Wednesday, May 28, 2008

See you at Railsconf 2008

I'll be leading two Birds of a Feather sessions at RailsConf 2008 that I hope everyone will attend (or flock to):
I was also invited to sign copies of the book Advanced Rails Recipes (to which I contributed a couple of recipes) at Powell's books in Portland on May 30th at 12:30 pm.  Hope to see you there!

I'll be there with the full OtherInbox contingent, so if you're looking for an awesome startup to join, come and track us down.

Sunday, May 25, 2008

random_data v1.3.0 released

random_data is a testing and seed data gem I wrote a few years back to help get Ruby projects up and running with semi-realistic fake data (the faker gem provides similar functionality).

I just released version 1.3.0 which includes a bunch of RDoc enhancements as well as some new features contributed by the tireless (and patient!) Hugh Sasse:
  • Added RandomData::Grammar, which lets you create simple random sentences from a grammar supplied as a hash, like so:
    Random::grammatical_construct({:story => [:man, " bites ", :dog], :man => { :bob => "Bob"}, :dog => {:a =>"Rex", :b =>"Rover"}}, :story)
    ==> "Bob bites Rex"
  • Added Random.bit and Random.bits
  • Added Random.uk_post_code
  • Bug fix: zipcodes should strings, not integers
Thanks Hugh!  Open source is awesome!

Using Ruby's Autoload Method To Configure Your App Just-in-Time

Reading The Ruby Programming Language was a great experience — like revisiting a country I thought I knew intimately, but with expert tour guides who showed me whole new landscapes. It's also a good primer on what's changing in Ruby 1.9.

One of my favorite discoveries was Ruby's autoload method. Using autoload, you can associate a constant with a filename to be loaded the first time that constant is referenced, like so:
autoload :BCrypt, 'bcrypt'
autoload :Digest, 'digest/sha2'
The first time the interpreter encounters the constant BCrypt, it will load the file 'bcrypt' from Ruby's current load path, which it assumes will contain the definition of that constant. (Note that autoload takes the name of the constant, in symbol form, not the constant itself).

Here's an example of how useful it can be. OtherInbox uses beanstalkd in a few places where we haven't yet migrated to SQS. I was loading the beanstalk client with a Rails initializer, 'config/initializers/beanstalk.rb':
require 'beanstalk-client'
BEANSTALK =['localhost:11300'])
Making this initial connection on our production server takes five seconds or more each time I restarted the app or dropped into the console. That doesn't sound like much but when you're doing that a few times a day, it starts to add up. So I moved the beanstalk code out of the initializer and into 'lib/etc/load_beanstalk.rb'. I placed all of my autoloads in a single initializer, 'config/initializers/autoload.rb'. For beanstalk, the statement is:
autoload :BEANSTALK, 'etc/load_beanstalk'
Now, the app starts more quickly, and even better, this library doesn't get loaded into memory by parts of the app that don't need it.

Wednesday, May 21, 2008

ORDER BY null kills MySQL filesorts dead

I spent some time today optimizing OtherInbox.  As our private beta expands, we are starting to see heavier usage, and so it's time to revisit some of my beloved SQL queries.

I use the MySQL slow query log to find out which queries were taking the most time -- that's been a wonderful tool that I plan to blog about later.  I will note that the output is much easier to make sense of if you parse it first with this script.  (It's really old, so I had to modify it to look at Query_time instead of Time)

Using the EXPLAIN command for each of the slow queries identified in the above log, I found one that was especially disturbing.   According to EXPLAIN's "extra" column, MySQL was resolving these queries with two fairly expensive operations: 
Using where; Using temporary; Using filesort
Fixing the "Using temporary" required some nimble manipulation of indices, but filesort was really perplexing me.  I wasn't using an ORDER BY clause, so as I read the docs, there was no reason to be doing a filesort.  But then I remembered that MySQL automatically does ordering based on GROUP BY clauses.  All I had to do was add "ORDER BY null" to the end of my query, and that did the trick:
Using where; Using temporary
If only all optimizations were so simple.

Wednesday, May 14, 2008

Applications due for Baltimore Improv Festival 2008

We have a formal application process for this year's Baltimore Improv Festival taking place in August.  Submissions are due May 23rd.  We'd like to get as diverse a pool of performers from all over the country as we can.

On a related note, BIG has been accepted into Artscape to perform on the Saturday night show (7/19)  along with the Mimehunters.  See you there!

Monday, May 12, 2008

SocialDevCampEast recap

SocialDevCampEast on Saturday was a blast.  Lots of talk about building up the "Amtrak corridor" running from DC to Boston as one unified, tech-ified region.  The talks people gave were interesting (I even got to do one on my experiences with Amazon Web Services), but for me the most valuable experiences took place in between sessions and at the after-party held at Brewer's Art.  

I met several cool DC, MD, and VA entrepreneurs which was really invigorating.  I found out about some new blogs that I need to be reading, including, written by the creator of the newly-launched

I also saw first-hand the value of Twitter, which I'm very late to the party on.  I don't know that many people in my own circle who were using it, but after seeing how it was fostering the collaboration among people in the conference environment, I'm sold, especially if you have something client-side that checks tweets for you (my friend Brian Lyles aka Smarticus recommended Twitterific, which works great).  So you can now catch me @subelsky.

Thanks to the sponsors and organizers for a great event; I'll be at the next one for sure.

Tuesday, May 6, 2008

Startup community in Baltimore

I just found about a very interesting Barcamp called SocialDevCamp East planned in Baltimore on Saturday, just a few miles south of my house. It's very heartening to see enthusiasm building for a tech community here on the east coast and this has gotten me thinking about the Baltimore startup community in general. Below are some notes on startup life in Baltimore.

  • Here are some Baltimore startups I know about:

    I'm sure there are more; send me some and I'll add them to the list.

  • I've talked to many other Baltimore entrepreneurs with ideas in various stages of development, and there are lots of hackers here working remotely (or commuting to DC and Northern Virginia) on startups. We're also the home of which employs a lot of smart people and brings a lot of talent to the area.

  • I meet a lot of cool hackers through the local Ruby on Rails meetup.

  • One of my favorite blogs is written by a Baltimorean, Paul Barry. He's a Ruby on Rails expert, but has in no way drunk the Kool Aid. He's got plenty of love for Java and Scala and whatever else gets the job done.

  • I've been dreaming for awhile about organizing a "Baltimore Demo Night" where all of us could gather and show off our wares, get feedback, and so on. Who's down for that?

Advanced Rails Recipes out now

I contributed two recipes to the newly-released Advanced Rails Recipes which I highly recommend.  It's got 84 very eye-opening solutions to problems faced by a lot of Rails programmers.  

I feel lucky to be working with cool, open technology that's yielded an opportunity to be part of a project like this.

Thursday, May 1, 2008

Looking for Rails developers (who isn't?)

For the past seven months I've been building a cool new consumer web app with some folks in Austin, TX,, and we're looking for experienced Ruby On Rails developers. We're a small agile team led by Steven Smith, founder of FiveRuns.

The whole site is Rails-based and makes extensive use of Amazon Web Services (EC2, S3, and SQS) and there's a new awesome challenge every day. More info on our jobs page.