I got tired of all todo apps and needed a simpler way of handling my everyday tasks.
My OS X desktop was mostly empty, I was only keeping files that reminded me of tasks.
So I though, why not use my desktop as my todo list? I already spend a lot of time in
the terminal so a simple ZSH todo function solved all my todo problems.
Bonus: If you’re using Alfred on OSX, you can use the workflow below. Just type “todo” in Alfred’s command window and make sure you escape or quote the arguments if they contain spaces.
I thought drawing gradients on iOS is easy. Well, until our designer gave me this:
I went on and implemented the drawRect: method on a custom UIView. I used CGGradient and wrote the drawing code. I ran the project in the simulator and noticed that the gradient was quite different. Ran on the device, same thing.
I played around with different colors and their positions but nothing turned out like the Photoshop gradient. After some head scratching I figured it must be something to do with how the colors are interpolated. CGGradient uses a linear interpolation of colors.
What I need is a slope (ease-in ease-out for you familiar with animation timings) function and apply that to each color component. I actually cared only about transparency so I had to only adjust the alpha channel.
I needed this:
Looking at the documentation, CGGradient doesn’t support custom color interpolation. There is something called CGShading that does. The documentation is not absolutely clear on how to use it, but after some experimenting I came up with a solution, which is presented below. There is also a sample project available on GitHub so you can compare CGGradient and CGShading.
Most programmers are familiar with the ternary operator ?: that is available in C and most other languages.
But what some people may not know is that you can also use this operator with only two arguments.
Instead of writing
you can do this
The other thing some of you may not know is that when defining a const you can’t use an if statement to define it based on a condition, but you can do this: