Benjamin Curtis

Speculations on Web Development

Skipping Asset Compilation With Capistrano

| Comments

Capistrano has a handy task that runs rake assets:precompile for you when you are deploying your Rails 3.1 application. This gives you an easy way to get the performance boosts of having only one css file and one javascript file to load per request. The price you pay for that benefit is the amount of time it takes to run that rake task when you are deploying. There is a way to get the benefit while reducing that cost, though.

Since capistrano creates a symlink for the assets that is moved across deploys, you really don’t need to compile those assets for any deploy where the assets didn’t change. Instead, all you need to do is move the symlink. However, the default capistrano for compiling the assets does compile them every time, regardless of whether any assets were changed in the set of commits that you are deploying. The trick, then, is to check the list of files that were changed in the range of commits that are being deployed, and compile the assets only if assets show up in that list. And here is a code snippet that does exactly that:

It only supports git, as that’s what I use, so if you use git, just drop that snippet into deploy.rb and enjoy quicker deployments.

Deploying New Relic Server Monitoring With Chef

| Comments

This morning I deployed New Relic’s new Server Monitoring feature for the first time (I’ve used Scout previously). It’s cool to see your server vitals right next to all your app vitals, and their interface looks attractive, to boot.

Since I deploy everything with Chef, I threw together a quick Chef recipe to automate the installation of New Relic’s server monitoring agent. It has been tested with Ubuntu 10.04 LTS, and you can configure the license key in your Chef JSON config.

You can grab the recipe from my Chef recipe repository at Github.

Improvements to Bundle Watcher

| Comments

I just released an update to Bundle Watcher this morning that may make it a little easier to get your Ruby gem updates tracked. Now you can specify a URL where your Gemfile.lock resides, rather than having to upload a file.

You can also now see a list of bundles that your tracking, once you’ve logged in via Github. This list shows you at a glance which gems have been updated for your bundles.

Faker 1.0 Released

| Comments

Earlier this week I released version 1.0 of the Faker gem. It’s been about 4 years since the initial release of the gem, and the API has been fairly stable for the last couple of years, so I figured it was a good time to make the jump to 1.0. :)

This release finishes the conversion to I18n. Just about everything is in the locale files now, including the ability to define custom formats for everything – company names, street addresses, etc. And, with the magic of method_missing, you can add new items to your locale file and have them show up as methods in the Faker classes.

The 1.0 release also settles some long-standing issues people have had with bad interaction between Faker, Rails 2.3, and locales (especially fallbacks). Though I’m not actively seeking to support Rails 2.3, I at least don’t want it to be broken, so this release should cover that. Both Ruby 1.9.2 and 1.8.7 are fully supported.

Finally, I want to send out a big “thank you” to everyone (and there are a lot of them) who contributed code and ideas to this release. I really appreciate the interest shown and the work done by so many people who use and love Faker. According to rubygems.org, it has been installed over 400,000 times — over 1,000 times in the past few days!

Of course, I’m not done yet… next on the feature list is Faker::Image, which will provide an interface to all those cool fake image generator services out there. :)

CentOS 5.5 Net Install Secret

| Comments

Today I needed to spin up a VM with CentOS 5.5. My preferred distro these days is Ubuntu, and I had to learn the CentOS dance to get an unsupported version installed, so it took me a little longer than I would have liked to get it going. Here’s the secret:

When asked for the name and directory of the install image, enter vault.centos.org for the name and 5.5/os/x86_64 for the directory. If that doesn’t work for you, go back a step and disable IPv6. After that, you should be good to go.