Author Archive

Watch Multiple Logs in a Single Terminal

Wednesday, November 12th, 2008 by Nick Gauthier

Have you ever opened 4 terminal windows, SSHed each one into a server, and ran tail on all of them to watch 4 log files?

Have you ever had a terminal window open whose sole purpose was to run “tail my_log” over and over again to look at the output of a file?

It’s a pain, isn’t it?

Introducing “Watch Me” a simple ruby script that allows you to watch multiple log files simultaneously.

go from this:

Before Watch Me

Using multiple terminals to watch logs

to this:

Using WatchMe to watch logs

Using WatchMe to watch logs

(more…)

Fork Pools in Ruby on Rails

Friday, September 19th, 2008 by Nick Gauthier

If you need to process 1000 items independently, the simplest thing to do is to handle them one-by-one. But what if there is a large delay that is not caused by your application when you handle an item? What if you need to make a 100ms web request per item, only to do about 10ms of processing on that item? This would take 1000 x 110ms (100ms to wait, 10ms to process)!

So what do we do?

(more…)

Google AJAX Libraries on Rails

Friday, June 20th, 2008 by Nick Gauthier

If you’re reading this blog you’ve probably already heard about Google’s AJAX Library API on many other news sites like Slashdot.

I’m going to describe my simple process for setting up a RoR app to use Google to pull the APIs in a rails friendly way, throughout layouts, views, and helpers.

(more…)

Ruby on Rails Polymorphic Association Benchmarks

Friday, June 13th, 2008 by Nick Gauthier

Polymorphic relationships in Ruby on Rails are great. If you don’t know what they are, check them out here:

Understanding Polymorphic Associations

John and I were curious about the speed of these relations, since the linking between objects searches on both the ID of the foreign object, and a string which is the model name. So if you have two tables, ChildA and ChildB, your parent has a reference to child which is acutally the combination of child_id (the ID in the ChildA or ChildB table) and child_type (equal to “ChildA” or “ChildB”).

The old-school way of doing this involves creating a lookup table and using integer IDs for type, instead of strings. So you’d have another table mapping “ChildA” to “1″ and “ChildB” to “2″, then when you do your query, you are matching against the number “1″ and not the string “ChildA”.

The down side of doing it that way is that you don’t get to use Rails’ snazzy polymorphism, which makes life a lot easier. So we decided to run some tests to see how much faster it would be, and therefore, if it was worth it.

(more…)

Multithreading in Ruby on Rails

Wednesday, June 11th, 2008 by Nick Gauthier

Don’t you hate it when sites say “Please Wait” when you’d rather just come back later? I am always worried my browser will close and it won’t work. Or maybe I want to shut my computer down but I have to leave my task running. Read on!

(more…)

Using FFMPEG to Encode Video for iPod, iPhone Streaming, and Flash 9

Wednesday, May 21st, 2008 by Nick Gauthier

Read on to learn how to encode videos in to H264 for use by Flash 9, and also to stream to an iPhone in Safari, and be able to sync them onto an iPod.
(more…)