Monthly Archive for March, 2008

[Hint] Deploying Ruby on Rails applications on Dreamhost with Capistrano

So, you have a nifty Ruby on Rails application, got yourself a cheap Dreamhost account and you want to give Capistrano a try. And what do you get - errors.

This occurs if you have Ruby gems installed in your home directory (probably ~/.gems/). I’m assuming that you already have your environment configured. Despite that you still can get errors like no file to load -- json when executing cap deploy. That’s because you have your shell configured, but most likely non-interactive environment is left intact.

To fix this you have to modify your .bashrc file (since you probably added GEM_HOME and GEM_PATH to .bash_profile):

export GEM_HOME=$HOME/.gems 
export GEM_PATH=$GEM_HOME:/usr/lib/ruby/gems/1.8

And you’re probably done.

You can also check these articles, they’ve been very helpful:
Deploying Rails (2.0) to Mongrel with Capistrano 2.1
Using Capistrano with Rails
Ruby on Rails - Dreamhost

[Hint] Detecting Firefox 3 in extensions

For a couple of months I’ve been developing a Firefox extension called BlipFox - an interface to Blip, Polish way-better-than-the-original-Twitter-clone. With Firefox 3 coming soon I had to get my extension ready for the final release.

Due to some chrome changes and bugs I had to update some code related to dynamic overlay rendering. Now all I need to know is whether the extensions is installed on Firefox 2 or Firefox 3, hence this snippet of code:

function isFF3()
{
	var foo = Components.classes["@mozilla.org/login-manager;1"];
	return typeof foo === 'function';
}

How do you like? Let me know if there are other methods of detecting Firefox 3 (more elegant, perhaps?).

[Hint] Using Windows keyboard in OS X Leopard

Since sometimes I’m awfully lazy - I got myself a second keyboard, just for the sake of not having to carry one to office and back. At home I use my beloved Apple Keyboard, while at work - a crappy, no-name, ten-bucks-a-piece one (it does it job, though!).

However, since at work I use a Windows keyboard I had a problem with the switched Option / Command keys. I’ve tried DoubleCommand, however I had to click through the System Preferences each time I switched my keyboard. Couple of minutes of googling and a nice script popped out. However, it was useless in OS X Leopard, so I made a couple of quick changes and here’s something I came up with. First, switch-to-windows-keyboard script:

tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
	get properties
	tell process "System Preferences"
		click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
		click pop up button 2 of sheet 1 of window "Keyboard & Mouse"
		delay 0.3
		click menu item 4 of menu 1 of pop up button 2 of sheet 1 of window "Keyboard & Mouse"
		delay 0.3
		click pop up button 1 of sheet 1 of window "Keyboard & Mouse"
		delay 0.3
		click menu item 3 of menu 1 of pop up button 1 of sheet 1 of window "Keyboard & Mouse"
		delay 0.3
		click button "OK" of sheet 1 of window "Keyboard & Mouse"
	end tell
end tell
tell application "System Preferences"
	quit
end tell

Second, back-to-apple-keyboard script:

tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
	get properties
	tell process "System Preferences"
		click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
		click button "Restore Defaults" of sheet 1 of window "Keyboard & Mouse"
		click button "OK" of sheet 1 of window "Keyboard & Mouse"
	end tell
end tell
tell application "System Preferences"
	quit
end tell

You might ask why not use Ryan Block’s script? Well, since I rely heavily on QuickSilver I also created two Platypus applications - one for each script. I’m a keyboard user, so I didn’t like the clicking on the Macintosh / PC screen. ;-]

[Release] Fluid’s Google Reader Fix

For quite a few weeks I’ve been using Fluid with Google Reader - having a standalone WebKit based application with dock notification works great for me. However, one thing has been bothering me - Fluid never clears the dock badge when all the items are read. I’ve just posted a little fix for this issue - grab it at http://userscripts.org/scripts/show/23422.

Let me know if this works for you!