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

Ruby and Random

Wrongly used randomness can be the source of hard-to-detect bugs and security holes. This is relevant every time you use randomness, for example, when implementing an existing protocol/interface that requires random values or generating tokens for your next raffle. This article describes when to use which of Ruby’s randomness methods.

…read

Things I learned while implementing version 1.0 of pws

After releasing version 0.9 of my cli password manager, I received friendly feedback and suggestions, which encouraged me to further improve it. Here are some of my experiences implementing pws 1.0:

…read

pws: The ruby-powered command-line password manager

  • stores your passwords in a file on your disk
  • encrypts the file with a master password
  • is designed for every-day-use
  • is written in 234 lines of understandable Ruby code… Read it!
  • is tested with 222 Cucumber steps

Why you should switch to 1.9: Three Ruby 1.8 bugs

Ruby 1.8 dies in June 2012. This post shows some small examples, why this is good ;)

…read

Pass multiple blocks to methods using named procs

My codebrawl entry (gist) got the 5th place (out of 20). Want to use it in real life :)

…read

Project Euler 19, 20, 21, 22, 23, 24, 25 (Ruby)

The next pack of Project Euler solutions.

…read

Do you know the official Ruby interpreter "goruby"?

##              ##    ##     ##    ##    ##    ####           ###        ##    ##
 ##            ##     ##     ##     ##  ##     ##  ##        ## ##        ##  ##
  ##    ##    ##      #########      ####      ##   ##     #########       ####
   ##  ####  ##       ##     ##       ##       ##  ##      ##     ##        ##
    ####  ####        ##     ##       ##       ####       ##       ##       ##

…read

New features of Ruby Zucker version 2 and 3

The Zucker gem has gotten some new features. Installation is as easy as
 gem install zucker
and
 require 'zucker/all'

…read

Introducing Ruby Zucker - a new syntactical sugar gem

Zucker is a collection of lightweight scripts (cubes) that make Ruby even more beautiful: rubyzucker.info

…read

Project Euler 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 (Ruby)

More solutions for the projecteuler.net problems. Some of them are solved using 1.9.2 features.

…read

New Array and Enumerable methods in Ruby 1.9.2: keep_if, chunk...

In Ruby, dealing with Arrays and similar objects is pretty fun. And we have gotten more possibilities with Ruby 1.9.2 :)

…read

RubyBuntu -2- Troubleshooting common Ruby ubuntu problems

A common Ruby experience on ubuntu: You get some stupid error, saying something would be missing – and you don’t know what to do…

…read

RubyBuntu -1- Installing Ruby (and Rails) on ubuntu

Installing Ruby/Rails on ubuntu is not hard, but some little obstacles might be confusing.

…read

Project Euler 1-5 (Ruby)

projecteuler.net tries to get you thinking about how to solve mathematical problems by programming. Here are the first five problems, solved in Ruby, including comments.

…read

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.

…read

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).

…read

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]

…read

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.

…read