Thursday, February 6, 2014

January #TMIL

Here's to keeping up with one New Year's resolution!

Documenting and collecting resources has always helped me learn, not only for the occasional refresher but also a reminder of the progress I'm making (or not). For some of us, giving oneself a pat on the back every now and then isn't as forthcoming as it should be. Amidst the countless blog posts, tutorials, books, projects and rabbit holes, I'd like to begin collecting them a bit better. Just kidding, I'm kind of an information pack rat as anyone who's seen the multiple browsers on my computer, each with multiple windows containing dozens of tab, can attest. I'd like to start sharing more as a way to help others and help keep myself organized and focused. With that, here's the first This Month I Learned.

Ruby and Rails bits

Route globbing and wildcards in Rails
-A colleague recently pointed out this feature of Rails which I hadn't used. By including a wildcard in your route, you can grab the matched value as a param. Here's one of the examples from the RailsGuide:
get 'books/*section/:title', to: 'books#show'
would match books/some/section/last-words-a-memoir with params[:section] equals 'some/section', and params[:title] equals 'last-words-a-memoir'.

Cleaner metaprogramming

-Ruby methods defined using define_method show up when you call #methods on an object even though ones defined at runtime with method_missing don't (unless you define a responds_to that basically matches your method_missing). This makes sense - defining it versus rescuing an error with method_missing, though I didn't expect it.

-The Code School Ruby Bits 1 and 2 courses helped me really understand what's going on with class_eval and instance_eval - the exercise of rolling your own DSL was lots of fun. Like many/most things in Ruby, knowing what self is is the key. (Isn't 'is is' fun?) I've also been working through the Metaprogramming Ruby book. One of my broader 2014 goals is to go from (feeling like) an intermediate to advanced Rubyist -- although like most things, I'll likely always choose the beginner's mindset -- and this book seems highly recommended across the board. (Although it had some competition from Ruby Under a Microscope.) Contrasting the use of yield and instance_eval also helped understand both better. This post is a good tl;dr, and the Recipes DSL from this page provides a fuller example.

Non-Ruby misc.

I decided February would be vim month. While I've used the editor of the beast for basic editing, I'm still mostly a n00b when it comes to fluently switching between editing modes, using buffers and registers, knowing the plugin landscape, and other everyday editor tasks. While I'm not about to give up my precious Sublime Text (which has a vintage mode too) just yet, I'm trying to spend more of my time in vim. The main benefit I hope to realize is having a more integrated development environment by switching contexts less and keeping things in the terminal. Also to better follow colleagues' use of it.

These CSS animations were from December but get honorary mention since they were fun to make and I can't think of anything else to include right now. The code is here or in your friendly neighborhood web inspector.

Although most of my work is in Rails these days, I'd like to learn a Javascript framework well this year. While I've started poking around with Backbone via the Railscasts and Code School course, it's too early to tell which one I'll prefer. I've also been seeing a lot about the MEAN stack, not to mention the neverending comparisons of the Javascript MV* options. The solution? As always, learn enough about all of them to know what to choose when the right projects presents itself.