Concepts
Bitwise Operators - My coworker Scott taught me about these today. ‘|’ (or), ‘&’ (and), ‘«’ (shift), ‘^’ (xor), etc. They’re done at the hardware level, meaning super efficiency. It’s basically the same as the operators in circuits, except codified / in decimal representation. For example, 3|4 = 011|100 = 111 = 7.
Bitmasks - Imagine you’re conducting a survey on people’s diets (this is probably not a great example) - eats chicken vs doesn’t eat chicken, drinks milk vs doesn’t drink milk, eats beef vs doesn’t eat beef, etc. You could record each person’s every answer as a separate string/boolean, or you could record all their answers as one number. With 1 being ‘eats it’ and 0 being ‘doesn’t’, 100 = eats chicken, doesn’t drink milk, doesn’t eat beef. 101 = eats chicken and beef but doesn’t drink milk. Bitmasking is using bitwise operators to test against conditions. In an ‘if’ statement, I can test if the person drinks milk by performing a bitwise ‘&’ on their answer with 010. If the result is greater than 0, then the person drinks milk. Yes this could be done with other conditional tests but from what I gather, bitmasks / the whole integer representation concept in general are significantly more lightweight, albeit possibly harder to understand.
& - Another magical Ruby shorthand. This one took me a while to understand, and I have to admit even now I’m a bit shaky on it. Basically if used on a Proc (variable which references a method), it’ll convert it to a block. If used on a block, reverse happens. This article did a good job of explaining it. The only thing I’d add is that in work we use it a lot for mapping. Normally to map you’d do
foos.map { |foo| foo.bar }
which performs ‘bar’ method on every item (foo) in ‘foos’. You can shorthand it to
foos.map &:bar
The & converts the ‘bar’ symbol to a block and calls it on each iteration, doing the same thing as the long(er) version.
Law of Demeter - A general guideline for loose coupling / making your code more maintainable and safe. Doubt I can explain it better than that article, it’s a pretty easy read.
Technologies
Page Speed - Extension for web developer tools which tells you how to improve page performances
RDebug - Great gem for debugging / stepping through code in Ruby. This article explains pretty well how to use it
A/Bingo - Possibly one of the ugliest sites I’ve ever seen but very neat plugin for Rails A/B testing
Cool Articles
Linux Fundamentals
Photoshop pushing photo magix further with unblur