Debian Lenny – Installing MySQL

sudo aptitude install mysql-server mysql-client libmysqlclient15-dev

sudo gem install mysql

mysql -u root -p
INSERT INTO mysql.user (User,Host,Password) VALUES(‘my_user’,’localhost’,PASSWORD(‘mypassword’));
GRANT ALL PRIVILEGES ON my_table.* to my_user@localhost;
SHOW GRANTS FOR ‘my_user’@’localhost’;

Install ruby 1.8.7 on debian lenny

sudo aptitude update

sudo aptitude install build-essential

sudo aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby
sudo aptitude install libssl-dev libreadline5-dev zlib1g-dev

sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb
tar xzvf ruby-1.8.7-p249.tar.gz
cd ruby-1.8.7-p249
sudo make install

Gem/Rails CRC Error:

cd ruby-1.8.7-p249/ext
cd openssl
ruby extconf.rb
sudo make install
cd ../
cd zlib
ruby extconf.rb
sudo make install


tar xzvf rubygems-1.5.2.tgz
cd rubygems-1.5.2
sudo ruby setup.rb

Connecting a Rails app on Windows to SQL Server

(1) For this to work properly, first you need to install the DevKit.
Just download the executable from RubyInstaller and run it. For rails 2 choose 3.4.5 version.

If it’s installed on C:DevKit, for example, then follow the next steps:
cd C:DevKit
ruby dk.rb init
ruby dk.rb install
gem install rdiscount --platform=ruby

(2) Install the ruby-odbc gem for accessing ODBC data sources:

c:>gem install ruby-odbc

(3) Install the activerecord-sqlserver-adapter gem. Be sure to install the same version of your Rails framework. You have more info about it here.

c:>gem install activerecord-sqlserver-adapter --version=2.3.11

(4) Create an ODBC data source. If you’re running a 64 bit Windows System, don’t use the ODBC Administrator Tool from the Control Panel because a 64 bit ODBC data source won’t work. Instead, open the 32 bit ODBC Administrator Tool this way:

c:>cd C:WindowsSysWoW64

Select a default database on your DSN. Select English as the default language, although you’re not using English (I had problems with date formats using Spanish).

(5) Edit the config/database.yml configuration file:

adapter: sqlserver
mode: ODBC
dsn: your-odbc-data-source-name
host: your-sql-server-host
username: an-sql-username
password: the-username-password

If you have any problems with Decimal numbers just change the decimal type to float on your migration files, and recreate your database.


Zlib buffer error on gem install

if gem update –system not works and rename ruby/bin/zlib1.dll to zlib.dll not helps try:

Open file RUBY_DIRlibrubysite_ruby1.8rubygems.rb

And replace existed def self.gunzip(data) by this:

def self.gunzip(data)
require ‘stringio’
require ‘zlib’
data = data

# # skip the gzip header
zis =
is =

Deploying a Subversion branch with Capistrano

Capistrano is a tool for automating tasks via SSH on remote servers. It has many uses, I (and many others) use it to deploy their (rails) applications. The best I can tell there is no built in way to deploy a branch from your source code control system. There are a couple ways of accomplishing this. I chose passing in the branch as a parameter to the Capistrano command:

cap --set-before branch=testbranch  deploy

…where ‘testbranch’ is the name of my subversion branch, and ‘deploy’ is the action to take. The ‘–set-before option’ sets a variable before the recipes are loaded (sort of). All you need to do to make this work you just need to set the repository URL correctly based on if the branch variable exists or not. In my case, that is editing the top of deploy.rb in the config section of my rails app:

if variables.include?(:branch)
  set :repository,  "{branch}"
  set :repository,  ""

.htaccess password protection

The following tutorial gives you step by step instruction on how to password protect your website directory with .htaccess.

There are three simple files involved: .htaccess, .htgroup and .htpasswd all you have to do is make them and ftp them up to your webserver. You put the .htaccess in the directory that you want to protect the other two files go in a directory not visible to anyone but you, get the path right or nothing will work. If your ftp login is elvis the path of your directory looks like this: /home/elvis/www/index.html. Make sure you use an ordinary text editor like windows notepad or simple text for the Mac.

Step 1: MAKE A .htaccess FILE

It should look like this. The first two lines tell where .htpasswd and .htgroup are located and the third line is the title that will be in the password box that pops up to prompt users for their login, user-list is just the name of the group that has access its just a generic term.

AuthUserFile /home/elvis/.htpasswd
AuthGroupFile /home/elvis/.htgroup
AuthName Graceland_Visitors
AuthType Basic

require group user-list

Save this file, call it .htaccess and then ftp it up to the directory that you want to protect.

Step 2: MAKE A .htgroup FILE

This file tells who is in the group “user-list” the syntax is simple user-list: with a space between each of the user’s names.

user-list: john joe dick harry jane spot ryan manos

Save this file, call it .htgroup and ftp it up to the /home/elvis directory.

Step 3: MAKE A .htpasswd FILE

All of the passwords are encrypted so you have to use a program called htpasswd to generate them. There are two ways to do this, one if you have a shell and know how to use it your can telnet to, login and do the deed from your shell account by typing: htpasswd -c .htpasswd username to create the file and add “username” as the first user. The program will prompt you for a password, then verify by asking again. You will not see the password when entering it here but it will appear in this syntax in the .htpasswd file and your will not have to use the -c flag when writing subsequent passwords since that creates the file .htpasswd, you can now ftp it up to the /home/elvis directory.

If all this was gibberish to you proceed directly to STEP 4.

manos:jEYnEJ3lX3j0Y elvis:MpU4S/Lvr8KlE


Do it the easy way using the Inch Password Generator. Go to the password generator page and use it to make as many passwords as you need then cut and paste them into a text file. GO NOW

After you’ve finished cutting and pasting your file should look something like the file you see above. Now ftp it up to the /home/elvis directory where your .htgroup file is located. Now you can give it a try. Go to the URL of the directory and this window should pop up:

Now if everything was done correctly then you should be immediately authenticated and allowed to enter the site. If it refuses you, you probably made a mistake, most likely in the path to the .htpasswd and .htgroup file in your .htaccess file.

If you want to remove a user then simply use the text editor you assembled your .htpasswd file with to remove that user and his password.-

How to install RMagick + ImageMagick

Installation on Windows


A. This version of RMagick was created to run with ImageMagick 6.3.0 but ImageMagick 6.3.5 is installed on this system. You should either
1) Configure and build RMagick for ImageMagick 6.3.5, or
2) download ImageMagick 6.3.0 from and install it.
B. Errors about missing CORE_.. .dll file(s).
C. Errors about missing sqlite3.dll.

Issue A. stems from the fact that you have a incompatible version of ImageMagick installed which does not work with RMagick. The solution would be to uninstall any existing ImageMagick and/or RMagick gem, and start all over as described below.

Issue B. tells me that either ImageMagick or RMagick is not installed properly.

Issue C. is a bit off and has nothing to do with ImageMagick or RMagick. It is probably being thrown by the plugin or application that you are using that needs ImageMagick or RMagick. To fix this issue, just install Sqlite3.

Now that we have tackled the issues, let’s get to the goal – how to install RMagick + ImageMagick on Windows.

  1. Uninstall any Image Magick or RMagick gem from before.
  2. Download rmagick-win32 for windows that has the gem and the ImageMagick installer from
  3. Unzip the rmagick-win32 zip file that you downloaded above.
  4. Install the ImageMagick from the installer that came in the zip i.e. run the ImageMagick-6.5.6-8-Q8-windows-dll.exe. This will install ImageMagick for you.
  5. Now, we need to install the rmagic gem that came in the zip i.e. rmagick-2.12.0-x86-mswin32.gem. To do that, run the following command on a windows command line:
    gem install <unzipped rmagick path>rmagick-2.12.0-x86-mswin32.gem

    Note: When you read this post, the version nos. of the gem and the zip file may change. Please adjust your commands for that.

  6. If you get Issue C., from above you probably are left with installing Sqlite3. If you need help you can look up my post.
  7. Restart command line or IDE.

That should get you going on Windows machines. Yet another big Ruby on Rails development hurdle on Windows, solved for good.

Installation instructions for Ubuntu

1. Undo any old leftover install baggage

sudo apt-get remove --purge librmagick-ruby-doc librmagick-ruby1.8

2. Install the appropriate version

sudo apt-get install libmagick9-dev ruby1.8-dev

3. Install the rmagick gem

gem install rmagick

That should get you going on Ubuntu machines.

Installation instructions for MacOSx

If you want to use Homebrew, then do the following:

1. Install ImageMagick via a homebrew

brew install imagemagick

3. Install the rmagick gem

gem install rmagick

If you want to use macports, you can see the instructions at the RMagick site.