Monthly Archives: January 2011

Using regular expressions? The Devil is in the details.

Recently, I ran into a little roadblock as I’ve been cleaning up some bugs for one of my applications. I rely heavily on cross pollination of data between sites to drive traffic across my network. In this particular situation, a simple collection of linked image thumbnails accomplishes this task.

One of the helper methods that I use returns the file name of a supplied post object. To do this, I perform a regular expression match against the post’s URL and return the result.

# post.url(:icon) = id/10/icon/foo.jpg
# returns "icon/foo.jpg"

def filename_from_post(post)
  return post.image.url(:icon).match(/icon\/.*\.jpg)/)[0]
end

That worked great until my application would randomly throw a NoMethodError. I spent a while scratching my head, looking over my code, checking my SQL queries, and so on and so forth. Finally, I figured it out…I had forgotten to specify a case insensitive search!

# post.url(:icon) = id/10/icon/bar.JPG
# returns nil

>> post.url(:icon).match(/icon\/.*\.jpg/)
=> nil

>> post.url(:icon).match(/icon\/.*\.jpg/i)
=> #<MatchData "icon/bar.JPG">

I guess what they say is true…the Devil is in the details.

A few shots from Thunderhill with ACGG

What a fun event, thanks to ACGG for everything! I had some car trouble so I only got to run a few sessions in my car on Saturday, luckily my buddy Oliver let me drive his car the rest of the weekend. For the record, anybody who tells you a Stage 3 B5 S4  is no fun has never driven a car with no traction control and a LSD!

Since the temps on Saturday were in the low 30s and my Direzzas had literally 0 miles on them I decided it would be best to run with my street wheel and tires. Surprisingly, 20″ Works with 255/30/20 Falken 452s handle quite well!

Here are a few shots of me in my car, and in Oliver’s B5 S4.