100% meat-free code

From an iPhone 4 to a Lumia 925

My first and only smartphone up to now is/was my iPhone 4. I had it for almost four years now. Since it won’t get an update to iOS 8 and 700 to 800 euros for an iPhone 6 this fall are a lot of money, I decided to give Windows Phone a try and bought a Lumia 925. Here are some thoughts after 1 day of Windows Phone 8.1 (in the eyes of a longterm iOS User)

Moving my Contacts

The first thing I wanted to do was to have all my contacts from my iPhone on my Lumia. After some googeling I decided to export all my Contacts to my GMail account and sync them from there. Something synced, but none of my synced contacts had a phone number (bad for contacts on a phone). Next thing I tried was to transfer my GMail contacts to and sync them with my Lumia. This had the same effect: phone numbers on, but not on my smartphone. Luckily I saw that Windows Phone offered an option to sync with good old iCloud, so I entered my Apple ID and there were my contacts (and they had phone numbers).

Apps, Apps, Apps

Yes, this is still an issue with windows phone:

  • No official App for my Sonos system. I didn’t bother to try any of the alternate Apps, because I still have my iPad to control my Sonos.
  • No official Dropbox Apps
  • No Google Apps (not even Authenticator, so I have to change something with my two factor authentication)
  • 1Password misses a lot of features, but at least I can further use it. And its free on Windows Phone (which compensates for the lack of features)
  • Threema. I read that a Windows Phone is in development, but until it is released I have to use WhatsApp again.

What I am still missing

Two things:

  • The gesture to go back and forth in history introduced in iOS 7. Far better than the dedicated button on the Lumia.
  • Being able to use the phone with one hand only.

The Upsides

The Modern UI is definitely an eye catcher and a welcome change to four years of a 4×4 grid of icons. The Lumia 925 is a lot faster then my old iPhone and the camera  should be a lot better too (had no chance for a comparison so far).

I will definitely give it a shot for the next few months (at least until the iPhone 6 is out), then I will decide If I go back to  iOS or not.

Counting Sort in Ruby

I stumbled on this article from Austin G. Walters on reddit. It’s about a C implemention of counting sort which is restricted to integers but is of complexity O(n), if the range of the elements is in the order of n. I did a quick implementation in Ruby to see if I could beat Ruby’s Array#sort. Here it is:

class Array
  def counting_sort
    min,max = self.minmax
    histo =,0)
    self.each { |e| histo[e-min] += 1 }
    sorted = []
    histo.each_with_index { |e,i| e.times {sorted << i+min} }

Turns out Array#sort is  way faster than this implementation. It’s more than twice as fast on an array of 1 million elements. I assume that Array#sort is not implemented in Ruby but in native code.

Ruby: retrieve tweets that contain a certain #hashtag

Interacting with Twitter is pretty easy in Ruby. First you have to install the twitter gem

gem install twitter

To use this gem you need to register your application with Twitter here to get your CONSUMER_KEY and CONSUMER_SECRET.

The connection to Twitter is established in the following manner

client = do |config|
  config.consumer_key = CONSUMER_KEY
  config.consumer_secret = CONSUMER_SECRET

Now it is very easy to do a search on all recent tweets. The following loop prints all tweets of the last 24 hours containing #hashtag

now =
catch :done do"#hashtag", :result_type=&gt;"recent").each do |tweet|
    diff = now - tweet.created_at
    throw :done if diff &gt; 24*60*60
    p tweet

Based on this I built a little webpage that shows how much is tweeted about german soccer clubs:

Raspberry Pi in a Super Nintendo Case – Part I

I always wanted a Super Nintendo when I was a kid, but I never got one. So this my new Raspberry Pi project: Put a Pi into a SNES case and make it emulate SNES/NES games. Further I will use originial controllers and set them up to work with the Pi. Thank god, a lot of work has already been done over at the RetroPie Project.

For the first stage of my project I will connect the the SNES controllers to the GPIO interface of the Raspberry Pi.


  • a SNES. I ordered a broken one on eBay
  • Tools to open the SNES. Yes, Nintendo uses proprietary screws. You can either google for some hacks to open the case with a ball pen or self made screw drivers. I simply ordered a Gamebit (4.5) on eBay which is certainly the easiest method
  • At least one original SNES controller
  • Raspberry Pi, a SD card with at least 8GB, a micro USB power supply, a HDMI cable for connecting it to your TV and a keyboard (for setup only)

After opening the SNES you will see that a flat flex cable connects the controller board with the main board. I removed this cable and wired the controller board to the GPIO pins.

Wired SNES controller board

The controller boards has 11 pins which I wired in the following manner to the GPIO pins to make it work with RetroPie. The numbering is left to right if you look at the back of the board (which is probably not as Nintendo intended as this way pin 1 connects to GND…)


Wired GPIO

That’s its. Now fire up emulationstation and play a ROM of your choice.

Playing Donkey Kong on my Raspberry PI

New years resolutions 2014

Its already a little late, but not too late for the same procedure as every year: new years resolutions. But this time I will try something different to make them stick: I will use peer pressure (by making them public).  So here they are:

  • Start a blog. In the past I started some (mostly programming) side projects but never finished even one. My new side project will be this blog.
  • Stop biting my nails (awful habit). I bite my nails as long as I can think back. I already tried to stop several times (I remember that I once managed to stop for at least a month or two) but always failed.
  • Eat less chocolate. I eat a lot of chocolate and once I start, I cannot stop. For this year a will restrict the amount of chocolate I eat and try to enjoy it more.