Caius Theory

Now with even more cowbell…

Keyboards

Back in the day I swapped the keys on my 12" powerbook keyboard around to read macgenius across the middle row.

Powerbook Keyboard

I unearthed the picture, and figured, why not do it to my apple aluminium keyboard? So I found a tutorial from some other guy that'd done it, and dug out my penknife.

External Keyboard

After that I decided to rearrange the macbook internal keyboard as well. First I googled around to make sure lifting the keys was the same as doing it on the external keyboard (which it appeared to be), then I went ahead and rearranged them as well.

Internal Keyboard -- Macgenius

So whilst I was wondering what to do about it, my mother emailed me and suggested using ontherails instead of macgenius. So I did, and now the top row reads ontherails on the macbooks' internal keyboard.

Internal Keyboard -- Ontherails

All pictures are licenced under Creative Commons Attribution 2.0 Generic licence and the above pictures, plus some in progress shots, are available in my Keyboard Modifications flickr set.

Why do I love Ruby?

So mother (who can't program) just posed me the question

Why is Ruby your favourite programming language?

Me being a show off jumped straight into TextMate and banged out some code in real time to show her. First up, a quick little one-liner of Ruby code to output a String:

puts "Hello World"
# => "Hello World"

So she goes, "Sure, but whats so brilliant about that?" So I just decide to reverse the string, have it output in reverse order:

puts "Hello World".reverse
# => "dlroW olleH"

Then the next question comes, "So what makes that so much easier than in other languages?" Well now I was thinking on the spot about which other language I can bang out a quick example in without having to look up too much information. PHP seems the logical choice, being the language I know best behind Ruby.

Thinking about how to do it in PHP, I can't think of a function to reverse the content of a string, but I know that array_reverse() exists, so I just split it into an array and reverse that array. Only problem is I can't remember how to split a string by "", I don't think explode( "", $var ) does the job. So I quickly jump in and write the following code to test my concern.

<?php
  $a = "Hello World"
  $b = explode( "", $a );
  $c = array_reverse( $b );
  echo implode( "", $c );
?>
# => ERROR

The reason for the error is because I've missed a semi colon off the end of line 2, to this I get the response, "well thats certainly not as nice as ruby." Just because one little character is missing!

So I fix the semi colon and run it again, now I get an error complaining about explode not being able to split by a missing delimiter (the empty string - "") So I go hunting through the php.net docs and find str_split(), which does exactly what I want it to.

In replacing explode() with str_split() and running it via the php command line binary, I realise that I haven't got any \n (newlines) at the end of it, so it doesn't display nicely in the terminal. I thus update the script to the following and show her the result:

<?php
  $a = "Hello World";
  $b = explode( "", $a );
  $c = array_reverse( $b );
  echo implode( "", $c )."\n";
?>
# => "dlroW olleH"

And so she goes away seeing why I prefer Ruby to other languages for most programming I do. There are things Ruby fails at (and don't get me started on why rails isn't going to replace php!) and other places where it succeeds very well.

But each to their own, and my own favourite is Ruby!

Update

As pointed out in the comments, if I had looked a bit further I would've found strrev() which does the same as the reverse method in Ruby. So in fact the final code would be:

puts "Hello World".reverse

vs

<?php
  echo strrev( "Hello World" );
?>

So it turns out this was a bad way to show why I prefer Ruby to PHP code wise to mother, think I might have to just bite the bullet and write about why I prefer object.method to method( object )!