The Bike Situation

For once, I am not going to talk about technical stuff but about cycling (this article is about Dublin but I am sure applies to a fair few cities). I have been sitting on this article for a few weeks, and I feel this is now time to publish it. I would like to thank Rich for the edits and corrections.

I am mainly a cyclist, this has to be said so people reading this understand that this article might be slightly biased. I live in Dublin and commute mainly by bicycle every day to the city center. That said, I am also a driver and a pedestrian. I should also mention that I lived in various parts of the world where I have seen all styles of people. This brings me to my point. People are stupid. Yes, it could be you, or your neighbour. The point is, regardless of the type of transport, you have idiots everywhere. This is quite important since on my commute I see idiots everywhere.

Let’s start with the drivers. there are good and bad drivers, like there are good and stupid people. The bad ones are amazing at pushing a cyclist in to the pavement, exceeding (sometimes at high speeds) the speed limit creating waves of air as they pass you, breaking red lights. I see this on my commute every single day. My favourite infraction remains when a vehicle passes you close to turn left just in front of you – this happens much more than you think. Cars parked in the cycle lane (and I do not mean parking spots but cars parked on single or double lines where only cycles are supposed to be allowed) is also very common and quite often on double yellow lines.. I will not expand on the bus drivers that feel the need to push you as you cycle, even if you leave them as much space as possible to pass by.

The second type is the cyclists. One could argue that the rising of Dublin Bikes brought a lot of less aware cyclists out there, and not a single day passes where I do not see one of them breaking a red light or going against traffic on a one way road. The funny thing is, this applies to the people owning their bike , and most likely commuting regularly too. Breaking red lights emphasizes natural selection, I am fairly convinced that chicken run applies here, stupid chicken crosses the road at the wrong time, balance in the universe is restored. Some cyclists also pass bikes on the left hand side, which is not only stupid but very dangerous. On the nice list of infractions, bikes using the pavement at moderate speed is equally bad for pedestrians and do not give the message that cyclists are responsible. Why? Because people are stupid.

The third type is the pedestrians. I hear the argument over and over again that pedestrians are endangered by cyclists as they cross the road. I can confirm that I have seen this on numerous occasions where cyclists were reckless when it comes to people crossing the road. But unfortunately, the same can be said of pedestrians, who are a danger to themselves and to the rest of the traffic. Considering how many never turn their head to check for incoming traffic, and how many look down at their mobiles rather than paying attention, they are quite hazardous in my view, those headless chickens should be cited by the guards.It is also worth mentioning that a fair few pedestrians do not give a shit about common sense and cross in front of you just out of defiance because you are supposed to be in control of your vehicle. I believe natural selection should apply here.

As most of you know, from the 1st of August, new laws have come into effect that allows guards to fine you on the spot for 40 euros per infraction. They are now able to sanction breaking red lights, cycling with no lights at night or cycling on pedestrian access. Garda have already announced blitz operations from the 1st of August. My problem with this is, it will probably catch a good few stupid cyclists, but what about the stupid drivers? According to this article, Garda does not seem concerned about stupid drivers, just stupid cyclists. This does not seem fair on any account, this is not an accurate way to deal with the issue.

It is quite clear Dublin is pro car biased, so I do not see this improving any time soon. Dublin is not a cycle friendly zone. The government likes to think that they have made the city as bike friendly as possible but unfortunately, until you split the cycle lanes and car lanes, this is unlikely to be resolved. And before you say that we cannot do it, I would encourage you to look at Amsterdam’s history, they made it happen. Given the fact that a fair few driving licenses were just given a few years back, this does not make for a very safe place. Dublin should still look into splitting lanes, at least stupid people will be commuting on the same lane with the same transport type.

A cyclist is much more vulnerable than a car, drivers be aware of that fact, it is quite easy to tip over a cyclist, due to speed and/or proximity. The only thing that we have to protect ourselves is a helmet, it protects only the head and not the rest of the body.

So until we actually have more solutions, stop being stupid.

Grafana 2 and Nginx

I have spent a bit more time tuning that setup so it works the way I want(tm). I have also decided that I no longer want to use the default graphite web UI but rather use grafana exclusively. The collector used here is Diamond. It has an extensive list of collectors to grab all the metrics.

First, start by setting up your graphite site in the backend, I allow it to be reachable only locally because Grafana will proxy the queries to it. So create /etc/nginx/sites-available/graphite and fill it with:

server {


  server_name  localhost;
  root   /opt/graphite/webapp/graphite;
  index index.html index.php

  access_log  /var/log/nginx/graphite.access.log;
  error_log  /var/log/nginx/graphite.error.log;

  location / {
                gzip off;
   include uwsgi_params;


You then need to install grafana where you see fit, in this example, I put it under /opt/grafana. Then create /etc/nginx/sites-available/grafana

server {

  listen 80;

  root   /var/www/html;
  index index.html index.php

  access_log  /var/log/nginx/grafana.access.log;
  error_log  /var/log/nginx/grafana.error.log;

  location / {
   proxy_pass http://localhost:3000;

You will of course still need to set up grafana, i will refer you to the official documentation.

Symlink the 2 sites under sites-enabled then restart nginx. Et voila !

Graphite and Nginx with uwsgi (2015 version)

A few years back, I wrote this tutorial to install Graphite with uwsgi on Debian. At the time, I used uwsgi 0.9.9 which has since evolved. My current Debian Jessie uses packages available from the system rather than having to use tarballs. It is now provided as version 2.0.7

Needless to say it has changed quite a bit. I have spent some time configuring it right and eventually got it. For posterity, here’s the config I now use, the rest of the configuration is still pretty much valid from the previous post.

Install the following packages: uwsgi uwsgi-core uwsgi-plugin-python
Create a file called graphite.ini in /etc/uwsgi/apps-available/ then copy the following into it, and symlink it to apps-enabled.

processes = 2
uid = www-data
gid = www-data
chdir = /opt/graphite/webapp
pythonpath = "['/opt/graphite/webapp'] + sys.path"
manage-script-name = true
mount = /graphite=/opt/graphite/conf/graphite.wsgi
socket =

Restart the uwsgi service and check the logs, they should get created in /var/log/uwsgi/app/graphite.log by default.

Upgrading your nexus phone the adb way

Because I got fed up with OTAs and I also play too much with my phone, I decided to load up factory images directly with ADB. This process does not wipe the data for me, as long as you are careful on what you wipe.

In order to do this, you need to have your bootloader unlocked, if you unlock it now, you will lose all your data.

Here goes:

# check that you see your phone
fastboot devices
# get latest image
# md5sum this shit
md5sum hammerhead-lmy47d-factory-6c1ad81e.tgz
# untar and get into it
tar xvf hammerhead-lmy47d-factory-6c1ad81e.tgz
cd hammerhead-lmy47d/
# unzip the different images
# flash all the shit
fastboot flash radio radio-hammerhead-m8974a-
fastboot flash system system.img
fastboot flash boot boot.img
# reboot in recovery and flush cache and dalvik
# reboot and let it upgrade, profit.

6 months later with Tado

I posted a review of the Tado back in March and thought I would re-visit it after over 6 months of using it.

I would like to start with an important disclaimer. Never assume that the wiring is right if you moved into a place and are not quite confident with electricity. Back then I based my wiring on the existing one that was done for the timer. Turns out that it was incorrect. This is why when in summer time, Tado brought the water schedule functionality, it did not work for me. A friend came by to look at the wiring and figured out what was wrong. Thinking back, I got quite lucky that i managed to get the heating working. So long story short, a second set of eyes that actually understand electricity: good! Thanks Glen :)

Tado got out a new model with display now, which is not the model I have, just in case you stepped on this from a search and wonder what is coming next.

Tado completely rewrote the web interface and also the phone apps. I got to say, it is very welcome as the previous web interface was a bit clunky. The phone app was also in need of cleanup, just for speed alone. I am glad to report all additions actually helped.

Re-visiting what I think of the Tado, it has been a very good investment. Now that the wiring is fixed, I have thermostat as before but also water schedule when i want to, this is really cool for when the warm days will come back. I have advised a few friends to go for Tado and as far as I know, no one has been disappointed yet. Disclaimer: I am not paid by Tado to write this, I am just very enthusiastic about this device.

Importing sqlite3 to MySQL in a semi non painful way.

The example I will give below should work for most data. I needed to import dashboards for graphite in sqlite3 format to MySQL which is our now standard backend. This is the rough steps I used.

Get that file from /opt/graphite/storage/graphite.db then dump it like it is 1982:

sqlite3 graphite.db
sqlite> .output graphite.sql
sqlite> .dump dashboard_dashboard

Grab that wonderful python script. I am copy/pasting it here just in case in disappears.

#! /usr/bin/env python

import sys

def main():
    print "SET sql_mode='NO_BACKSLASH_ESCAPES';"
    lines =
    for line in lines:

def processLine(line):
    if (
        line.startswith("PRAGMA") or
        line.startswith("BEGIN TRANSACTION;") or
        line.startswith("COMMIT;") or
        line.startswith("DELETE FROM sqlite_sequence;") or
        line.startswith("INSERT INTO \"sqlite_sequence\"")
    line = line.replace("AUTOINCREMENT", "AUTO_INCREMENT")
    line = line.replace("DEFAULT 't'", "DEFAULT '1'")
    line = line.replace("DEFAULT 'f'", "DEFAULT '0'")
    line = line.replace(",'t'", ",'1'")
    line = line.replace(",'f'", ",'0'")
    in_string = False
    newLine = ''
    for c in line:
        if not in_string:
            if c == "'":
                in_string = True
            elif c == '"':
                newLine = newLine + '`'
        elif c == "'":
            in_string = False
        newLine = newLine + c
    print newLine

if __name__ == "__main__":

Rename it something like then execute the following:

cat graphite.sql | python > graphite-mysql.sql

I would advise you add a few statements at the beginning and the end like:

USE graphite; 

All you need to do now is to dump it back to MySQL like this:

mysql < graphite-mysql.sql

You should now have a full DB of dashboards in MySQL format.

Docker on Debian Wheezy

I recently got to play with Docker at work and thought, what would it take to get that running on a Debian stable system like Wheezy. In short, surprisingly little if you are not afraid to install a more recent, less tested kernel.

So I guess, let’s start and see what is involved. I decided to follow this Ubuntu installation guide directly from Docker. Due to a bug in Docker, kernel 3.8 or above is advised, so I installed the Debian backports repo. To do so, edit /etc/apt/sources.list and add:

# backports for new kernel
deb wheezy-backports main non-free contrib
# Docker Repo
deb docker main 

Then install the newer kernel by doing:

apt-get update
# needed for the Docker repo
apt-get install apt-transport-https
# key for that repo
apt-key adv --keyserver hkp:// --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# install new kernel
apt-get -t wheezy-backports install linux-image-amd64 linux-headers-amd64
reboot # last step will reboot your box but you guessed it

Once you have rebooted, check your kernel version to make sure you rebooted on the right one. Then it is time to install the Docker repo and install the software. We edited the repo before and added the key for Docker, so all that remains to be done is:

apt-get install lxc-docker

At this point, you should see the Docker service starting by itself and have a working docker host ready to install all the wonders in the world. You can do a quick check by typing:

# docker version
Client version: 1.1.1
Client API version: 1.13
Go version (client): go1.2.1
Git commit (client): bd609d2
Server version: 1.1.1
Server API version: 1.13
Go version (server): go1.2.1
Git commit (server): bd609d2

If you need convincing on what Docker can do for you, head to their official documentation to get started. I would also suggest you take 10 minutes to look at Docker at Spotify

Enabling HDMI sound on an ion2 motherboard for XBMC

A friend of mine gave me a nice home made HTPC. I had forgotten the joy of setting up sound and video on Linux. I ended up installing Ubuntu 14.04 LTS with the latest XBMC 13.0 but the part that really was troublesome was to get the sound working.

Turns out PulseAudio tries to be too clever about this, it detected the wrong output. I eventually found a solution on this thread.

In short, edit /etc/pulse/ and added this line:

load-module module-alsa-sink device=hw:1,7

Of course, this will depend on your device, to see what you have, do aplay -l

Installing Skyline to monitor graphite

I had heard of that project a while back and was curious to give it a go, with this weekend, I ended up having a bit of time to test this. Skyline is a project created by etsy which is designed to monitor automatically graphs and detect anomalies.

I would have normally used a CentOS 6 installation to test this but it turns out that the requirements are actually quite important in terms of dependencies. You will need fairly recent versions of packages to make this work. This is why I ended up using Ubuntu (14.04 LTS at the time of writing).

You can choose to use pip in order to install dependencies but I preferred to use the distribution’s packages instead. If that works for you, here’s what you need to install:

apt-get install python-numpy python-scipy python-pandas \
python-patsy python-statsmodels python-msgpack \
python-unittest2 python-mock python-simplejson \
python-hiredis redis-server python-daemon python-flask

Next, you need the latest version of skyline, you will need git installed for this, you can just do:

apt-get install git-core 
cd /opt
git clone
cd skyline
cp src/ src/
cp src/redis.conf /etc/redis/ # copying redis skyline config
mkdir /var/log/skyline /var/dump /var/run/skyline
chown -R redis /var/lib/redis/ 
service redis-server restart # important

You will need to modify the port and address if like me you are not using the same machine, then you can start the daemons. There is two things I fell into when i started them: first, make sure your host has its correct name and ip in /etc/hosts, horizon will get upset if you don’t. Second, also make sure that in the you will have to replace by if you want to be able to connect to the webapp outside of your machine. Last but not least, change the value of the http interface to point to your graphite instance, failing this, not much analysis can happen. Also note that you have to run the web interface on port 80, using anything different will fail.

Time to start it all:

cd /opt/skyline
bin/horizon.d start
bin/analyzer.d start
bin/webapp.d start

If at any point starting these daemons you have an issue, you are on your own, use the logs. I have included in the commands above all the issues I had, so you should be alright starting all the daemons.

You will need to direct your graphite metrics to a relay for duplication, this is nicely explained here.

You can also do a check to make sure it’s all good, luckily for you, the project includes a little utility to test this.

/opt/skyline# python utils/
Loading data over UDP via Horizon...
Connecting to Redis...
Congratulations! The data made it in. 
The Horizon pipeline seems to be working.

Installing Suricata 2.0 on Debian with JSON support

A few months ago, I wrote a blog entry worth reading if you lack context on installing Suricata on Debian with banyard and syslog support. During my original research, Suricata 2.0 was under development but has since been released. What is very interesting about this is its JSON support.

I am using Debian Wheezy but I did not want to install from sources nor upgrade to sid. So I ended up recompiling libhtp1 and suricata 2.0 for wheezy, which you can now download right here:

These packages have been compiled on my own wheezy server with latest patches installed. I have also installed libjansson4 and compiled suricata 2.0 with JSON support (Debian suricata on wheezy disables JSON support by default).

It will then allow you to output JSON directly to a file, I advise you to take a look at that link on Logstash Kibana and Suricata JSON output if you need more information on how to enable this with your logstash/kibana installation.

You can install some nice dashboards for suricata to use in Kibana, I have been using these ones lately.

I will write a bit later on tidying your alerts.