The Two-Envelope Paradox

You just finished some yard work for your eccentric neighbor, Mr. Grimes. He prepares some lemonade for you while you rest at his kitchen table.

“Thank you for your help today,” he says as he places two envelopes on the table in front of you. “Both envelopes contain money. Pick one and you can keep the money inside.” As you reach for one of the envelopes he adds, “One envelope has exactly twice the amount of money as the other.”

You pick one of the envelopes and open it. Inside you find a $20 bill. You are about to pocket the money when Mr. Grimes interjects, “I’ll give you a chance to switch envelopes if you’d like.”

Should you switch envelopes?

Using Capybara in Rails 3

Capybara makes it easier to write integration tests. Its syntax is very similar to Webrat’s. The main difference between Capybara and Webrat is that Capybara has more architectural flexibility. It works with a variety of JavaScript-enabled browser simulators and–because it’s based on Rack–it works with any Rack-compatible web application or framework. Another advantage is that Capybara is compatible with Rails 3, but Webrat isn’t. Because Capybara is basically a more flexible Webrat, Capybara and Webrat are likely to merge.

Rails 3 Online Conference Word Cloud

I used Wordle to create a word cloud from the chat transcript of the Exploring Rails 3 online conference.

Installing Rails 3 Beta with RVM and Ruby 1.8.7

Jeremy McAnally posted some great instructions on installing Rails 3 beta. When I tried to install Rails 3 it complained that my Ruby version needed to be at least 1.8.7. Fair enough, I only had 1.8.6, and it was about time I upgraded.

Streamlining Your Workflow with AppleScript

When developing web applications, I frequently switch between iTerm, TextMate, my browser, and my mail client. So I used AppleScript to streamline my task-switching. I’ll show you how I did this in case you’re inspired to streamline your workflow, too.

Getting Mugged by Nokogiri

Once you’ve gotten started with Nokogiri, you’ll expect everything to be as easy as the beginning, and then–BAM!–you’ll get sucker-punched.

Getting Started with Nokogiri

Nokogiri is a Ruby document parser that was released in October 2008. It’s great for reading, searching, editing, and otherwise mucking around with HTML (and XML).

New Release of Alphabet Clock

I’ve made some improvements to Alphabet Clock, most notably the inclusion of dates and developer libraries.  Read the full story on Alphabet Clock’s blog.

Automating Your Backup with Cron

cron is a daemon that will execute commands at a scheduled date and time. You use the crontab command (short for cron table) to set up cron to execute commands at regular intervals.

If you haven’t used cron before, I recommend reading this excellent introduction to cron and crontab and looking at this example crontab file. You should have at least a basic understanding of crontab before proceeding.

Backing Up Your Data with Astrails-Safe

Astrails-safe is a ruby gem, so you can install it on your web server like so:

sudo gem install astrails-safe