Last Year's Statistics

I've managed to keep this website up for over a year now, something that was unimaginable at a time. A nosey person would know that I've been tracking visitors using Mint (I browse source code as well!). Now it's time to reveal some astonishing facts! (Fake enthusiasm.)

This Year

There have been 9,100+ visits, 4,600+ of those being unique.

The top three visited pages are:

Most popular search term: “rails contact form”.

Most popular local search term (using my search function): “subversion”.

Most popular outbound link: Rails API on ActionMailer::Base.

Visits by browser: Firefox (44%), Safari (24%), Chrome (22%), IE (9%).

Visits by platform: Macintosh (51%), Windows (31%), Linux (11%). Did I mention I bought a PC, running Windows?

Random

My most popular referrer is linking to the wrong page because of how many times I've changed permalinks. My second most popular referrer is a page discussing my contact form articles. January 2010 was the all-time most popular month for this website.

Statistics are fun!

Filed in The Site.

no such file to load -- iconv

After upgrading from Ruby 1.8.7 patch-level 174 to patch-level 249, I noticed I couldn't run Rails anymore. After some investigating, I found out it was the iconv library (used for text conversions). Ruby apparently couldn't locate it (require 'iconv' failed). I was stumped, since it never had had this problem before.

The solution was to simply give the configuration script the location to my iconv installation (please note I'm running OS X Snow Leopard).

./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1 --with-iconv-dir="/usr/local"

Make sure to provide the correct path to your iconv installation. After compiling, require 'iconv' returned true. Huzzah!

Filed in Web.

Obligatory Post

I said it once, and I'll say it again.

Happy New Years!

Filed in Personal.

More Verbose Migrations

Migrations are a simple way of manipulating a database schema using pure Ruby. Rails migrations aren't tied to a specific database, which makes them very powerful. The same migrations and schema can be applied to MySQL, SQLite, Oracle, and a number of other databases.

This post is aimed at those who are already familiar with migrations and just want to add a bit of spice to them. I'm only writing about two simple methods that can make migrations a little more verbose. When rake db:migrate is called, it prints out more or less what is happening (tables or columns being manipulated). If you're running a migration that for instance cleans up records, Rails won't offer much information other than the migration's class name.

The first method is say_with_time(message). Here's a sample usage snippet.

say_with_time "Populating published_at column..." do
  # Sprinkle magic dust here
end

This will simple print the time elapsed since you ran the migration script and the provided message before executing the code inside the block.

Second, say(message, subitem = false). It basically does the same as the first method, prints a message to the console, but with the added bonus of the subitem option. The subitem option just indents the output, so it looks like it's part of the parent migration.

say "Adding default user to database...", true
# Sprinkle magic dust here

This would print the message indented in the console. Of course with the addition of a database seed file in Rails, putting default data in a migration is no longer needed.

Now, let's bring these fantastic methods together in one example.

say_with_time "Destroying users with nil account_id..." do
  if user.account_id.nil?
    say "Destroying user #{user.id}", true
    user.destroy
  end
end

Filed in Programming and Tutorials.

Sunday Afternoon Deployments

It's a glorious rainy Sunday, a great time to deploy. I talked about writing a new permalink structure for my website a couple days ago. It's now live! After about a week of working on it in my spare time, it's ready to see the light (and rain) of day.

Old Permalinks

The previous permalinks (/posts/1-title) still work. My plans are leave them intact to both be nice to anyone linking to my site with old URL's, and have a "Short URL" type service.

I'll be monitoring the site all of today to make sure no bugs got through, otherwise, enjoy!

Filed in The Site.