Give table columns equal width using CSS

If you want to distribute a <table>’s width equally over its columns, you can use the following CSS property:

table-layout: fixed

It is supported by every browser ever.

/proc/cpuinfo on Solaris

When used to do:

$> cat /proc/cpuinfo 
processor : 0 
vendor_id : GenuineIntel 
cpu family : 15 
model : 4 
model name : Intel(R) Xeon(TM) CPU 3.00GHz 
stepping : 1 
cpu MHz : 2992.785 

Instead, on Solaris, use psrinfo(1M)

$> psrinfo -v 
Status of virtual processor 0 as of: 09/17/2006 21:45:32 
on-line since 08/24/2006 16:16:03. 
The i386 processor operates at 1800 MHz, 
and has an i387 compatible floating point processor. 
Status of virtual processor 1 as of: 09/17/2006 21...

Show the character set and the collation of your MySQL tables

To show the collation of your tables you have to login to the MySQL console and execute SHOW TABLE STATUS FROM database;

| Name        | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_leng...

Stub a request's IP address in a Cucumber scenario

The solution in this card is based on a stack overflow post by Leventix.

If you need to make request come from a fixed IP address for the duration of a Cucumber scenario, the code below lets you write this:

Given my IP address is

Rails 3

Given /^my IP address is "(.*?)"$/ do |ip|

Rails 2 —–…

Using :dependent => :destroy – Issues with 'code arrangement' or 'cached objects'

First keep in mind that :dependent => :destroy hooks into before_destroy.
So when you use other before_destroy callbacks the sequential arrangement of your code may be important.

For example:

class Container < ActiveRecord::Base
  before_destroy :a_callback
  has_many :items, :dependent => :destroy

results in

# => a_callback
# => container.items.destroy_all


class Container < ActiveRecord::Base
  has_many :items, :dependent => :destroy

How to install a debian/ubuntu package without dependencies

Please note that you can break your system with this! This is not recommended.

Sometimes the package repository has errors. If you can’t install a package because you can’t install the dependencies with the package manager you can try this:

(You have to download the deb first e.g. from here or here)

dpkg -x bad-package.deb common
dpkg --control bad-package.deb

Then you have to edit DEBIAN/control with an editor. You can delete the broken dependencies t…

Micro clearfix mixin for Sass

Clearfix is a hack to clear floating elements without additional HTML markup.

Over the years many different clearfix methods have appeared. Currently Nicolas Gallagher’s Micro Clearfix Hack seems to be in vogue. It is known to work in Firefox 3.5+, Safari 4+, Chrome, Opera 9+, IE 6+.

This card describes a micro clearfix mixin for Sass. It let’s you say this:


Stub methods on any instance of a class in Rspec 1 and Rspec 2

RSpec 1 (Rails 2)

With the most recent spec_candy.rb helpers you can say:

User.stub_any_instance(:foo => :bar)
user =
# => :bar

RSpec 2 (Rails 3)

RSpec 2 comes with this feature built in:

User.any_instance.stub(:foo => :bar)
user =
# => :bar

Show and change MySQL default character set

To show the MySQL default character set you have to login to the MySQL console and execute SHOW VARIABLES LIKE 'char%';

mysql> SHOW VARIABLES LIKE  'char%';
| Variable_name            | Value                      |
| character_set_client     | latin1                     |
| character_set_connection | latin1                     |
| character_set_database   | latin1                     |
| chara...
External content

Ruby 2.0 Implementation Work Begins: What is Ruby 2.0 and What’s New?

While 2.0 will include a number of syntax changes, new features and general improvements, mentioned below, it is anticipated to remain backward compatible with code written for 1.9.3 and Matz has stated that the changes are less significant than those made in the 1.8 to 1.9 jump.

Fix multiple CKEditor instances using jQuery adapter - fixed since 4.2

Using the jQuery adapter breaks the built-in save function of CKEditor.

Phenomenon: The page is submitted correctly, but the original values of the form fields were posted instead of what was typed in the editors.

Work around: Basicly instead of initiating the editor using the above example I ended up using the following:

$( 'textarea.editor').each( function() {

    CKEDITOR.replace( $(this).attr('id') );


Note: This assumes that each field using the editor has its own unique ID.

Paste X selections into your terminal with your keyboard

The buffer where text is put into when you double-click on text within X is called X selection.

You can paste this buffer (at least into a terminal window) by pressing Shift + Insert.

Cucumber.yml was found, but could not be parsed.

If you encounter the error message above when running cucumber, just execute…
rm rerun.txt …in the Rails directory.

Or run…
tests …from the geordi gem. This will do the work for you automatically.

Solve screen error "Cannot open your terminal '/dev/pts/0' - please check"

When using the screen tool you may be unable to start a screen session but instead encounter an error:

Cannot open your terminal '/dev/pts/0' - please check.

This is because another user (you) initiated the current terminal – you probably did a sudo su into the user you are now trying to run screen as, right?

There are two ways to resolve this:

  • Sign out and properly connect / sign in as the user you wish to use.
  • Run script /dev/null to own the shell (more info over at [Server Fault](…

Git: How to create and apply patches

You can convert git commits into patch files. Those can be used to apply to a different repository [1] or by someone else (e.g. sent when sent to them via e-mail).

Creating a patch

  1. Make your changes and commit them.
  2. Run git format-patch COMMIT_REFERENCE to convert all commits since the referenced commit (not including it) into patch files.

For example, let’s say you prepared 2 commits. Run:

git format-patch HEAD~~ 

This will create 2 files, one for each commit since HEAD~~, like these:


Run multiple local webricks at the same time using different ports

If you specify different ports, you can run multiple local webricks with rails server --port=300X at the same time.

Parse & sort unique hits in logfiles

If you want to know the exact hits on your website (or whatever logfile you want) for a specific date without duplicates, here’s how. “Unique” means you don’t want to count hits to an URL originating from the same IP twice.

You can use the attached script to do so:

# ./log_parser.rb 2011-10-04

27 hits on /rss.xml
36 hits on /stylesheets/fonts/slkscr-webfont.woff
37 hits on /stylesheets/fonts/slkscrb-webfont.woff
37 hits on /images/bullet.png
38 hits on /images/download.png
38 hits on /images/play.png
2727 cards