When something is repetitive, there's a shortcut

It happens all the time. You get into a habit of clicking around in an app to do a certain task. And you find yourself doing that same task again. Click, click, click. Again. Click, click, click. Why haven't the devs made a shortcut for this yet? Surprise: they have. You just haven't learned it yet.

At least that's what I've found to be true in most cases. It's surprising how much time you can save by catching yourself in the act of repetitive clicking, and making a conscious effort to replace that workflow with a shortcut.

And sometimes, you don't even need to search for the shortcut. Sometimes you can make a logical guess, and it turns out to be correct.

This just happened to me in After Effects. In order to change a shape's fill type from solid to linear gradient, I'd click the word "Fill" in the upper toolbar, then select the fill type, then click "OK".

FillType01

It finally occurred to me that there might be a better way. There might be a shortcut. After trying a couple other key combinations, I tried holding Alt and clicking the fill box. It magically switched from one fill type to another.

FillType02

I was learning a shortcut that everyone else probably knows already. But I felt like a genius, and that's what matters.

When coding, use the modulo to loop something over time

I recently started playing around with the app Pico-8 in an effort to better understand how animation can be created purely through code. It's been challenging, especially because I'm creating animations with code that doesn't exceed Twitter's 280 character limit.

One thing I learned while making my last Pico-8 animation is the power of the modulo, which is typed in code using the percent sign (%). In programming, this operator returns the remainder after dividing one integer by another. For example, 8 % 4 would return a value of 0 (because 8 divided by 4 equals exactly 2). 8 % 3 would return a value of 2 (because 8 divided by 3 gives you a quotient of 6 and leaves you with a remainder of 2).

In practice, I found that the modulo is really useful for looping something over and over while time continues to increase forever. Here's an animation, and its code, that uses this concept:

cls()
camera(-33,-33)
for t=0,159 do
    a,b=(t%2)*32,flr(t/2)
    c,d=(t%4)*16,flr(t/4)
    e,f=(t%8)*8,flr(t/8)
    g,h=(t%16)*4,flr(t/16)
    i,j=(t%32)*2,flr(t/32)
    if b<64 then
        line(a,b,a+31,b,1)
    end
    line(c,d,c+15,d,2)
    line(e,f,e+7,f,14)
    line(g,h,g+3,h,7)
    line(i,j,i+1,j,13)
    flip()
end

In the bolded code, you can see that the variable t is being . . . moduloed? . . . by five different values (2, 4, 8, 16, 32). The variable t represents time, and it increases by 1 every time the for function is called (which happens 30 times a second in Pico-8). So if I wanted to have something loop every second, I would use the equation t % 30 in order to get a value that is looping once every 30 frames, and then I would modify that value as necessary.

In this example, I am using the modulo to change the x position of different horizontal lines, and have them loop at different rates.