Singing your source

…and while I’m at it. The following piece of code, which Sam Aron presented at the goto; conference (I don’t know where he got it from) is also the lyrics of a christmas song.

better watchout
better !cry !pout
lpr why
santa claus <north pole > town
cat /etc/passwd > list
ncheck list
ncheck list
cat list | grep naughty > nogiftlist
cat list | grep nice > giftlist
santa claus <north pole > town
who | grep sleeping
who | grep awake
who | egrep ‘bad|good’
for (goodness sake) {be good}

Friday puzzle

My good friend Frank just sent me this email (I did translate to English though). I had never seen the algorithm before, so it gave me a good laugh. Now I need to share it. It’s written in Groovy:

If you just need to get some blood through the neural cells after the pork roast, try to figure out the code below.

Hint: a classic sort algorithm, but which one?


import java.util.concurrent.*

def list = new CopyOnWriteArrayList()

def task = { n ->
t = {
} // job in a closure
t as Callable // return block as a callable }

def workers = []

[5, 3, 7, 2, 1, 1, 3, 4].each { n ->

def executor = Executors.newFixedThreadPool(workers.size());
def futures = executor.invokeAll(workers, 10, TimeUnit.SECONDS);

println list # the sorted list

So, what is it? Eh’? Eh’? :o)