Counting the number of changed lines between the original and a changed file

February 23rd 2011 · Read More · Comments(2)

Recently I needed to count the number of lines I had updated in a file compared to the original. After reading the man page for diff, playing around with it and thinking a bit I came up with the following command:

diff -y <original> <new> | grep -E "\||<|>" | wc -l

New host

January 17th 2011 · Read More · No Comments

I’ve migrated the blog to a new host. Hopefully nothing is too broken. I might have lost some comment spam in the process, but that’s hardly a bad thing.
Also: Hi there spider!

Fixing slow ssh on OS X

September 12th 2010 · Read More · Comments(4)

I have a few hosts that I have enabled X-forwarding by default to. A while ago it suddenly started to take a very long time to connect and log in to the remote machines.

A bit of digging and googling made me realise that the culprit is in fact xauth, which didn’t make much sense to me at first. A bit more googling led me to this blog post. The post explains that in the 10.6.3 update changed the way that the local X display is referred to. Normally the first local display is reffered to as :0 but in the update Apple changed it to org.x:0. This is bad because xauth things the org.x is a domain name and tries to resolve it. The blog post suggests stripping out the org.x part and creating symlinks to the existing unix socket, but I don’t really like that solution because it creates extra symlinks.

I came up with a different, although possibly more ugly and hackish solution. It’s unlikely that x will become a topdomain in the near future, so performing the following in a terminal will make the DNS lookup succeed and always point to the local computer instead of timing out.

sudo echo "127.0.0.1 org.x" >> /etc/hosts

It’s important that there’s two greater then signs or you will overwrite the file instead of appending to it.

New batch of homebrew

April 2nd 2010 · Read More · Comment(1)

Started a batch of Brewtec’s Bock. Making 21 litres instead of 23. Might have pitched the yeast slightly warm, thermometer tells me 30 degrees. Range of yeast is 18-28. I hope that’s not absolute min and max. Initial gravity is about 1037. Kit says it will be done at 1005.

Beer fridge is set to 19.5 degrees C.

I intend to use bulk priming at bottling and put most of it in 0.75l bottles if I brewed more I’d definitely switch to kegs.

New Photos on my Flickr page.

August 16th 2009 · Read More · No Comments

I went to the Hamilton Gardens today and took some new photos. The light was pretty weird, a very bright day but still overcast.

Normally I’d say that overcast can be pretty good for photography, but I had problems with getting my motifs underexposed because the overcast sky was so bright.

It did however give me a very good lesson as to why the camera’s JPG with auto white balance can be crap compared to shooting pictures in raw.

Computer Controller Beer Fermentation

May 16th 2009 · Read More · Comment(1)

I’ve spent this and the last weekend soldering together a bunch of circuitry that I can use to control my beer brewing process. I have built three calibrateable temperature sensors and two circuits to drive two different relays. There will then be connected to an Arduino that will be the brains.

The temerature sensors will be used to measure the temperature around my beer and the relays will be hooked up to the fridge that the beer fermentation will be taking place. The other relay will drive a lamp that I can use to heat the inside of the fridge.

I am planning on either making a webpage or an instructable showing exactly how it’s all done and set up some kind of github or sourceforge project with the code for the Arduino.

Capturing SIGINT in multithreaded python

August 27th 2008 · Read More · No Comments

Multithreaded Python scripts doesn’t always respond to signals. This is because it is not defined which thread will receive the signal. Also, it seems that if a thread is sleeping the signal might be interrupted altogether. The sympton of this that I saw the most often was that the script deadlocked and had to be killed.

Activestate contains a more thorough discussion of this together with code for a signal handler that catches SIGINTS and aborts the process.

Bananas

August 24th 2008 · Read More · No Comments

Sometimes they turn ripe and taste more of bananas. To me that’s a bad thing. I don’t really like bananas. I just eat them because they’re a decent snack between meals.

I figured that I would like them a lot more if someone would make bananas a bit crispier and make them taste like apples. Then I might actually enjoy eating bananas ;)

Maybe I should write an article about it and try to get it published in Waikato Times. Hopefully that would encourage a farmer to do investigate the chances of crossbreeding. If they succeed with creating a new fruit I think they should be called “bapples”.

Ph.D topic

July 7th 2008 · Read More · Comment(1)

There’s been a lot of questions what it is I am going now, and I’ve decided to try to write a bit about it.

The official title of my work is “Using machine learning to detect events in traffic flows”. What this actually means is a bit more complex ;)

A traffic flow is basically the traffic which is generated by someone interacting with something on a network. It can be someone checking their email, browsing the web or using Bittorrent. It is the actual flow of information exchanged between the parties, not the actual data. Events is relatively self explanatory, they’re when something happens in a traffic flow. Detecting this accurately is actually very difficult, and there’s been a number of specialized methods developed to do this. The biggest problem with these methods seems to be that they’re bad at adapting or detecting all types of events.

Machine learning is that when you use specialized algorithms which are used to teach computers to wade through big amounts of data and either classify it or find out what’s interesting about it (This is just a part of what it actually contains, but for this explanation, it’s good enough.). What’s really important to keep in mind is that the computers are trained to work with the data and that they can also learn from experience.

What I will actually be doing is to combine all of this. I will look at traffic flows and then investigate the best ways machine learning can be used to detect these events. I will also attempt to classify different types of traffic, such as web browsing, emailing and so forth.

The research I’ll be conducting will be within the limits of an autonomous control system for networks which detects problems, comes up with possible solutions, simulates them and then implements the solutions. My work will hopefully only be used to detect problems ;) And for those of you who wonder, I do not look at packet payload. In fact, I do not even have any payloads in my test data. That makes encryption useless to defend against this kind of classification ;)

Gogol Bordello

April 5th 2008 · Read More · No Comments

After discovering Gogol Bordello a while ago I finally got around to buying their cds at Sound Pollution today.I’m very happy with the buy and I have to admit that I find the sound quite compelling. They categorize themself as gypsy punk, and I guess it’s a fairly accurate description.  If you think you might like that kind of music I can definitely recommend checking them out.

It’s a shame that I missed their concert when they were playing here in Stockholm…