Batch file for adding Rails files to Subversion

Posted by Runar Svendsen on October 22, 2009

How do you make sure your Rails files are added to Subversion before you commit? I have a simple batch file (for Windows currently) which I use, thought I’d post it here if anyone finds it helpful. What’s probably gonna happen though, is that someone points me to a better solution, which would be even nicer :-)

Anyway, here’s the file, so download and place it in your RAILS_ROOT folder:
Add to SVN Batch file

Installing webrat on Ubuntu 8.04 7

Posted by Runar Svendsen on June 16, 2009

I was installing webrat on my Ubuntu 8.04 Hardy Heron box and it gave me this error message:

libxslt is missing. try ‘port install libxslt’ or ‘yum install libxslt-devel’

Well, it turns out there is no libxslt-devel on Ubuntu, instead you have to do

sudo apt-get install libxslt1-dev libxml2-dev

and then install webrat (via sudo gem install webrat or add the gem in your environment.rb file).

Wordpress: .htaccess file won’t work with Apache 2

Posted by Runar Svendsen on April 07, 2009

I recently installed Wordpress on an Ubuntu 8.10 image and permalinks wouldn’t work properly. I would only get a 404 File Not Found error when I enabled the pretty URL permalink structure. The Permalink function in Wordpress relies on a small URL rewrite statement that Wordpress puts in the .htaccess file at the root folder of your WP installation:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# END WordPress

Turns out there is a setting in Apache that disables the .htaccess files by default. So you have to enable this to allow the .htaccess files to be processed. The setting is called AllowOverride, and you must set this to All (it probably is set to None right now).

Change your Apache virtual host config file to something like this:

<VirtualHost *:80>
        ServerAdmin webmaster@server.com

        DocumentRoot /var/www/

        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
....

A better clearfix (or: Clearing floats like there is a tomorrow)

Posted by Runar Svendsen on January 06, 2009

I can’t believe its not clearfix (sic) because this fixes clears! The tip is from 2005, I have no idea how everybody missed this, but anyway here it is:
Simple Clearing of Floats

CSS min-height tricks

Posted by Runar Svendsen on January 06, 2009

Here is my favorite CSS min-height solution:

Dustin Diaz min-height solution

How to get smooth fonts like Safari on Ubuntu

Posted by Runar Svendsen on January 03, 2009

My main claim against using Ubuntu is that the font rendering is just ugly and uninspiring. I am no graphic designer, but I love seeing my XHTML rendered in Safari on OS X. Turns out there is a solution that makes Firefox on Ubuntu almost as good as Safari/OS X, and it’s quick, easy and free!

If you want the whole explanation, go to this article, but if you just want the fix, all you have to do is this:

Download this file and store it in your home folder (ex: /home/yourname) with the file name .fonts.config (remember the leading dot). Restart X (press CTRL+ALT+BACKSPACE or log out and in again), and your fonts should be smooth as a you-know-who’s you-know-what.

Below are a few selected web sites captured before (left) and after (right) the font smoothing was enabled.

Wordpress.com before and after

Alistapart.com before and after smoothing

How to convert an image to grayscale using ImageMagick 2

Posted by Runar Svendsen on October 07, 2008

This is something I do just too rarely to remember the syntax, so I decided to write it down. Here it is:

To convert an image from color to grayscale (and save the result to a different file), type the following curse:

convert image1.jpg -colorspace Gray image1_grayscale.jpg

If you just want to overwrite the original image, use this command instead (thanks CableCat for the tip):

mogrify -modulate 100,0,50 image1.jpg

Installing ImageMagick / RMagick on Ubuntu Hardy Heron 6

Posted by Runar Svendsen on May 02, 2008

This is a short description of how I installed the ImageMagick framework and its Ruby wrapper (RMagick) on an Ubunty 8.04 (Hardy Heron) OS. This tutorial requires that ruby and gems are installed. See www.rubyonrails.com for more info.

Step 0: run sudo apt-get update (thanks for reminding me, HD)

  1. run
    sudo apt-get install imagemagick
  2. Then, install the imagemagick9 dev library:
    sudo apt-get install libmagick9-dev
  3. Last, install the RMagick gem:
    sudo gem install rmagick
  4. That’s it! Now peruse the RMagick documentation and start processing images!