Tag Archives: mac osx

Speeding up firefox startup on Mac OS X

I’ve been a long time user of firefox and find that over time, starting firefox up takes a lot longer. Firefox uses sqlite as a database to store things like the list of places you’ve visited. Over time, these database files become fragmented, and need cleaning up. Here’s how to do it on mac OS X.

You should close Firefox, and then open up Terminal.app and type the following commands:

First, check the current size of your database files:

find ~/Library/Application\ Support/Firefox/Profiles -type f -name '*.sqlite' -exec ls -arlth {} \;

Next, vacuum and then re-index your database files. This may take some time – so don’t worry and leave it to finish.

find ~/Library/Application\ Support/Firefox/Profiles -type f -name '*.sqlite' -exec sqlite3 {} VACUUM \;
find ~/Library/Application\ Support/Firefox/Profiles -type f -name '*.sqlite' -exec sqlite3 {} REINDEX \;

Now check the sizes again:

find ~/Library/Application\ Support/Firefox/Profiles -type f -name '*.sqlite' -exec ls -arlth {} \;

You should see an instant speed increase.

Installing RVM on Mac OS X

RVM is the Ruby Version Manager.  It allows you to install multiple versions of Ruby, and within each of those versions, multiple sets of gems (gemsets).  So, for each project you’re working on you can have exactly the same version on all environments.   This is an excellent idea.

The documentation, whilst excellent, lacks howtos for different operating systems.  I installed it on both Mac OS X and on an Ubuntu server (see this post for details on how Ubuntu works).  Mac OS X 10.6 instructions are below.

Installing RVM

Open Terminal.  Then, as your user (NOT root) run the following:

cd
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
vim .~/.profile

add the following right at the end to load RVM:

[[ -s “$HOME/.rvm/scripts/rvm” ]] && . “$HOME/.rvm/scripts/rvm” # This loads RVM into a shell session

Reload your profile (by typing . .profile) and type:

type rvm | head -n1

You should see:

rvm is a function

If you do not, it means that RVM has not loaded properly.  You’ll need to go into the installation process in more depth – a good place to start is the “Troubleshooting your install” section of this page.

RVM’s now installed. The next step is to set up the particular version of Ruby and gems that you want to use for a project.

Installing Selenium 2 as a service on Mac OS X

This post covers how to install selenium standalone as a service on Mac OS X.  Version 10.6 in this case, but should work on 10.x

First, browse to http://code.google.com/p/selenium/downloads/list and copy the url of the selenium-server-standlone-2.*.jar file.

Next, open Terminal.app and type the following:

sudo mkdir /usr/lib/selenium/
sudo wget url-you-copied-above /usr/lib/selenium/
sudo mkdir -p /var/log/selenium/
sudo chmod a+w /var/log/selenium/

Next, save this file as ~/Library/LaunchAgents/org.nhabit.Selenium.plist.  Edit the file in your favourite editor, and change the filename on line 13 (currently selenium-server-standalone-2.0a5.jar) to that of the server file you downloaded above.

Now go back to Terminal and type:

launchctl load ~/Library/LaunchAgents/org.nhabit.Selenium.plist
launchctl start org.nhabit.Selenium

The Selenium server should now be started and running on port 4443.  You can check everything’s fine by typing:

ps auxwww | grep selenium

It logs to /var/log/selenium/.  You can check the error log here:

tail /var/log/selenium/selenium-error.log
Selenium server is being run as a daemon via launchd, which is controlled by launchctl.  The config file above was set up using this GUI:  http://sourceforge.net/projects/lingon/files/
Next: Installing Selenium server as a service on Ubtuntu