Job post

Just saw this job post and had a laugh when I got to the last line.

Wanted skills and knowledge:

 – C++ programming
– Image processing and analysis
– GPU programming
– Computer graphics / Visualization
– GUI development

And this is a summer job for students. Who in their right mind studies interactive design and multicore programming? There must be like 1 person in the whole of Norway that fits the bill.

Also. I’m looking for an architect to build my new house and then make some paintings for the living room. Anyone?

Rose on my desk

The rose on my desk has a perfect flower.


Priser på


Da fikk vi rettet opp i de misvisende prisene til Netcom. Hvis du vil ha nettbrett, så koster det fra 200,- kroner i måneden. Det som stod om 1,- krone, det blir som når banken sier at huset ditt koster 50 øre, akkurat passe misvisende (eller var det Telenor?)

Hvis du vil ha nettbrett, så etter et par sider er månedsprisen blitt skrudd opp til 349,- uten at det blir nevnt med så mange ord.

Bug in

There is a small rendering bug in the on OSX Mountain Lion running on a retina display. is the default preview app in OSX for viewing PDF files, JPEG files or DOC files. Or pretty much any file you want. Through the years it’s also gotten some very useful features, my favourite being the edit toolbar for adding text and arrows and such to documents and images.

On a retina display, PDF’s meant for regular displays need to be handled very carefully. Any distances and locations need to be preserved while fonts are upscaled and rendered onto the original canvas while photos need to be rendered straight through onto the canvas at retina resolution.

However, Apple’s efforts have not been enough, since when scrolling through the content, the edge between the canvas and the toolbar distorts the content one pixel row. This distortion is still visible as you scroll up or down as a “stuck” row in the document where everything is shifted a pixel row up. This is immediately visible on any diagonal lines. Screen Shot 2013-02-06 at 7.04.08 PM

On the “<” in the above picture you can see the line is slightly broken.



Enlarged to make the effect more obvious.

Zooming in carefully in photoshop it is obvious that one row of pixels is missing. Below showing the original (left) and the correction in pink (right) to emphasise the missing row. Everything below the pink line is simple shifted down one row of pixels from the original.

Screen Shot 2013-03-03 at 8.13.14 PM

And finally as a comparison. When zooming in and out again the canvas re-renders and the glitch is gone.

Screen Shot 2013-02-06 at 7.04.14 PM


So how do you reproduce this glitch. Open a PDF with lot’s of text, scroll so that one line of text falls on the edge og the canvas (top) and scroll up quickly to bring the entire line into view. Inspect the line of text for any glitches, if none are visible, try again.

Boingohotspot and iOS Messages

I was recently at Heathrow T5 and connected to the boingo hotspot just to see how much it cost when I got a message in iOS messages in my iPad. Seems like it go through their router for some unknown reason. Since I hadn’t paid and all email or we page requests failed or ended up on the boingo landing page, I would like to know how the messages go through over the wifi connection.

Anyone got a clue?

There is a bug in my software


Regex and pattern matching in OWL

Building my new personal finance application I needed to do pattern matching on literals in OWL. I ended up using some custom pattern matching with a bit of java code because I wanted to use Pellet for my reasoning, however I did discover that Hermit supports the xsd:pattern for OWL.

hasName some string[pattern ".*Peter.*"]

Matches any individual that has a “hasName” property with a string containing “Peter”. The “.*” is regex for wildcard.

This works in the latest version of Protege (4.2) with Hermit 1.3.6.

Screen Shot 2012-12-19 at 10.50.28 AM

Swimming in Montevideo, Uruguay

Spent a while looking for a nice place to swim in Montevideo. Most of the places I found were old and run down. Then I heard that the spa at the Radisson Victoria Plaza had a big pool and was accessible to outsiders. I paid 2500 UYU (130 USD) for a book of 10 tickets valid for a month. Each ticket is valid for an entire day, so you can go out to lunch and return in the evening.

The spa has a weights room, 100 meter running track, ~20 meter pool with a skylight, jacuzzi and sauna. You also have access to spa facilities like a massage if you want to pay for that.

  • IMG_0592
  • IMG_0591

Snowing in Oslo

Arduino Serial Protocols

Communicating with an Arduino over serial usb is easy thanks to the simplicity and abstractions in the Arduino IDE together with good example code for (among others) Java.

The challenge then is designing a protocol to clearly and efficiently send commands and request information from the arduino. There are many such protocols available, from simple single byte protocols to advanced XML or JSON based protocols.

The simplest protocol is a single byte protocol. It keeps every byte separate and there is no interdependence between bytes. The essence of the protocol is to send one byte, eg. to turn on a led, and another to turn off the led. The byte to turn on the led could be ‘1’ and the byte to turn off the led could be ‘0’. This protocol is very easy to implement and requires no synchronisation or advanced semantics.

The protocol can also be used to send variables, eg. to control the brightness of a led or the angle of a servo. A problem arises though when you want to mix variables with commands and requests. The solution is to reserve some byte values for command signals and use the remaining bytes to support a single variable, or split the byte to support multiple smaller variables. An example is a led lamp that has an auto mode. ‘0’ denotes off, ‘1’ denotes auto mode and 2-255 are for manual brightness.

If you do not want to sacrifice resolution of a value an alternative protocol is a variable-byte protocol. Here a message can be as long as you want and to transfer more complicated messages you would leverage interdependence between messages. To construct such a protocol you could set up a tree for which messages you would expect to follow some other message.


The problem with such a protocol is that some messages are 2 bytes, some are 3 and some are 4. This means that if you should get an exception or other unexpected behaviour in your program you would risk getting out of sync with the server. To handle this you could send a special escape signal, but programming support for this at all levels of your code is not so simple.

To simplify the variable-byte protocol we could devise a 2-byte protocol. The first byte is always a control byte, and the second is either null or a value byte. This way you would not fall out of sync with the server since you always receive two bytes at a time. The downside to this approach is that the the highest resolution of values is always 8-bit. So alternatively this protocol could be extended to a 3-byte protocol or even a 5-byte protocol. The key is that the every message is always fixed length, so sync is never a problem like it could be in a variable-byte protocol.

As a hybridisation between a fixed length and variable length protocol is the contained length protocol. The difference being an explicit byte saying how long the rest of the message is.


This way every message is always received in its entirety and sync should never be lost.

The remaining problem with all the above protocols is that they have no generic syntax support or semantics. This is where something like XML would come to play, since you could define the semantics and syntax of what follows in the message within the message.

Currently though I use a 2-byte protocol for my lamp, initially I used a single byte protocol but due to restrictions I opted to upgrade to the 2-byte protocol for simplicity and expandability.