Software developer blog

Postponable iterator

When I started this blog I had no idea how hard it will be to post useful things without revealing too much about the "top secret" projects we are involved in. 🙂 This time though I've been allowed to release an entire class that turned out to be useful in an application we were developing a while back. The piece of software below was created with a financial support by Uratim Ltd. and can be used under the terms of the GPL license. YAY for free software.

Postponable Iterator source

The iterator pattern is one of the most frequently occurring patterns used in software design. Even before one learns about design patterns inevitably implements an iterator without actually realizing. The problem I came across not so long ago was that I had an iterator that was returning  jobs from job packets that would have to be processed but there were a number of constrains I had to keep in mind:

  • For each job there is a resource assigned for the job. It can only be executed using the resource assigned to it.
  • As long as possible certain resources should not be accessed too frequently. (But they can be accessed more frequently when it is necessary.)
  • Packages are processed semi asynchronously: all jobs in one package are returned at once, but there may be more that one pending package. The maximal number of packages under simultaneous processing is a parameter.
  • When there are too many jobs waiting for a single resource than access times should be gradually decreased to avoid too long waiting times for jobs.
@ //

Gomoku perfect play

The other day I had a very boring job to do. I had to listen to a sound recording of a workshop I've been attending few weeks ago and sum up the ideas that appeared during brain storming. I couldn't come up with any other solution, but to listen to it while playing Gomoku. It's not a time critical game so I could switch back to writing LaTeX code whenever I needed, and since it's quite an easy game, I still had the brain computing power to multitask. (By the way I use GNU screen to manage my terminal sessions, and vim to code so it just seemed convenient to use the BSD Games implementation of Gomoku... pretty old school, huh?)

Anyhow... as most of you probably know Gomoku is a pretty unfair game, as the first player has a winning strategy... but how hard is it to memorize the winning strategy? Is it even possible? Well... I set out on a journey to find out about that. I spent about half an hour to research Google for any existing perfect play algorithms, but didn't have much luck. Next I tried to find out how computer plays Gomoku... The key concept seems to be Minimax search and Alpha-Beta Pruning, but that is a highly heuristic approach, and since I could beat the algorithm as second player, it does not result in a perfect play either. (Although I could guess that even without winning against the computer.)

Well... I'm stuck at this point. I think I'll read what L. Victor Allis has written on the topic in his thesis. But before doing so, I'll have to get back to coding for food. (-;

@ //

Remote editing

To achieve maximal productivity it is very important to choose the right tools for editing your code, and find the configuration that works best for you. When coding on a remote server one has several choices, but each has it's drawbacks. Let's sum up the possibilities.

@ //

Moving your PuTTY config

The general stereotype is, that geeky programmers don't like windows, and to be honest it really is like an annoying aunt: you hate her, but got to put up with her sometimes. Although one must acknowledge windows' virtues, and I'd find it inconvenient to get along without my windows box at home. Not because of windows, but because of software that is only available for windows and don't run on Wine. However when it comes to coding I inevitably find myself opening an SSH connection to my Linux based server. So not surprisingly PuTTY is among the first 3 or 4 applications I install on a fresh windows.

One of the most convenient features of Linux is that configurations are stored in simple files allowing you to just copy them to your new home directory without much trouble. On windows however configurations are hidden deep into the registry making it a real pain to re customize your windows desktop once you replaced your old PC with a new one. Not that if windows was so highly customizable, but it still takes like a day to get all of my settings right. Today was such a day...

@ //