SR-410 MP 107 10-11-2009

It takes a giant landslide to destroy a quarter mile of road way. It’s the end of summer, it hasn’t rained yet here… what was the tipping point for it?

Cleaning up your Address Book on OS X with Ruby

Lately I’ve been working on mailing out wedding invitations. The easiest way to print address labels on OS X is to select contacts or a group in Address Book, hit print and change the Page option to “Avery Standard” then select the label type. Easy. The hard part is getting all those addresses in there in the first place and then organizing them. My problem was that I imported things incorrectly a number of times and filled my address book with 1500 or so broken contacts. That made it really hard to call someone because I had 15 very similar looking entries for each person. Fortunately all the addresses I imported were missing phone numbers, so I knew I could group them together easily (with a smart group) but how could I script the name edits like “Add ‘& Guest’ if the name doesn’t include an &”? Not to mention I didn’t want to end up with contacts like “Joe Smith” next to one named “Joe Smith & Guest”!

First I tried to do this with AppleScript and 25 minutes into it had something working, but working with AppleScript is so strange, I needed ruby! In 10 minutes I had the following script written and now I could also use ruby to push/pull/stretch and tweak all the data I have in Address Book already, yay.

Here is the AppleScript version of the same script:

Here is a great reference for how to work with Address Book from AppleScript that you can combine with the rb-appscript guide on commands to add new contacts, etc. Now I’ll leave it up to you to go write a script to update your contacts picture in Address Book from their facebook, linked in, gravatar or other photo. Or perhaps see if they have a DandyID and add all their associated accounts to their contact entry.

Exploring test driven development with Javascript: A look at jsunit, JSSpec, and Screw.Unit

I gave a talk at Seattle Code Camp on testing Javascript about TDD (test driven development) in Javascript using jsunit, JSSpec and Screw.Unit. One thing to come out of this is a github project that is setup to allow you to test your javascript against all three frameworks in one package:

http://github.com/wesmaldonado/test-driven-javascript-example-application/tree/master

Just want to see what the same tests look like between the frameworks? Here you go! A jsunit example, JSSpec example, Screw.Unit example.

The presentation was a walk through the code, so there aren’t slides yet, contact me if you’re interested in having me present at your company or to your group.

Many thanks to Nick Kallen for Screw.Unit and other various Javascript hackery. Brian Takita for JSSpec/Screw.Unit servers , Edward Hieatt for JsUnit and the blog posts about testing javascript. Finally, I want to thank all all the people at Pivotal Labs for the countless hours of pair programing that led to me learning these libraries and testing techniques.

Back to my roots, procrastinating for fun and profit!

The psychological principle is this: anyone can do any amount of work, provided it isn’t the work he is supposed to be doing at that moment.

Robert Benchley

For the next month I will be free to wander around aimlessly. If you’ve been wanting to hang out with me for any reason, the time is now. Call me at +1 206.240.4233 to get my attention, I might be available. I might be more available if you offer any of the following:

  • Breakfast
  • Private Suites at Safeco for Mariners games
  • Sushi
  • Coffee/beer/tea and an interesting topic
  • Free stuff (llamas and ponies not accepted at this time)
  • Speaking engagements wherein I may ramble aimlessly
  • Pogo Stick Jousting Facilities

Thanks! I’ll leave you with the rest of the essay from Robert Benchley, How To Get Things Done, available from this compilation of his essays.

Let us see how this works out in practice. Let us say that I have five things which have to be done before the end of the week: (1) a basketful of letters to be answered, some of them dating from October, 1928 (2) some bookshelves to be put up and arranged with books (3) a hair-cut to get (4) a pile of scientific magazines to go through and clip (I am collecting all references to tropical fish that I can find, with the idea of someday buying myself one) and (5) an article to write for this paper.

Now. With these five tasks staring me in the face on Monday morning, it is little wonder that I go right back to bed as soon as I have had breakfast, in order to store up health and strength for the almost superhuman expenditure of energy that is to come. Mens sana in corpore sano is my motto.

Found via The Pmarca Guide to Personal Productivity

Handling Eventual Consistency with Amazon SimpleDB and Ruby

Eventual consistency. The storage system guarantees that if no new updates are made to the object eventually (after the inconsistency window closes) all accesses will return the last updated value.

My coworker wrote up our experience writing ruby integration tests against Amazon SimpleDB. You should know that we were in an integration test that runs infrequently. Production code should not use this retry method. You should be using exponential back off when you get an error code. I’ve heard that not doing this is the equivalent of crossing-the-streams in Ghost Busters.