Skip to content
accelerando

Monthly Archives: May 2009

Turn ruby heredocs from double-quoted into sinqle-quoted strings

17-May-09

By default, Rubys heredocs are interpreted as double-quoted strings, that is #{something} is evaluated, \r turns into newline and so forth.

You can change this behaviour by single quoting the heredoc identifier like so:

s = <<-'SINGLE_QUOTED'
#{i'm not interpreted}
SINGLE_QUOTED

Batchconvert ascii to utf8

12-May-09

Next time i see umlauts in source, I’ll scream. Loud.

In the mean time I try this:

find . -iname "*.java" -exec sh -c 'iconv -f cp1252 -t utf-8 {} > {}.utf8' \;
for i in `(find . -name "*.utf8")`; do mv $i ${i/.utf8/}; done

Before you try this, make a backup of your files. It worked for me but i don’t guaranty that your files won’t vanish.

Understanding

08-May-09

I’d love to understand what makes people create abominations such as this:

if((foo ? !bar : true))
    if(!somethingelse)
        dosomething()

I don’t want to judge anyone, the thing actually worked, but i really want to understand why people don’t see that this is crap. I’m really aware of the fact, that things tends to organically grow, but how can it be achieved to raise awareness to this fact? I mean, i’m probably only a not-totally-bad engineer, but i see things that will break or are just ugly as hell and i want my colleagues to be more aware of pitfalls.

Would make life much easier and probably more conflict free.

Close
E-mail It