The Passionate Craftsman

Ruby, PHP, MySql, Software engineering and more.

Tuesday, 24 August 2010

VNC viewer on Snow Leopard

If you need to connect to a VNC server with your Mac, you do not need to download and install a VNC client. Snow Leopard has and application in '/System/Library/CoreServices/Screen Sharing'. Just click 'Screen Sharing' and you will be prompted to enter an IP or host name of the server. It works much better than Chicken of the VNC. Screen Sharing is also compatible with Apple Remote Desktop (ARD) v2.1 or later.

Mac OS X 10.5 has this application too (Snow Leopard is 10.6).


Mac OS X 10.6 Help - About screen sharing


Friday, 13 August 2010

When ActiveRecord does not find a record

In Rails, when ActiveRecord does not find a record with the specified ID raises and exception. A good way to control this exception is to intercept it and respond with an appropriate HTTP status code, in this case a 404. This is a simple example:

Labels: ,

Wednesday, 11 August 2010

Execute Rails migrations on producion server with Capistrano

If you cannot access, from your development computer, the production database (because of corporate policies and/or security settings), you can add a command to Capistrano when you deploy your application.

After copying the files and coping database.yml, you can run easily a migration on the production server in this way:

run "cd /rails_dir/#{application}/current/ && rake db:migrate RAILS_ENV=production"

That command goes into the root of your Rails application and execute the migration specifying production as environment.

After that command you can change the symlink and switch to the newly deployed application.

Labels: ,

Friday, 6 August 2010

Installing Erlang on Mac OS X

mkdir erlang
cd erlang/
tar xz otp_src_R14A.tar.gz
cd otp_src_R14A
./configure --enable-hipe --enable-smp-support --enable-threads
sudo make install
cd ../..
rm -rf erlang

Start the Erlang console:


If you do not have wget, you can install it with Darwin Ports:

sudo port install wget


Monday, 2 August 2010

Kitty - a funny gem

I found a new screencast on Rubypulse about a gem named kitty. If you install the gem, then you will have a kitty command that will print a random ASCII-art cat. For instance:

Labels: ,