Photo-1 Photo-2 Photo-3 Photo-4 Photo-5 Photo-6



Full-time web developer. Part-time smart ass.

I'm Brent Collier.

After a year and a half as an engineer on Twitter's Trust & Safety team, I'm looking for my next gig. Contact me if you know of something interesting.


gem install mysql FAIL

Posted on 11/09/2008

This is nothing new or monumental, but I thought I'd post it anyway.  I recently picked up a new Macbook Pro, and while setting it up for Rails development, I ran into a little issue while installing the mysql gem.  I'm sure this little tid-bit is probably posted a million other places on the intarwebs, but one more can't hurt.

So here's the problem.  You attempt to run a rake db task, and you get this...

!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql

So you do as it says and attempt to install the gem...

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out

Well shit.  That didn't work.  So here's what you need to do...

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

which should yield...

Building native extensions.  This could take a while...
Successfully installed mysql-2.7
1 gem installed



another rewrite

Posted on 11/07/2008

So I've got a problem...

I've got a wordpress blog, this rails blog, a tumble log, a twitter feed, and probably a few other blog/feed/things that I'm forgetting.   Aside from this blog, I post to the others fairly regularly.  Granted, it's typically only an iphone photo with some blurb of text, but still...

Here's the issue.  There's only a handful of people following this stuff (it's a shocker, I know) on a regular basis, so I can't really expect them to his 4 or 5 urls every time they want to see what's up with me.  My "followers" consist primarily of family, friends, and coworkers.  The family only checks the wordpress blog (and occassionally the tumble log) for pictures of the kids and my super-witty anecdotes.  The friends and coworkers mostly follow my tumble log and more recently, my twitter feed, which I've had for a while but didn't start using much till now.

Here's my solution.  I want to bring it all together.  Put it all in one place.  When someone gets bored enough to look me up, I want them to get the whole picture with having to play a game of musical websites.  This inspiration for this came from a blog that I've been loosely following for several months now.  The blog combines both life and tech posts, but all the while maintaining the separation of the two.


Notice also that he includes a link to his tumble log in the header nav.  I'd like to find a better way to incorporate Tumblr, but at this point, I'm not sure how.  The same goes for my Twitter feed.

Not only will this allow people to see everything in one place, but hopefully it will also encourage me to post tech content more often in order to keep up with the steady flow of family/life stuff.

So that's my plan.  We'll see how long it takes me to get any of it done.  For anyone interested in following the build, I've already setup a Github repo here.


backgroundrb troubles

Posted on 09/16/2008

So I recently spent several days upgrading an outdated backgroundrb install to the latest version.  The Backgroundrb documentation is a bit sparse, so needless to say, I quickly became an active member of the mailing list.

Actually, to be honest, I didn't end up joining the mailing list until after I spent nearly an entire day pulling my hair out over a very strange bug.

Basically, I would create a new worker, send it some work to do, and then nothing would happen.  The code looked something like this:

key = MiddleMan.new_worker(:worker => :prince_xml_worker, :worker_key => worker_key)
    worker = MiddleMan.worker(:prince_xml_worker, key)
    worker.async_build_pdf(:arg => html_string) 

(I was working on pdf generation in case you couldn't tell)

A little tailing of the background_debug log told me that I was requesting work on an invalid worker.  An invalid worker?  How could it not be valid?  I just created the freakin thing.  I thought maybe the key was wrong or something, so I added a debugger after the 'new_worker' line and tested it out.  To my frustration, the generated key was perfectly valid, as was the worker retrieved from the middleman.


I even managed to call the async worker method from the console and it worked perfectly.  But anytime that I would remove the debugger and let it run its course, nothing would happen.  It seemed ridiculous at first, but I thought maybe it just needs a second before its ready.  Nah...  That couldn't be it.  Just for kicks I put in a half-second sleep call where the debugger was previously, like so:

key = MiddleMan.new_worker(:worker => :prince_xml_worker, :worker_key => worker_key)
    worker = MiddleMan.worker(:prince_xml_worker, key)
    worker.async_build_pdf(:arg => html_string) 

...and it worker perfectly.  

This just seemed crazy, so I got on the mailing list, described my problem and had a response within the hour.  I couldn't believe it, but i was right.  It said that if you're developing on OSX that backgroundrb basically needs a split second to start up the worker, before it can be used.  Since only our development environments were OSX, I conditionally enabled the sleep command based on the RAILS_ENV.  Unfortunately, our staging server, which is a Gentoo machine had the same problem, so I had to update the code accordinly.


Whatever you do, don't put 'puts' statements in your workers.  I ran into the situation where my debugging of code was actually causing it to break, which wasted more time than I'd care to admit.


Keeping the pace

Posted on 08/12/2008

I'm currently working on a fairly large rails app that's been in development for the past couple of years. In fact, when it first began I think Rails was only at version 1.1 or 1.2.

A lot's changed since then, both in Rails and the app. I've been doing Rails development for over a year now, but I'm still far from an expert. I often find myself looking at a bit of code and wondering if it's some part of Rails (or ruby) that I'm not familiar with, or if it's something specific to our app. We have a lot of custom framework code, and given the size and age of our app, it's not unlikely.

Well, I found a case today in which it was both. I was in the middle of replacing a bit of classic_pagination with will_paginate and I noticed that it kept choking on hash.except(keys). I thought this was a little odd since it was plugin code, which I was pretty sure we hadn't modified. After a little poking around, I found that the except method was defined in a Hash extension in the lib/ directory. There was no way that will_paginate was referring to a bit of our code!  A quick Google search later, I found that ActiveSupport added the except method to Hash. Clearly one of two things had happened. Either we had implemented our own version of hash.except before it made it into Rails, or it had already been added to ActiveSupport, but we were just lagging behind on our Rails version.

When working in a field where the tools change so rapidly, it's very important to keep up with any changes that are made. This is especially important when the development lifetime of an app spans multiple releases of a framework.