All entries

Moving to a different domain

Read more...

Written on Mon Oct 25 12:38:47 2010.
Tagged as blog.



Inject the Hash before you tap it

There is a Ruby best practices blog that is exploring the uses of Object#tap, particularly with respect to building hashes, as per the example they give:

Read more...

Written on Wed Aug 5 19:57:39 2009.
Tagged as ruby.



RSpec should each matcher

should each for easy testing of collections

Read more...

Written on Wed Nov 5 20:31:20 2008.
Tagged as rspec, ruby, test.



Ruby blocks in Perl

The power of Ruby blocks is hidden in Perl. Create ruby rescue blocks in Perl

Read more...

Written on Sun Oct 19 21:00:00 2008.
Tagged as perl, ruby.



(Principles of a) Best Man Speech

A little while ago I gave a best man speech at a wedding. It was one of the most successful thing I have ever done. Afterwards, everyone who saw me told me it was a great speech. Even the DJ.

Read more...



Easy attribute assignment (in Rails)

Update: It seems like I reinvented Hash#slice which is already in the Rails API

Read more...

Written on Fri Mar 21 17:34:39 2008.
Tagged as rails, ruby.



Navigating nil (Method Chaining) in Ruby

Method Chaining is an important technique to create beautiful code in object oriented languages, but Ruby (the beautiful language, right?) does not support it as well as it should.

Read more...

Written on Sun Mar 16 08:17:59 2008.
Tagged as gem, ruby.



Real modules for Ruby

More specifically, Ruby doesn’t have real mixins (or interfaces or typeclasses if you like). But then what does a module mixin do? It modifies a class’s inheritance chain at runtime

Read more...

Written on Tue Mar 11 16:26:54 2008.
Tagged as gem, ruby.



(A Detailed Explanation of) Ruby’s Symbol#to_proc

Must people love a new feature in Ruby called Symbol#to_proc, but there are not many good explanations of it. The concept is actually fairly straightforward, but the Ruby implementation is fairly complex. The following is an explanation that assumes no knowledge of Ruby.

Read more...

Written on Mon Feb 25 18:04:26 2008.
Tagged as linux, ruby, script.



Even more Beautiful Code (C → Haskell)

In the book Beautiful Code some code is more beautiful than other code. But there is little doubt that the opening chapter presents a regular expression matcher in a beautifully succinct fashion. As the author Brian Kernighan states:
“I don’t know of another piece of code that does so much in so few lines while providing such a rich source of insight and further ideas.”

The example is written in C. I wondered if a more beautiful version could be created using a newer programming language. But we can maintatin the advantages of C and work at a slightly higher level by using lists. Since this code also uses recursion and pattern matching, Haskell is a very natural replacement.

Read more...

Written on Mon Feb 4 18:00:22 2008.
Tagged as C, haskell, regex.



The script I use every day

The script I use most frequently is a script for extracting files. If you work from the linux command line, it is impossible to remember which program with which flags should be used to extract a file. This is something the computer should do for you! This extraction script solves the problem, and you can configure the first lines of the script to match any filetype. I use it so often that I have it aliased to ‘e’

Read more...

Written on Fri Feb 1 00:59:26 2008.
Tagged as linux, ruby, script.



Too many choices! (in open source software)

Setting up my blog got me thinking: Do we really need so many blogging systems? To be specific, I am using an open source static blog generator. There are three different programs for this kind of blog written in the ruby programming language. Of course there are several open source dynamic ruby blogging systems. Venturing out of ruby, there are many blogging systems for all the other languages being used with web programming.

Read more...



An Efficient Blogging Setup

I never thought I would be a blogger. It seemed so narcissitic to me, but I have come across a lot of useful information or cool ideas on people’s blogs. With that in mind, this blog will have a technical orientation since I know that nobody cares that I took a trip to the zoo yesterday. To prove it, here is the technical setup of my blog.

Read more...