Posts

Showing posts from April, 2012

So you think you can Vim?

I love vim. After giving it my best for about a week I was getting more productive than in previous editors for writing code like javascript, python or bash. Unfortunately, I also love statistics. Have I really improved my editing speed? If yes, how much? It's difficult to tell really, because I have not kept statistics.

I've been using it full time for over half a year by now and I keep picking up new things. Today for example, I added a mapping to F2 to let python run the current file!

nnoremap <F2> :w<CR>:!python %<CR>
I am absolutely sure that this saves me quite some time when developing python. However, it makes me wonder: how much more functions are there that I am not using? I use macro's, tabs, buffers, replacing, searching, jumping, the . key. What am I still missing out on? What do the real vim masters use that I don't?

What would be great is when apps like have something like a statistics plugin that keeps track of which functions and keyst…

Google Code Jam 2012 - My solutions for the qualification round

I participated and managed to find reasonable solutions for A,B C en D-small. I code in Python, as its compactness and focus on sets, dicts and lists are great for coding challenges like these.

They read input from stdin, so a command like cat input | python program.pyprints the output to your terminal.

A - Speaking in Tongues



B - Dancing With the Googlers


C - Recycled Numbers


D - Hall of Mirrors

I'm not proud of this solution, but it got the job done. It's not elegant and it only works for the small set. (The only mirrors are the ones on the sides).

It works by tiling mirrored versions of the original map to cover.

UNIX pipes: male | female > baby

What happens when you execute the following command on a Unix system?
male | female > babyIt will start two processes (in this case male and female) pre-supposing you have them in one of your bin or sbin folders.

Unix pipes (called from shell with the "|" character) reroute the output of the process on the left to the input of the process on the right. In this case, whatever male outputs to stdout, female will receive in stdin.

What happens to the output of female?

If we would have called this line:
male | femalethe stdout of the last process (in this case female) will be displayed on your screen.

However, the ">" character allows you to capture the output of the last process to a file. In the first case, a file called baby.

Disclaimer: I realize this would make a cool line for the birth announcement, but it isn't one ;)

java.lang.Thread considered harmful

As Moore's law seems to be moving horizontally instead of vertically these days, most CPU intensive programs have split up their logic in threads so it can be run on multiple cores simultaneously. This seems appealing, but for the programmer it is not. It is no wonder that thinking in parallel operations results in more bugs, as there is only so much that a programmer can mentally keep in his head.

Consider this engineering comparison: No matter how fast you make a train, it has to stop at every station where passengers have to be picked up. This is annoying for the passengers who have no business at the current station. This is the serial way of doing things. Recently a parallel alternative was proposed that would allow trains to never stop moving. It is a simple idea that no doubt has popped into many an engineer's brain in the last 150 years: passengers start their journey on board of a small train that will match up to the speed of the “main train” and passengers will be a…