contact
----------------------------

Blog <-

Read less

A programmer once built a vast database containing all the literature, facts, figures, and data in the world. Then he built an advanced querying system that linked that knowledge together, allowing him to wander through the database at will. Satisfied and pleased, he sat down before his computer to enjoy the fruits of his labor.

After three minutes, the programmer had a headache. After three hours, the programmer felt ill. After three days, the programmer destroyed his database. When asked why, he replied: “That system put the world at my fingertips. I could go anywhere, see anything. Because I was no longer limited by external conditions, I had no excuse for not knowing everything there is to know. I could neither sleep nor eat. All I could do was wander through the database. Now I can rest.”

— Geoffrey James, Computer Parables: Enlightenment in the Information Age

I was a major content consumer on the Internet. My Google Reader had over 120 feeds in it. It produced more than a 1000 new items every couple of hours. I religiously read Hacker News, Reddit and a variety of other high-volume sources of content. I have directories full of theoretical science papers, articles on a wide range of topics and many, many tech books. I scoured the web for interesting articles to save to my tablet for later reading. I was interested in everything. Programming, Computer Science, Biology, Theoretical Particle Physics, Psychology, rage-comics, and everything else. I could get lost for hours on Wikipedia, jumping from article to article, somehow, without noticing it, ending up at articles titled "Gross–Pitaevskii equation" or "Grand Duchy of Moscow", when all I needed to know was what the abbreviation "SCPD" stood for. (Which, by the way, Wikipedia doesn't have an article for, and means "Service Control Point Definition")

I want to make it clear I wasn't suffering from Information Overload by any definition. I was learning things. I knew things about technology which I hadn't even ever used myself. I can tell you some of the ins and outs of iPhone development. I don't even own an iPhone. I can talk about Distributed Computing, Transactional Memory and why it is and isn't a good idea, without having written more than a simple producer/consumer routine. I'm even vehemently against writing to shared memory in any situation! I can tell you shit about node.js and certain NoSQL databases without even ever having installed – much less dived into – them. Hell, I don't even like Javascript!

The things is: even though I was learning about stuff, it was superficial knowledge without context and the kind of basic information that allows you to draw these conclusions you're reading about for yourself, without the help of some article. I didn't pause to think about conclusions drawn in an article, or to let the information sink in. I read article after article. I wasn't putting the acquired knowledge into practice. The Learning Pyramid may have been discredited, but I'm convinced that we learn more from doing than we do from reading about something.

So what makes reading so attractive that we'd rather read about things than actually doing them? And I know for a fact that I'm not alone in having this problem. I think – and this might be entirely personal – it's because of a couple of reasons.

One is that it's much easier to read about something than to actually figure things out yourself. I want to experiment with sharding in NoSQL databases? I have to set up virtual machines, set up the software, write scripts to generate testing data, think about how to perform some experiments, and actually run them. Naturally I'd want to collect some data from those experiments; maybe reach a couple of conclusions even. That's a lot of work. It's much easier to just read about it. It's infinitely easier to stumble upon and read an article on "How to Really Get Things Done Using GettingThingsDone2.0 and Reverse Todo Lists" than it is to actually get something done.

The second reason, at least for me, is that it gives me the feeling that I'm learning more about things. In the time it takes me to set up all the stuff above, I could have read who-knows-how-many articles. And it's true in a sense. The information isn't useless per se. I'm learning more shallow knowledge about a lot of different things, versus in-depth knowledge about a few things. It gives me all kinds of cool ideas, things to do, stuff to try out. But I never get around to those things, because I'm always busy reading about something else!

So I have taken drastic measures.

I have removed close to 95% of my feeds from Google Reader. I've blocked access to Reddit and HackerNews so I'm not tempted to read the comments there. I check hackurls.com (an aggregator for Hacker News, Reddit's /r/programming and some other stuff) at most once a day. Anything interesting I see, I send to my tablet (at most two articles a day), which I only read on the train (where I don't have anything better to do anyway). I avoid Wikipedia like the plague.

I distinctly remember being without an Internet connection for about a month almost four years ago. It was the most productive time of my life since the Internet came around. I want to return to the times when the Internet was a resource for solving problems and doing research, not an interactive TV shoveling useless information into my head.

Now if you'll excuse me, I have an algorithm to write and a website to finish.

Read the POSIX standard

Stop reading your local manual pages when programming/scripting stuff, and use the POSIX standard instead:

Online POSIX 2008 (EEE Std 1003.1-2008) standard

There are four main parts:

Some Do's and Dont's:

Finally, read Bash Pitfalls to learn why your shell scripting sucks.

VirtualBox: List guest IPs

I often clone VirtualBox machines as a quick way to get a fresh box to test some stuff on. The problem is, I don't know which IP the new clone gets assigned. Fortunately, if you've got VirtualBox Guest Additions installed on the guest, you can use the guestproperty to get the IP.

Here's a quick shell script for listing the v4 IPs of all the running guest virtual machines.

#!/bin/sh

VBoxManage list runningvms | cut -d "{" -f1 | sed "s/\"//g" | while read VBOXNAME; do
    IP=$(VBoxManage guestproperty get "$VBOXNAME" /VirtualBox/GuestInfo/Net/0/V4/IP | cut -d":" -f2)
    echo "$VBOXNAME: $IP"
done

P.S. If you're using Debian guests: delete the /etc/udev/rules.d/*persistent-net* files. See here for why.

Edgeworld Strategy guide v0.8

I've updated the EdgeWorld Strategy Guide to v0.8. Changes:

  • Updated Lvl 50 Helio vulnerability.
  • Removed lvl 250 Helio vulnerability.

Thanks to madstork91 for reporting Faction vulnerability changes. Get the HTML version, or other versions (PDF, ePub, etc).

Python UnitTest: AssertRaises pitfall

I ran into a little pitfall with Python's UnitTest module. I was trying to unit test some failure cases where the code I called should raise an exception.

Here's what I did:

def test_file_error(self):
    self.assertRaises(IOError, file('/foo', 'r'))

I mistakenly thought this would work, in that assertRaises would notice the IOError exception and mark the test as passed. Naturally, it doesn't:

ERROR: test_file_error (__main__.SomeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./test.py", line 10, in test_file_error
    self.assertRaises(IOError, file('/foo', 'r'))
IOError: [Errno 2] No such file or directory: '/foo'

The problem is that I'm a dumbass and I didn't read the documentation carefully enough:


assertRaises(exception, callable, *args, **kwds)
Test that an exception is raised when callable is called with any positional or keyword arguments that are also passed to assertRaises().

If you look carefully, you'll notice that I did not pass in a callable. Instead, I passed in the result of a callable! Here's the correct code:

def test_file_error(self):
    self.assertRaises(IOError, file, '/foo', 'r')

The difference is that this time I pass a callable (file) and the arguments ('/foo' and 'r') that the test case should pass to that callable. self.AssertRaises will then call it for me with the specified arguments and catch the IOError. In the first scenario (the wrong code), the call is made before the unit test is actually watching out for it.

Tmux scrolling with shift-pageup/down

Put this in your .tmux.conf to enable scrolling using the Shift-PageUp/Down keys:

set -g terminal-overrides 'xterm*:smcup@:rmcup@'

MCPlayerEdit v0.21 released

I've released a new version of my Minecraft Player/World Editor MCPlayerEdit v0.21. This release brings MCPlayerEdit up to date with Minecraft v1.0, The following features and modifications have been added:

  • Lily Pad
  • Nether Brick, Nether Brick Fence, Nether Brick Stairs, Nether Wart [block]
  • Enchantment Table, Brewing Stand [block], Cauldron [block], Brewing Stand, Cauldron
  • End Portal, End Portal Frame, End Stone, Dragon Egg
  • Blaze Rod, Blaze Powder
  • Ghast Tear, Nether Wart
  • Gold Nugget
  • Potion, Glass Bottle, Spider Eye, Fermented Spider Eye
  • Magma Cream
  • Eye of Ender, Spawner Egg
  • Glistering Melon
  • Music Discs

Thanks to Pedro Lopes for the patch!

Edgeworld Strategy guide v0.7

I've updated the EdgeWorld Strategy Guide to v0.7. Changes:

  • Added vulnerability of the level 1000 Maar Confederacy Base (thanks to Cam Arnold for reporting it).

Get the HTML version, or other versions (PDF, ePub, etc).

Programmer's Block: Analysis Paralysis

I'm in the process of writing a tiny tool. What it does is not important, only that it's nothing big. I've almost finished writing it, and it currently weighs in at about 260 lines of code. The bizarre thing is that it took me three days to write. By my estimates, it shouldn't have taken me longer than perhaps a day. So why did it take so long?

Like always, whenever I start writing a program, I begin with the absolute heart of the problem I want to solve. I then write the rest of the program around that. I never really design anything up-front, especially when it's such as small project. As normally happens, I run into some potential problems. The solution is almost always obvious. Part of the program might block on a non-responsive network resource? Fine, build some threading around it. External tools may need to access internals of the program? Alright, let's build in a simple RPC server to communicate with the process. Functionality should be extensible by system administrators or other programmers? Cool, just write some plugin architecture with a tightly defined API. In short, everything just flows.

"Flow" is, to me at least, exceptionally important. Problems and solutions present themselves almost instantaneously when I'm writing code. More often than not I need to refactor almost constantly during the development process. Some might see that as a problem; I don't. It's just the way I work. It's part of my flow. I can't design an entire program up front on paper or in diagrams [1]. I'm one of those "Solve the problem at hand and nothing else" kind of developers. I always gruesomely over-design things, scared of ending up with a design that is not extensible or flexible enough, which leads to Feature Creep. Usually, halfway through the implementation I will encounter something non-optimal in the design and feel bad for either following or not following the design. Following design breaks my flow, and it demotivates me. So I don't fully design up-front, although I usually have a rough outline in my head.

This time however, my flow was interrupted by something completely different. It was such a small and ridiculous thing that I'm almost ashamed of talking about it. You see, I needed to return some results from a method call, and I couldn't see the right way to proceed. My normal minimalist approach would have been to simply return the results as a list/array of values. My "Upcoming Problem" alarm bells started ringing however, as I anticipated that a simple list wouldn't do. The calling code would need to do various things with the results, which really weren't the responsibility of the calling code at all. So should I create a new object to hold the results, accompanied with some methods to perform operations on those results? Again it didn't feel like the optimum solution. It would mean tightly coupling that object with other code. I considered some other options, but it was beginning to feel obvious: my flow was broken.

So I did what I usually do when my flow is broken: I go and do something else. Let my subconscious think about it a bit. A solution is bound to jump to the top of my mind, and I can get back to work, right? Well, it didn't. Then I did what I almost never do: I let the problem fester in my mind. In the next two days I intermittently returned to my (still open) editor, looked at the code a bit, and went to do something else again.

After two days I suddenly realized I was having Programmer's Block over something completely idiotic! This was such a minor problem that I almost couldn't believe I wasted two days on it. My lack of progress wasn't because the problem was too hard, or that the solution was sub-optimal. That happens all the time, and I either keep on tinkering until I've solved the problem, even if it means the solution is sub-optimal. The problem was that I had multiple possible solutions in my head and all were equally sub-optimal, and I couldn't choose between them. I was over-thinking the implications of my choice; suffering from Analysis Paralysis. The very thing I try to avoid by not designing too much up-front.

In the end I just went with a random sub-optimal solution to the problem. I still don't know of a better one. Perhaps one will come around later on in the development, or during my final refactoring round. It's really not important, which is why it bugs me that I got stuck on such a minor problem in the first place. In any case, my flow is back and the program is almost finished [2].

So, the lessons learned?

  • Sometimes you just have to put your perfectionism aside.
  • Sometimes, all you have are bad choices. Making a bad choice is better than making no choice.
  • "Go and do something else" can sometimes actually be more harmful then just persevering in solving the problem, even if it is sub-optimal. Remember, it's just code. You can always throw it away if it doesn't live up to expectations. I was afraid of wasting time by making the wrong choice, but in the meantime I wasn't working on the problem at all, so the time was wasted anyway.

[1] Actually, I can design up-front. I just have to keep it very minimal. Some diagrams on the architecture of multi-tier projects. A couple of doodles of how the major components will interact. A small list of data that needs to be stored. But if I actually start making class diagrams, the flood-gates open and I end up with a beast of a design.

[2] Experience tells me the program isn't nearly finished. The "programming" bit of a project usually only accounts for about 40% of the total project I have to do. The rest goes to the final refactoring round, writing documentation, testing, packaging, release management, etc

Edgeworld Strategy guide v0.5

I've updated the EdgeWorld Strategy Guide to v0.5. Changes:

  • Added vulnerability of lvl 50 Helio base
  • Added vulnerability of lvl 250 Helio base
  • Updated Appendix II (upgrade costs)
  • Fixed battle duration before automatic retreat
  • Fixed some FIXMEs
  • Added some info about leveling up.

You can find the new version on my Writings page