Archives for the month of: May, 2007

The excellent scientific climate blog RealClimate has put up a small guide for beginners, with tons of links to good resources for those wanting to know a bit more. So the next time someone tells you “There ain’t no global warming, it’s just the sun heating up a bit more!” at a dinner, you’ll have some understanding of the problem and arguments to fight back.

Spread the word and do your homework.

If you’re doing some file system manipulations in Ruby, moving and creating files around (which it does very well as it doesn’t try to ignore, like Java, that there is a file system) you have basically two choices: hard code a lot of ‘/’ characters in your code, which isn’t pretty, or use File.join. After a while you end up with many of these joins all over the place and it’s not so pretty (there’s actually a third possibility, you can directly use File::SEPARATOR, but it’s so ugly that I’m not counting it).

Yesterday, I had this really simple idea:


class String
def /(str_to_join)
File.join(self, str_to_join)
end
end

It’s so sweet and easy that I can’t even figure why I’ve never thought of it before. Now I can do:


'tmp'/'readme.txt' # literals
ROOT_DIR/file_path # variables holding strings

Much easier on the eyes and the fingers.

Seen on the ruby-talk mailing list, in answer to a guy who is asking how Ruby can be 100% object oriented when primitives like ‘if’ and ‘then’ are not objects:

> Seriously, what kind of object would an If object be? What is the
> essence of If-ness? I think if anybody could answer that question they
> would instantly achieve enlightment and then their head would explode.

That, my friends, is exactly how LISP programmers are created.

Which reminds me of this xkcd comic.

End of the Lisp bashing.

Follow

Get every new post delivered to your Inbox.