Working with Ruby
Hi, I am Jan. This is my old Ruby blog. I still post about Ruby, but I now do it on You should also install Irbtools to improve your IRB.

Search the net - and do something for the environment :)

It is not that easy to find an replacement for google – often the search results are just better then those of the competitors. Except Yahoo – I like their results, but the user interface is not as good as google’s.

But now I have found a solution that works for me:



After editing some source files with different editors on different platforms, I had some troubles with automatically inserted tabs messing it all up.

This little script replaces all tabs with two spaces.


Organise your code comments with rake notes:todo!

Lots of IDEs (e.g. Netbeans) and some editors (e.g. gedit with plugins) have a nice feature: They show comments, which start with something like TODO or FIXME. Those annotations are quickly written and they make it harder to forget some things you wanted to (or have to) do.

I have just discovered that Rails has this feature already built-in!



This is my submission for the CodeRack contest:

A middleware that removes < and > from all incoming requests.


Oh, this sweet and tasty syntactic sugar!

This article is written for people with experience in programming in general, but who are new to Ruby.
A German version is published in the offline magazine #2, a magazine by some students of TU Dresden.

The intention is to demonstrate some features of Ruby and show, what is so great about Ruby:

A clean syntax combined with the possibility to adapt the language to given requirements flexibly.


A* in Brainfuck! by Thammi

Yeah! I am one of the two winners of the programming competition I talked about at Playing with Dijkstra.

Furthermore, Thammi, a friend of mine, is the winner of the category “crazy” with a brainfuck implementation!


Ruby Brainfuck golf [Update]

Some days ago, I discovered a website – which is the most addicting one I know :) – The goal is, to solve programming problems with as short code as possible.

As I said, it is addicting. You do not write better ruby code by golfing. But you can really improve the knowledge of the language. And it is fun :)


After doing some of the other challenges I tried the brainfuck challenge.
Brainfuck is a Turing-complete esoteric programming language consisting only of 8 letters, operating on a 30000 cells-array. This is the hello world program:

>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

The goal is to build a interpreter.


Quicksort in 5 minutes

Some time ago, I conducted a short presentation about Ruby. And to impress the audience, I did some live coding and implemented the quicksort algorithm in 5 minutes. They were impressed :)


Troubleshooting an aegis-permission problem

In my current Rails project, I use the aegis gem for rights management. And I almost got mad, wondering, why it wouldn’t work..

…read is an online RDoc for Edge Rails, which is regenerated every day. It is based on sdoc with some custom css.

Update 06.06.2010: Relaunched with better stylesheets!


Playing with Dijkstra

About a year ago, some students at my university announced a little programming competition for students beginning studying IT, like me. The language could be chosen freely.

At this time, I had already done some C and PHP programming.. but I also had heard of Ruby and that Ruby is sooo cool. So I decided to learn the basics of Ruby by taking part… and it’s been the right decision! I fell in love with Ruby ;).

I publish my solution here. It is a good “try to understand what it does”-exercise for people new to Ruby or programming in general (or people doing Rails only all the time).


Create an offline version of the Ruby docs

When I began programming Ruby/Rails, I quickly found the online Ruby documentation at and the Rails API, which are both very useful. But unfortunately, one cannot be always online. In this blog post, I’ll demonstrate some ways to generate or get the docs offline and some hints on using them.


Converting decimal to binary integers: custom methods vs. to_i [Update]

At my last entry, a question arose about what is the most efficient way to convert integers between the bases 2 and 10: either using built-in ruby methods (and even do lightweight string-operations) or calculating it manually. I had to find out ;). So I have written a little benchmark program, which does the conversion in three different ways:

  1. using built-in to_i-magic
  2. calculating it by hand
  3. using sprintf

It stops the time each method needs to get the fastest. The result might be surprising. [Update: improved the custom methods]


Storing an array of indices in an integer

Sometimes you have an array of indices. These might, for example, act as flags, whether some specific options are set or not. A nice way to store this list is, to store it in one single number.