Archive for May, 2008

27th May
2008
written by simplelight

Over Memorial Day weekend I migrated my Rails Application to Dreamhost using mod_rails (Passenger). It was not an entirely smooth process but I was also upgrading from Rails 1.8.x at the same time. That was compounded by making the foolish mistake of trying to rebuild my database using Rake migrations. (That’s a bad idea. I could have saved many hours by just uploading the schema)

Here is the procedure I followed (hat tip to Nock):

  1. cd ~/
  2. rails your_app_name -d mysql
  3. Copy app/, database.yml, routes.rb, db/
  4. Change public/.htaccess from .cgi to .fcgi
  5. put your app into production mode (uncomment line 5 in environment.rb)
  6. run rake db:migrate RAILS_ENV=production
  7. chmod -R 755 ~/your_app_name/app
  8. rm your_app_name/public/index.html
  9. killall -USR1 dispatch.fcgi
  10. killall -USR1 ruby

One comment on step 4. For some reason none of my stylesheets would load. Much of the advice gleaned from endless Google searches seemed to suggest that the problem would be fixed by setting the RewriteBase in /public/.htaccess. That turned out to not be the case.

My stylesheet problem was caused by having this line twice in my .htaccess file

RewriteRule ^(.*)$ dispatch.fcgi[QSA,L]

DO NOT uncomment the one before RewriteEngine On , as all the tutorials seem to imply, just change the .cgi to .fcgi in the block below it.

Thanks to Dreamhost for their stellar support over a frustrating (for me!) Memorial Day weekend. In the end, (as is so often the case), very little of the frustration was caused by Dreamhost or mod_rails but, rather, by some of the vagaries of Rails. I’m guessing that future deployments would be much smoother as this was my first time deploying to a shared hosting environment.

26th May
2008
written by simplelight

I use Dreamhost to host my websites and they have now added support for Passenger (a.k.a mod_rails). Ruby on Rails deployment hassles should be a distant memory soon!

If you’re looking for a cheap and cheerful hosting company for your Rails app, I highly recommend Dreamhost. It’s great for the solo developer (or small team) because for a small amount per year you can launch your site on a shared hosting service and then later easily migrate it to a virtual private server as your needs change. 

Dream in Rails

25th May
2008
written by simplelight

Omega Okello has released her new CD, Kiwomera Emmeeme. You can pre-order it now at Amazon and it will be released on May 27th, 2008. I’ve heard her sing live and it’s a great experience.

Here’s the blurb from her website:

Not only does this East African Diva burst on the world music scene with a unique name, but she also blazons into the industry with a fantastic new sound. Omega Bugembe Okello, who just goes by the name Omega, is blessed with a powerful vocal range and the international ability of singing in various languages and dialects.

The songstress who hails from Uganda has been described as “having a voice that touches the soul”. If you listen to her music you will undoubtedly agree. She definitely has the kind of voice that pleasantly, but hauntingly seeps into one’s soul and her latest album, Kiwomera Emmeeme, embodies this very essence.

Listen to Mujje a few times and you will be humming it the rest of the day!

25th May
2008
written by simplelight

To link to Amazon, use the following code

http://www.amazon.com/exec/obidos/ASIN/<10 digit ASIN number>/simplelight-20

Simply insert the relevant ASIN number for the product that you are linking to. You can find the ASIN number at Amazon’s Associate page

For example, to you would link to For One More Day by Mitch Albom like this:

24th May
2008
written by simplelight

If you’re looking for a game of touch rugby and live anywhere close to Stanford, there is a regular game at 3:00pm on Saturday at Roble field on the Stanford campus which has been running continuously since 1996. It runs year round and has solid representation from all the rugby playing countries. There are usually 30 or more players of varying ability and newcomers are welcome.

More details can be found here. There is also a Google Group that you can join to keep up to date.

24th May
2008
written by simplelight

To enable 640×480 video in Skype (instead of the usual 320×240 resolution), add the following lines to the config.xml file in the Skype user directory

<Video>
    <CaptureHeight>480</CaptureHeight>
    <CaptureWidth>640</CaptureWidth>
    <Fps>30</Fps>
</Video> 

There will probably already be a <Video> … </Video> section in the file so just add the middle three lines in that section.

The config.xml file is typically located in:

c:\users\<win_username>\AppData\Roaming\Skype\<skype_username>

Note: The “AppData” folder is a hidden folder so you’ll have to search for it. Either that, or just make all the folders in c:\users\<win_username> visible.

I’m running Windows Vista 64-bit so your location might be different. (If you do have the location for a different OS please leave a comment and I’ll update the post). If you enable “Display technical call info during calls” under Skype->Options->Advanced->Connection, you will be able to monitor the resolution and frame rate. (Hover your mouse over the main Skype tab and a yellow box will pop up with all the technical Skype data, including frames per second, transfer and receive resolution. This is useful for testing whether you are indeed sending the higher resolution image.)

Also, make sure you have the latest Logitech webcam driver installed. You don’t need the Logitech app, just the driver. I use the Logitech Quickcam Ultra Vision  and the image quality is very good.

Skype has gone to great lengths to differentiate this “hack” from their HQ (high quality) video (which requires Skype-endorsed webcams) but I think the difference is marginal if you have decent hardware and bandwidth. It appears that as of Skype 3.8 you will no longer see the usual HQ Video logo but you will still be transmitting video at the higher resolution. Your frame rate might take a slight hit depending on your uplink bandwidth. 

(As an aside: I highly recommend not upgrading to the current Skype 4.0 beta)

9th May
2008
written by simplelight

In the first week of my freshman year in college I went to a talk that was given by 4 people who had been disabled as a result of attempted abortions. Their mother had subsequently given birth to them. This video reminded me of that formative hour of my life.

[youtube=http://www.youtube.com/watch?v=yLi_Q74RH9Q]

8th May
2008
written by simplelight

The Tiobe Programming Index gives an indication of the popularity of programming languages. I’m pleased to see that Ruby (and consequently Ruby on Rails) continues to move up the rankings. I guess I’m going to have to learn Java at some point.

6th May
2008
written by simplelight

Newsweek has a fascinating article by Fareed Zakaria. Some of the interesting points he makes:

  • 20 years ago the US had the lowest corporate taxes in the world. Today the US has the 2nd highest.
  • Only three countries in the world don’t use the metric system: Liberia, Myanmar, and the US.
  • In 2006 and 2007, 124 countries grew their economies faster than 4%.
  • The share of people living on $1 a day has plummeted from 40 percent in 1981 to 18 percent in 2004
  • The global economy has more than doubled in size over the last 15 years and is now approaching $54 trillion. Global trade has grown by 133 percent in the same period.
  • In World War II Germany suffered 70 percent of its casualties on the eastern front yet the American narrative is one in which the United States and Britain heroically defeat the forces of fascism.
1st May
2008
written by simplelight

I’ve heard before that walking a mile emits more carbon than driving a mile so decided to investigate for myself.

A 190lb human walking at 3 miles per hour would expend 302 kCal. Therefore, covering a mile would take 20 mins and approximately 100 kCal. Apparently it takes 7-10 kCal of fossil fuel to produce 1 kCal of food. The upper end of the range assumes a diet of highly processed food and meat being transported long distances. The lower end of the range assumes a more vegetarian-centric diet and locally produced food.

Therefore,  a 1 mile walk requires 700 – 1,000 kCal of fossil fuel energy.

Driving a 30 mile per gallon car for one mile at 60 mph takes 1 minute and 1/30th of a gallon of gas. One gallon of gasoline contains approximately 30,000 kCal of fossil fuel energy.

Therefore, a 1 mile drive requires approximately 1,000 kCal of fossil fuel energy.

Depending on where you source your food and what you eat, it doesn’t make much difference in terms of carbon emissions. Driving a car one mile is far cheaper than walking a mile. But the health benefits of walking a mile far outweigh the cost.