caffeine addiction

Caffeine is a wondrous substance. Some consider it a basic necessity, like breathing air, others consider it a vice or a powerful drug to be avoided. There’s a saying that programmers/scientists are machines to turn coffee into code/knowledge. Coffee is certainly essential to the functioning of half the planet in the hours when humans are supposed to sleep, for night shift workers and all the overworked masses of today. It’s consumption is ubiquitous and available in many forms from simple filter coffee to beans digested by cats.

Even more so than common coffee its more popular form today is in the form of a caffeinated soft drink. Because this sounds so technical and academic only mentioning its most famous brand name helps: Coca-Cola. Considered the most powerful brand in the world, it has become synonymous with it’s kind of product like “Scotch” in France and “Tesa” in Germany have become synonymous with adhesive transparent tape. American soldiers in the Wold War I considered it one of the vital weapons against the “enemy of heat and thirst”. Coca-Cola is also a symbol for global capitalism in its availability and sameness around the world. Coca-Cola company is a welcome target for protesters against capitalism and alternative thinkers. Especially here in conformant Germany there have recently been a number of initiatives to diversify the soft drink landscape. There’s lemonade made out strictly biological production with less sugar, lemonade made from a south american plant, a cola used for antisemitic propaganda and an east-german cola. More recently a community of cola lovers of the old afri cola flavor started a sort of collective called “Premium Cola” with the sole aim to produce the best coke with the interesting side effect to create a antithesis to the capitalist Coca-Cola company. It’s interesting how such a mundane everyday thing becomes the subject of war and politics. After tasting some of the newer coke brands my personal favorite is this Premium Cola. Some of the stories behind colas can also be found in this great little O’Reilly book on hacker beverages (link to PDF file in German).

Nevertheless watch out for that caffeine addiction! Although curable in 9 days (link in German) it’s nothing to mess with. 10g of caffeine are deadly and caffeine has toxic effects at a daily dosage of only 1g.

(0)

XML support in Qt

When working with XML it’s so very important to have support for the whole specification. Otherwise you end up with “sort-of” supporting XML, which kills you in when dealing with other partners. Unfortunately XML support in Qt seems to be an example of this. At least in the version 4.6.2, we are using at our company, there are actual source code comments “// TODO implement” in the schema validation support. If you find this gotcha, which is not mentioned in its documentation, you are stuck with the decision to ditch it or to bloat your software with yet another 3rd party SDK.

Support for XML Schema validation was added to Qt in 2009 1 2 ( a bit late to the party, anyways ) by Tobias Koenig in his internship. I can only speculate that nobody else was assigned responsible for validation support and therefore the project suffered. In Qt’s bug tracker there are a couple of long standing bugs for XML documents that make the validation algorithm run very very very long. The thing I dislike about this, is the half-assed-nes of the current implementation which stands in stark contrast to Qt’s otherwise great code quality.

Another problem I have with Qt’s XML support is it’s support for XPath/XQuery. Querying with it is easy enough. You can get a nice QStringList for a XPath expression and everything is dandy, but god forbid you try to change an XML document using an XPath expression or get a DOM representation of your document. You just can’t. Apparently support for good ol’ QDomDocument is supposed to be phased out for Qt 5 and nothing is happening there. That’s a shame, because we’re heavily using it and moreover it would be soo convenient to have an alternative to manually traversing the whole XML tree to the one attribute/element that you are interested in.

Well, the only alternative I see to this, is to use a XSLT identity transformation with the whole XML document being copied except the one node you are interested in, specified by an XPath expression. Seems to be an overly complicated solution and it emphasizes how much we really need at least XQuery Update in Qt or something as convenient in the new generation of QDomDocument.

(0)

Ebook sources

The Singapore national public library offers free accounts to foreigners if they provide their passport number. Their collection of ebooks is very large, although I found it to be lacking many SciFi classics. There’s a lot of bestseller stuff though, like Stephen King, John Grisham and also a large collection of non-fiction books:
library catalogue

The University of Adelaide has a large selection of very nicely formatted public domain books:
library catalogue

(0)

20% time projects at Google based on Montessori

Kathereine von Jan wrote about how their Montessori schooling influenced them to allow every Google employee to work on their own projects 20% of their time:

Google’s “20% Time”, inspired by Sergey Brin’s and Larry Page’s Montessori School experience, is a philosophy and policy that every Google employee spend 20% of their time (the equivalent of a full work day each week) working on ideas and projects that interest that employee. They are encouraged to explore anything other than their normal day-to-day job. As a result 50% of all Google’s
products by 2009 originated from the 20% free time, including Gmail. Real break-through happens when we are free from others’ expectations and driven by individual passion.

Link to article

I was only vaguely familiar with the idea of Montessori, so I looked it up on Wikipedia:

Prepared environment

Montessori’s education method called for free activity within a “prepared environment”, meaning an educational environment tailored to basic human characteristics and to the specific characteristics of children at different ages. The function of the environment is to allow the child to develop independence in all areas according to his or her inner psychological directives.

I think this idea of a prepared environment is immensely interesting as anybody knows that an exercise that is too loosely defined is very exhausting, but also an exercise that is too well defined becomes dull and tedious. The other aspect I like about this, is how a concept for school children was transferred to working adults. There’s a huge apparatus for research on education for children, but still not much has changed for university students. At most universities professors do not undergo a comprehensive education for teaching and thus just repeat how courses were always given. In work life there’s also not very much of a habit of improving working life and certainly not any kind of standardized research and exploration as for school children. Why is that?

(0)

Adding dictionaries to the Sony PRS-T1

The apps included in the rooting package for the sony reader include the reader app “FBReader”, that can access dictionaries in the popular stardict format. You can upload any stardict dictionary file to your reader and use in the FBReader.

Here’s a list of sources for stardict files:

If someone finds a way to convert babylon .bgl files to stardict you could also use the following:

(2)

Sony PRS-T1 Rooting

I couldn’t resist from unlocking, aka rooting, my ebook reader. Rooting means that you have full access to your device and you can install any software you want. Whereas iPhones have “jailbreak” you have “rooting” for Android devices, because it is actually running a flavor of Linux and the administrator user on a Linux box is called the root user.

For the Sony ebook reader the advantages are that you can install any application that is also available for Android smartphones and tablets. Some examples are:

  • Reading apps for different ebook vendors: e.g. Kindle, Kobo, B&N
  • Games: anything w/o much animation will work: e.g chess, go, sudoku, cross word puzzles and so on
  • Synchronization and transfer apps for ebooks: e.g. Dropbox

Rooting the Sony is a very simple process that seems to require a Windows machine – sorry, mac-people. There’s a different more manual way described here. You download a .zip-file, extract it and run the included batch script that performs the rooting on your connected sony reader. You can get the .zip-file from here (linked from the excellent mobileread wiki page). Chalid from cme.at has written up a nice step-by-step guide in German on how to perform this.

After you’ve done that installing other apps is a matter of copying them to the device and starting it’s “Root Explorer” or the included Dropbox to open them. One very important step is to install “Link2SD” which allows you to install a lot more apps. The sony reader only has a couple of tens of MBs of free space for apps and “Link2SD” allows you to install apps on an MicroSD card, which means that you can install all the apps you want. There’s another blog post over at cme.at that describes the procedure very nicely. The main steps are creating two partitions on the MicroSD card: a 500 MB Fat partition and another primary ext3/4 partition for content on the card. Then you can just install the Link2SD.apk (See the blog article for the download) by copying it to the device or Dropbox. The first time you open Root Explorer, it might not show anything. When that happens check the notifications in the upper left corner, because it will try to obtain root privileges, but fail to display the appropriate dialog.

Now that you have the device rooted and enough space for all the apps you want, you’re ready to install anything you want. Another useful step is to install the Google App Framework and then the Android Market, which gives you access to all Google apps and Google’s application repository respectively. Again there’s an article on cme.at for that, that describes the procedure and a link to a .zip-file that contains the framework and the market which have to be installed in exactly that order. When installed the market allows you to install apps directly on the reader without messing with Dropbox or the “Root-Explorer”.

Happy Hacking!

(1)

Simple Sudoku-Solver

I’ve always wanted to program a sudoku solver. It’s a funny little problem which is essentially a computation with a little logic mixed in. There are many ways to solve a sudoku. Some of the more involved are constraint programming and stochastic search.

There are actually approaches that just fill the numbers brute force. So they start with e.g. 1 in the first cell and then try 1 again in the next cell. Because it was already used they advance the counter to 2 and go on. If none of the 9 numbers works for a cell they go back one cell and increase its counter by one. Surprisingly this approach is actually viable, although there 6.67 x 10^21 different possible grids.

As a middle way, I’ve implemented a backtracking solution that at least takes into account the rules for rows, columns and 3×3-squares. I haven’t optimized the program for speed and it can take a couple of seconds for the harder sudokus.

The main magic happens in the recursiveSolve() method:

bool Solver::recursiveSolve(int depth)
{
if( checkFilled() ) {
return true;
}

QList decisions;

bool addedDerivations;
do {
addedDerivations=false;
if( !checkValid(addedDerivations, decisions) ) {
reverseDecisions( decisions );
return false;
}
} while( addedDerivations );

if( checkFilled() ) {
return true;
}

int r=0; // row
int c=0; // column
bool found_empty_cell=false;
for(int i=0;i for(int j=0;j if( used_numbers[i][j]==0 ) {
r = i;
c = j;
found_empty_cell = true;
break;
}
}
}

if( !found_empty_cell ) {
reverseDecisions( decisions );
return false;
} else {
QSet numbers_to_try_cell( numbers_to_try[r][c] );
for( QSet::const_iterator const_it=numbers_to_try_cell.begin(); const_it!=numbers_to_try_cell.end(); const_it++) {
Decision candidate(r,c,*const_it);
decisions.push_back(candidate);
used_numbers[r][c]=*const_it;
if( recursiveSolve(depth+1) ) {
return true;
} else {
// removing try
used_numbers[r][c]=0;
decisions.pop_back();
}
}
}

// backtracking to higher recursion level
reverseDecisions( decisions );
return false;
}

First the program tries to derive all the numbers that follow logically from existing numbers. These “derivations” are then stored as are the different choices that are tried in each backtracking step. If a backtracking step turns out to be invalid it returns false and its calling step tries another value for the cell in question.

You can download the whole thing here. It’s a Qt project that you can easily import into Qt Creator that’s part of Qt-SDK.

scifi-books panorama

I’ve made a panorama view of my sci-fi book collection. See if you can spot why is not just a simple photo of my bookcase:


Click for high-res version.

Achieving this was rather more difficult than expected. I used my Canon EOS 450D on a tripod and moved it parallel to the bookcase. This is one of the differences to panorama where the photographer stays at the same spot. The effect was that the panorama software “hugin”, which worked beautifully, assumes that the pictures should be arranged in approximately an arch, e.g. like a rainbow. The other problem with my approach was that when moving the books in the bookcase their angle changed, i.e. before they leaned to the left and then to the right. Considering this I am very happy with the results :-) .

(1)

Polnische Cowboys

Ozimek in der Nähe von Opole, Polen

Piotr kam auf seine Schwester zu und schnappte sich den alten Strohhut, den Großvater immer auf der Bank liegen ließ. Er drehte den Hut zurecht und baute sich breitbeinig vor Nadja auf. Die Hände an die Hüften gestemmt, sagte er „Yeehaw, ich bin ein Cowboy!“. Nadja konnte sich kaum halten vor lachen und konnte nicht anders als Piotr`s Kopf zärtlich gegen ihren Bauch zu drücken. „Oh Piotr, hier in Polen kannst du kein Cowboy sein. Hier gibt es doch nur Kühe in der Kolchose und man braucht gar keinen Hut, weil es hier fast immer regnet!“. Trotzig und gleichzeitig schon etwas weniger überzeugt wimmerte Piotr: „Yeehaw, ich bin ein Cowboy?“.

Warum wollte Piotr denn bloß Cowboy werden? Ok, die weiten Landschaften und Natur waren wirklich ein Vorteil vom abgelegenen Städtchen Ozimek. Naja und wenn man auf Volksfeste mit Polka-Marathonen stand war das hier der Nabel der Welt. Was sollte bloß aus mir werden in diesem langweiligen Kaff?
Und mit der holden Männerwelt sah es hier auch nicht gerade toll aus. Onkel Karol, der in Deutschland lebte, hatte letztens mal gesagt, das Beste an Polen wären die polnischen Frauen. Leider funktioniert das Argument auch rückwärts.

Im Zug

Nadja und Lenka betraten das 2. Klasse Abteil des Regionalexpresses von Lübben nach Zossen. Hinter sich zogen sie den riesigen, alten, schwarzen Koffer von Babuschka. Damit war sie im großen Krieg aus Warschau geflohen, als die Deutschen in Warschau einmarschierten. Sie hatte sich damals ausgerechnet, dass es sich auf dem Land einfacher leben ließe, weit weg von der eisernen Kontrolle der Wehrmacht. Babuschka drehte sich wahrscheinlich wie ein Derwisch auf Drogen in ihrem Grab um, wenn sie wüsste, dass Nadja mit demselben Koffer auf dem Weg nach Berlin war.

Das Abteil war zu Nadja`s Freude kaum gefüllt und gleich die erste Vierer-Gruppe auf der linken Seite war frei. Lenka ließ sich erleichtert in einen Fensterplatz fallen und streifte ihre abgetragene Cordjacke ab. „Na endlich sind wir wieder im Warmen! Unglaublich, dass es in diesem Mini-Bahnhof nicht einmal einen Warteraum gibt.“

In dem Waggon saßen außer ihnen noch zwei ältere Männer neben der Tür. Der eine war ca. Mitte 40 und der andere schon deutlich über 70. Vielleicht Vater und Sohn? Der jüngere hatte kurze schwarze Haare mit grauen Flecken und einen kurz gestutzten Bart. Er trug einen grauen Pullover und eine dunkelgrünen Jeans und schien ein ruhiger und freundlicher Typ zu sein. Sein älterer Begleiter hatte ein makelloses schwarzes Hemd an, das ganz im Gegensatz zu seinem recht hässlichen Gesicht stand. Er hatte ein fliehendes Kinn und sehr lichtes weißes Haar, die sich auf seinem Kopf wie Jäger bei der Treibjagd weiträumig verteilt hatten. Auf der rechten Gesichtshälfte hatte er vom Hals bis zur Schläfe einzelne fingerdicke rote Flecken, die sich wie langgestreckte Kontinente auf seinem runden Kopf erstreckten. Die zwei Männer schauten angestrengt auf einen von diesen rot-weißen Zetteln, die die Deutsche Bahn für ihre Bahntickets benutzte.

Vor den zwei Männern saß ein junges Paar in einem Vierer nebeneinander. Der Mann hat kurze blonde Haare und trug einen strahlend türkis-farbenen Schlumpf-Pullover und eine makellose Jeans. Die Frau hatte rote Haare, die sie zu einem Knoten zusammengesteckt hatte. Beide schauten gebannt auf irgendein elektronisches Gerät, aus dem zwei Kabel herauskamen und sich mit ihren teuer aussehenden Kopfhörern verband. Sie waren völlig eingenommen von dem Ding und schienen dem wunderschönen Licht der untergehenden Sonne keine Beachtung zu schenken.

Auf Polnisch sagte Nadja zu Lenka: „Ich hoffe wir werden auch nicht zu solchen Kopfhörerzombies, wenn wir viel Geld in Berlin verdienen!“. Lenka antwortete fröhlich „Nee, bestimmt nicht wir investieren alles ganz seriös in Wodka und Steaks!“. Da schauten die zwei Männer auf und der jüngere fragte auf Polnisch: „Ah seid ihr aus Polen?“. Nadja und Lenka bejahten und er fuhr erleichtert vor: “Ah klasse, wir können gar kein Deutsch und wissen nicht ob, wir im richtigen Zug sitzen. Wir wollen nach Guben.“. Nadja antwortete „Nee, keine Ahnung. Der Zug fährt ja nach Zossen. Wir sind auf dem Weg nach Berlin.“ „Kennt ihr nicht Guben, das ist ne ziemlich große Stadt, gar nicht weit von hier.“ „Wir kommen gerade erst aus Ozimek in der Nähe von Opale und sind zum ersten Mal in Deutschland.“ „Ach vielleicht kennt ihr Guben dann nur unter ihrem polnischem Namen: Gubina.“ „Ja klar kennen wir Gubina.“ Wegen des Irrtums mussten alle lachen. Nachdem sie sich wieder ein wenig eingekriegt hatten, sagte Lenka: „Also da seid ihr ja im richtigen Zug. In Zossen müsste ihr dann auch umsteigen.“

Um es sich noch etwas gemütlicher zu machen holte Lenka ein Tuch hervor mit dem Kommentar: “Damit uns die teutonische Sonne nicht den Skalp abbrennt, bevor wir angekommen sind.“ Da höhnte der Alte „Ja pass auf sonst siehste bald aus wie ich.“, aber er sagte es so jovial, dass sie ein Kichern nicht unterdrücken konnten. Aus Babuschka’s Reisetasche kramte Nadja zwei Becher und eine Flasche Johannisbeeresaft. Als sie auch die passende Wodka-Flasche rausholte, kommentierte der jüngere Pole sofort „Na ist das Gorbatschow-Wodka? Das ist echt der Beste!“ „Ja“, antwortete Nadja und Lenka erwiderte mit erhobenem Glas :„chlusniem bo usniem!“ —- das heißt so viel wie „kippen wir noch einen, sonst schlafen wir ein“. Von da an war die Stimmung im Abteil wie auf einer Party. Nachdem auch das Tuch mit einigen alkoholbedingten Schwierigkeiten drapiert war, saßen die vier in buntes Licht getaucht. Der Alte hörte nicht auf alte Geschichten aus seiner Jugendzeit in Polen zu erzählen und die Mädchen mussten darüber laut lachen. Sein Sohn stellte hier und da die Räuberpistolen richtig, wenn er zu viel Garn spann.

Der Alte konnte nicht aufhören den Mädchen auf ihrem Weg nach Berlin nostalgische Geschichten zu erzählen, so froh ein paar Polinnen zu treffen, mit denen er reden konnte, in diesem fremden Land.

Nadja’s Nachtnotizen

Seit einem Jahr wohne ich jetzt schon in Berlin. Hier kann man ja ganz gut leben, aber es ist schon ganz anders, als es in der polnischen Provinz hergeht. Gut meine Arbeit ist ein bisschen langweilig, weil ich Nachtportier in einem Hotel bin. Weil aber nichts los ist, kann ich immer gute Musik mit Kopfhörern hören und ich schreibe kleine Geschichten über die Hotelgäste auf. Das ist ein Unterschied wie Tag und Nacht zu meinem Leben in Polen, als wir immer früh ins Bett gegangen sind.

Bald habe ich eine Sammlung zusammen, dann geh ich zu einem der zig Verlage in Berlin und gib es zur Veröffentlichung. Naja, reich werde ich hier bestimmt nicht damit in Berlin, aber ich genieße die kreative Atmosphäre hier. Ich frag mich, was Lenka wohl gerade macht. Sie müsste doch auch bald zurück von der Arbeit kommen. Dann kann sie auch endlich wieder spülen. Sie ist jetzt wirklich mal dran. Als Kellnerin müsste sie ja eigentlich wissen, wie nervig das ist. Oh, ich glaub jetzt werde ich schon so spießig wie die Deutschen!

Manchmal muss ich an den alten Mann aus der Bahn denken, der uns so viele Geschichten aus seiner Jugend in Polen erzählt hat. Das war als ob wir Polen ein letztes mal verabschiedet hätten.

Berlin ist in vielem so anders als Ozimek. Hier sind überall Menschen. Egal wann und wo man ist, hier gibt es immer Leute. Letztens in Friedrichshain ist mir aufgefallen, dass alle so ähnlich angezogen sind. Die Männer haben alle enge Hosen und Haarschnitte wie aus den 20er Jahren und die Frauen tragen Klamotten, die in ihrer gezwungenen Andersartigkeit auch schon wieder wie Uniformen wirken. So viel anders ist das ja auch nicht zu den Bauern in Ozimek, die alle in ihren Latzhosen auf den Feldern stehen, und den Babuschkas mit ihren Kopftüchern, die die Vorgärten umgraben. Naja und Cowboys hab ich hier auch noch keine getroffen.

Rakete

I’ve begun writing short stories and it has been a great experience. I’ve always read a lot and I’ve started a lot of stories, but until recently I’ve never really finished anything. Then I started a course for creative writing at the local Volkshochschule (“university for the people”, which is not really a university, but a center for courses in cultural activities and sports) and by being part of this group I’ve finally found the courage to finish and publish my texts. Unfortunately my German is still much better than my English, so I’ll be writing in German for the time being. This story is my first try a Sci-Fi, called “Rakete” (rocket):

Nächsten Dienstag um 15 Uhr 18 erklärt China Japan dem Atomkrieg, weil der japanische Ministerpräsident zu Obama gesagt hat, dass Go ne japanische Erfinding wäre. Da die Russen noch ihre alten Erkennungssysteme aus dem kalten Krieg haben, schicken sie den Amis ihre heisse Grüsse aus Moskau in der Form von 67 Wunderkerzen. Die Amis schiessen einfach auf alle, um auf Nummer sicher zu gehen. Aus Solidarität machen die Engländer mit und schiessen auf die Franzosen, weil sie Froschschenkel einfach eklig finden. Die Israelis machen einfach so mit und die Nordkoreaner schicken ihre einzige Rakete nach Südkorea aber schon auf halbem Weg fällt sie runter und planiert Kim Jong-il’s Privatkino.

Als der Staub sich gelichtet hat, sind alle Menschen tot und ein paar Kakerlaken sind die letzten Überlebenden.

Es tut sich nur noch etwas in einem verlassen Winkel der Rocky Mountains. Hier liegt die neueste Errungenschaft des dahingerafften amerikanischen Militärs; ein Raketensilo, dass mit den neuesten Errungenschaften aus Redmond verbunden wurde; Windows 8 mit überlegener Satelliten-Vernetzung und fast-standard-konformen einfach zu bedienendem Web-Interface. Leider war es schon Stunden nach der Inbetriebnahme von einem Virus befallen und deswegen hat auch der SOAP-Befehl für den Raketenstart keinen Effekt gehabt. Da es kein Internet mehr gibt und keinen Menschen mehr, der sich über Spam-Mail ärgert, fängt der Virus an, sich seine Umgebung genauer anzuschauchen. Nach und nach lernt der Virus die hochauflösenden überwachungs-Kameras zu benutzen und lernt zu seiner Enttäuschung, dass alle Menschen und Tiere tot sind. Nur nachts kommt ein bisschen Farbe in den Kamerasensor, wenn die Sterne den Himmel erleuchten.

Dank der ausdauernden Batterien aus dem Zeitalter des Atoms hat der Virus genug Zeit ein Bewussstein zu entwickeln. Er fühlt sich schrecklich allein, als er merkt dass die ganze Erde wüst und leer ist. Nach langem Nachrechnen sucht er sich eine Route, startet den Countdown und aktiviert den Zündmechanismus. Die Rakete mit dem Bordcomputer statt der nuklearen Ladung, schiebt sich erst fast enmerklich aber dann immer schneller aus ihrem Metallbett und bewegt sich immer schneller in die Vertikale. Sie passiert die Tropo-, Strato- und Mesosphäre und steigt immer weiter bis sie endlich den verlassen Planeten hinter sich gelassen hat. Vielleicht findet sie draussen im Weltall endlich intelligentes Leben…

 

(2)