Downgrade Ruby version using Macports

Recently, working in a big project that has frozen an old version of Rails, I had to downgrade Ruby in order to work with it (upgrading Rails for it would be too much effort). So the fastest solution was downgrade my Ruby from 1.8.7 to 1.8.6. This guide can be used in general to install an old version of a port using MacPorts.

We need to create a local repository, e.g. in /Users/Shared/dports:
mkdir /Users/Shared/dports

Edit /opt/local/etc/macports/sources.conf and add:
file:///Users/Shared/dports

Find out the svn revision number that has your version at http://trac.macosforge.org/projects/macports/log/trunk/dports/lang/ruby/Portfile. In this case for 1.8.6-144 is 36429

Install the port in your local repository:
cd /Users/Shared/dports && svn co --revision 36429 http://svn.macports.org/repository/macports/trunk/dports/lang/ruby/ lang/ruby/

Run portindex so that port now finds the new (old) version:
portindex /Users/Shared/dports

Now you should be able to see the new (old) version.
port list | grep ruby

Deactivate the current version of Ruby (using the complete name):
sudo port deactivate ruby @1.8.7-p22_3+thread_hooks

Install the new (old) version:
sudo port install ruby @1.8.6-p114

Activate it:
sudo port activate ruby @1.8.6-p111_1+darwin_9+thread_hooks

Check that you have the version desired:
ruby -v

Now you can activate and deactivate the desired version when needed.

Comments (0)

Web design workshop

This are the slides of a workshop I did some time ago.

Comments (0)

jQuery intro

A brief presentation of jQuery I did time ago:

Comments (0)

Set up font size and font family

html {
font-size:62.5%;
}
body, textarea, input {
font-family: arial, sans-serif;
font-size: 1em;
}
body {
font-size: 1.3em /* 13px equivalent */
}

Comments (0)

Backing up and restoring MySQL databases

Back up:
mysqldump -u myuser -p mydb > dump.sql

Restore:
mysql -u myuser -p mydb < dump.sql

Comments (2)

Create new MySQL database and user

mysql -u root -p
mysql> create database dbname default character set utf8;
mysql> grant usage on *.* to dbuser@localhost identified by 'userpass';
mysql> grant all privileges on dbname.* to dbuser@localhost ;
mysql -u dbuser -p'userpass' dbname

Comments (0)

Configure folder visibility in Textmate

I like Texmate to show all the hidden folders and files, except .DS_Store and .Thumbs.db.

Open Preferences->Advanced->Folder References

Empty Folder pattern and put in File pattern: !(.DS_Store|Thumbs.db)

Comments (0)

Opening rubygems in Textmate

Create /usr/local/bin/mategem with:

Make it executable:
chmod +x /usr/local/bin/mategem

To autocomplete with tab add this to ~/.profile:

Reload:
source ~/.profile

Now to list all gems:
mategem [tab][tab]

The original tutorial.

Comments (0)

My most used Texmate shortcuts

control+shift+w: wrap text with tag
control+sift+command+w: wrap each line with tag
control+shift+l: wrap text with link to clipboard’s url
command+/: comment

control+shift+.: open erb code

command+control+t: select bundle window
command+shift+t: go to symbol window

command+shift+l: select line
control+shift+d: duplicate line
command+control+up/down: move line

command+alt+right/left: change tab

def+tab: function
cla+tab: class
tc+tab: test case
ase+tab: assert equal

Comments (0)

Grep in project for Textmate

If you are working in a bit big project and you try to Find in Project with Textmate, probably it’ll get frozen. The grep in project command is much more effective. Download it and double click on it. It replaces the Command+Shift+F default. More info.

Comments (0)