Posts

May #TMIL - A Touch of eval()

In a Rails app, I've got a Plan that belongs to a Subscription. The Plan has a duration, and the Subscription has an expiration. The expiration gets set in an after_create callback using the current time (DateTime.now) plus the Plan's duration. Then, there's an expired? method on the Subscription which checks if self.expiration < DateTime.now . Pretty straightforward, right? (code snippet below)

April #TMIL - RSpec

As expected, this series of posts has drifted off schedule. At least the drafts have been on time! Below is a list of RSpec tips, preferences and best practices I've been accumulating over the last year, finally realizing that's it much more art than science.

March #TMIL - Ruby class macros

My how the time flies. Still, I'd rather be late than abandon my New Year's resolution early! Here are some notes that have been sitting in this draft for the last two months. Two quick tips PC Keyboard Hack is a must-have extension for me. I find it's much nicer on your hands to avoid using the Return key on the right side of the keyboard. (You can make some remappings in the Keyboard->Modifier Keys panel in the OS X system preferences; however, Return is not an available choice for remapping Caps Lock.)  Enable control-R backsearch in irb by adding this code to your ~/.editrc file : bind "^R" em-inc-search-prev Source Class macros in Ruby

Add a Keyboard Shortcut to Toggle WiFi On and Off

Clicking the WiFi icon in OS X on and off when you're trying to troubleshoot Internet connectivity or AirPort issues can be annoying and disruptive to your workflow. Here's how to add a global keyboard shortcut to do it: Copy the script from  here  and paste it into a new document in the AppleScript Editor. Save it as ToggleWifi (or whatever you want). Save it with Application as the file format. Since there's no built in way to create a keyboard shortcut to launch an application in the Keyboard system preferences panel, first create a Service in Automator. This post  shows screenshots of the steps to create the Service. Open Automator, go to File->New and choose Service from the options that appear. Set "Service receives selected" to 'no input' and leave "in" set to 'any application'. Then search for the Launch Application action in the Actions menu on the left, and drag it to the open area that says "Drag actions or files h...

February #TMIL - vim

Although it's already halfway through March, I'm not quite ready to give up on my resolution to collect a few of the things I've been learning each month as an opportunity to review the material. Don't worry, it's all a healthy exercise in non-competitive professional development. I haven't gone crazy but the risks of losing balance described here are very real, especially when you enjoy what you're doing. OK, on to the good stuff. Vim I've been meaning to learn more than the basics of Vim for years and finally dug in last month.

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.

Book Review of POODR: It Helped the Pieces Fit Together

After an extended blogging hiatus, time to take some baby steps back in by reposting my book review on Goodreads for " Practical Object-Oriented Design in Ruby ," aka the POODR book. This book helped tie together my understanding of OOP best practices in Ruby and has produced immediate benefits in the quality of code I'm writing. It contains great examples of refactoring code, along with checklists, red flags and questions to ask yourself throughout the design process.  The author does a great job of following the development and improvement of a sample app throughout the book (an app for a bike shop). The continuous narrative helps you see how the pieces fit together, though a few examples from other domains would have been helpful in some places. At the same time, that's really an exercise for the reader.  I found Chapter 4's discussion of creating a public interface particularly helpful in determining the proper responsibilities of objects by "Ask...