API versioning and deployment (a different point of view)

I’m quite new to the backend world so what I’m about to describe to you might be total blasphemy or quite trivial. Either way, I came up with this simple setup after a series of “Because that’s just how you do it” answers that didn’t please me as I’ve got quite a curious nature and nobody managed to satisfy my curiosity.

At work, in order to plunge me into the world of backend developers, I’ve been assigned a simple app. Got my tables, need to setup CRUD apis and so on. At a certain point I release my work for the frontend and mobile devs to test. They came back to me saying: “We need you to add versioning to your apis”. No problem for me, it sounds quite logical after all being able to support an older version whilst releasing a new set of APIs.

So, not being accustomed to the backend developer world and uses, I ask: “How do you guys do that?”. What I got as a response triggered me and made my skin crawl: “Just copy/paste the old code and make new routes for the new version”

I’ll let you guys read that last answer one more time…


Nice. So here I am, a C++ dev trying to get the hang of things in the backend world and these guys are telling me that duplicating code is actually a procedure that’s accepted.. At first I thought they were pulling my leg, but as I kept asking how they intended to deploy this I realized that they weren’t joking at all.

So basically, this is what backend developers do in order to support old apis:

|- v1/
|- myapi.js
|- v2/
|- myapi.js

I don’t know you guys, but that’s ugly as hell to me. I kept on asking “WHY” this procedure and duplication of code was the “common” procedure and I kept on getting a “Because it’s like that” answer.

Well, as a fan of docker that I am, it took me 10 minutes to demonstrate that their method was caveman-like and that I could obtain the same effect without code duplication.

How I did it

Basically what I did was, of course, dockerize my application (that’s basically the first thing I did when I setup the project). So now, I can have different working versions of my code in ready-to-use containers.

Let’s say I have myapp:v1 container and myapp:v2 container. This is already the first step into having tow different API versions. As the names states, v1 has /v1/:apis and v2 has /v2/:apis. Now both the containers in order to run together, need different ports to comunicate on and this is a problem for clients as they don’t want to go chaning their ports when calling my apis. In order to come over this problem I use nginx and the pretty cool feature proxy_pass. You should already know where I’m going here.

With a simple nginx setup I now have my two versions of the API running on the same server in different containers and both talking through port 80 (or whatever port you decide to setup for nginx).

NOTE: of course you’ll need to launch your containers and set them up to use different ports and be available on the system

server {
listen 80;
server_name localhost;

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

location /v2 {
proxy_pass http://localhost:3001;

This way I have my git repo correctly branched according to the various releases and no code duplication. I find this method to be tidy and simple.

So, how’s that instead of duplicating code to allow legacy apis to live?

Tagged , , , , , ,

Recursive lambda functions

Today i found out how to use lambda functions in a recursive manner. Documentation from std::function states:

Instances of std::function can store, copy, and invoke any callable target — functions, lambda expressions, bind expressions, or other function objects.

It can’t get easier than that!
So here’s an example taken from some code I had to do which uses lambda functions recursivly to delete contents on a device.

#include <functional>

void MtpDevice::deleteSelectedFiles()
    QStringList objectsToDelete;

    std::function<void(ContentObject*)> addChildren;
    addChildren = [&addChildren, &objectsToDelete] (ContentObject *obj) -> void {
        if (obj->type() == ContentObject::FOLDER) {
            for (ContentObject *child : obj->children()) {
                if (child->type() == ContentObject::FOLDER) {
                } else {
                    if (!objectsToDelete.contains(child->id())) {
        } else {

    for (ContentObject *contentObj : d->contentObjects.values()) {
        if (contentObj->isSelected()) {

    for (const QString &objId : objectsToDelete) {
Tagged ,

Error Loading Kernel Modules – aka “check your config files!!!1!1!!ONE”

This one’s a simple post to remind all of you out there to always check your
config/settings files and be sure you don’t add junk to them.

So, to my (solved) problem.

I started noticing one day, after a few kernel updates, that my laptop wasn’t
detecting acpi events anymore (battery, leds on keyboard, screen luminosity). I
immediatly blamed it on the kernel as I’ve already had similar problems like this in the past with my old Acer 5930g.

So I said to myself: “ok, let’s just wait for an update”.
Many updates passed and still I was having the same issues until tonight.
Bored, I decided to investigate the problem and get down to the bottom of it.

I started off with checking out all errors in the logs when I came across

Feb 2 22:32:09 localhost systemd-modules-load[159]: Failed to

insert ‘vboxguest’: No such device
Feb 2 22:32:09 localhost systemd-modules-load[159]: Failed to insert
‘vboxsf’: No such device
Feb 2 22:32:11 localhost [ 2.313395] systemd[1]: Failed to start Load Kernel

Hmm, strange. I didn’t remember adding those there. A check on the file “/etc/modules-load.d/virtualbox.conf” showed that they were actually there, so I just simply removed them from the file leaving only the “vboxdrv” module to be loaded.

I rebooted, et voilà: problem solved!

So yeah, failing to load 1 kernel module make all others fail too.

Now my

systemctl status systemd-modules-load.service


systemd-modules-load.service – Load Kernel Modules
Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service;
Active: active (exited) since Sat 2013-02-02 23:10:21 CET; 3min 35s
Docs: man:systemd-modules-load.service(8)
Process: 173 ExecStart=/usr/lib/systemd/systemd-modules-load
(code=exited, status=0/SUCCESS)

Hell yeah! \o/


Tagged , , , , ,

Multitouch fix for Alps touchpad

This summer I bought a new laptop, a Dell Vostro 3460. First thing I did was install arch linux.
Nothing wrong with it except one little annoying thing: multitouch was not correctly detected and the synaptics driver was not correctly loaded.
Luckily via the Arch linux forums a solution was found.

I’ll quote the procedure:

  • download latest alps source code from here (in case the page goes in 404 i have a stashed copy here)
  • unpack it and substitute the “alps.c” with this one (stashed version here)
  • copy the psmouse-alps-dst-0.x folder to your /usr/src directory
  • (as root) dkms add psmouse/alps-dst-0.x
  • (as root) dkms autoinstall
  • (as root) rmmod psmouse && modprobe psmouse

and multitouch should start working out of the box! Have fun!

(Thanks to user “post-factum” for the solution)

Tagged , , , , , , ,

Getting my swap back

Lately my pc was slowing down when using KDevelop and Chromium together and completely froze when I launched amarok as well.
Something was up but I couldn’t quite figure what it was. I kept on thinking that it was my laptop (an acer 5930g – yes, the one that still suffers from the acpi bug from kernel 2.3 2.6.3   ) until I noticed in my htop that my swap was 0/0MB.
Quite odd indeed..
I don’t know what caused it to be like that but in the end I solved the problem with
a few lines from my konsole.
Here’s the solution:

swapoff -a
mkswap /dev/your-swap-partition
swapon -a

et voilà! your swap partition will be restored! Plus, no more slow downs on my pc when developing! \o/

A little update

Hi folks!
Just wanted to give you lot a quick update on how things are going with KDE-Telepathy.
One word: GREAT!
Today I finished implementing the global presence setting for the presence applet and a patch is in review for the contactlist.
We’ve also decided to switch to haze msn instead of butterfly. The main reason for this change is that butterfly does not support the SASLChannel, which means it cannot use kwallet (plus it was a bit buggy).
As David said in his previous blog post we’ve also got a cool drag ‘n’ drop feature from the contact list to the kde-plasma desktop! \o/
We’ve entered the hard feature freeze and now we’ll be polishing things up.
So help us do a good job by testing our software and reporting bugs so that we can assure you a good user experience!

Tagged ,

Woshibon spot the difference

Hi all!
A quick post to let you guys have a bit of fun. Let’s play spot the difference!
Can you find the differences between these two photo’s shown below? They differ by a year.
The subjects to look for are: grundelborg, d_ed, drdanz, drf_ and andrunko. You should be able to spot them quite easily 😉

kde-tp sprint 1

kde-tp Woshibon sprint 2

Tagged , , ,

Woshibo (Telepathy sprint) audio call

My aim for the woshibo sprint (kde-telepathy sprint) is to get something going for audio/video calls in kde-telepathy.
The sprint started off well. We discussed a lot about how the project is to evolve and sorted out the problems we currently have

woshibo whiteboard

This afternoon I was depressed because I was having problems on my pc that NOBODY else was but in the end I managed to sort things out after bugging a Collabora guy and George K. (which I thank for not having killed
me for asking him 1.000.000 questions).
So in the end I managed to call George K on his n900 with my pc and listen to him speak 🙂
So that’s a +1 for kde-tp!

Just to let you guys know what’s currently going on:

mck182 – currently working on the “now playing” plugin
shocklaterboy92 – currently working on a new plugin system for kde-tp-chat
domme – telepathy kde logging
d_ed – furious bug fixing and kwallet integration
drdanz – auth handler + file transfer awesomeness
gkiaga – mental farsight fixing
grundelborg & drf – talking about stuff out of my league that I can’t comprehend. So it’s gonna be awesome 😉
me – telepathy-kde-call-ui

So as you see, we’re all quite busy here.
Stay tuned for more news on the Woshibo sprint!

Tagged , , , ,

Telepathy Contact Applet Goes Public!

As promised, I bring you KDE-Telepathy-Contacts!
The KDE sysadmins have kindly accepted my kde repo request and now my plasmoid is in the Telepathy playground.

Before I release version 0.1 I need to wait for reviewboard to be set up and do some final checks on my code with the help of my kde-telepathy colleagues.

If you can’t wait for the release (should be in just a few daysthis will be discussed at our sprint) you can checkout the git repo git clone http://anongit.kde.org/telepathy-contact-applet and build from source.

Have fun! 🙂

Tagged , , , ,

I bring you KDE-Telepathy contacts!

Hello all!
Cool thing happened today, I finished the Contact plasmoid for KDE-Telepathy! Yaaaaay!
This plasmoid is a simple 128×128 plasmoid that sits on your desktop and let’s you keep your favorite contact (or contacts if you have many friends) always at hand.
The contact presence status is displayed by a coloured frame on the outside. If you click on the plasmoid you’ll get a drop down menu with the possible/available actions you can use with that contact according
to your kde-telepathy capabilities and the ones of the selected contact.
I started off using the ktelepathy library nepomuk model for this plasmoid but ran into some problems halfway through so I had to fallback to the telepathy model (model we use in our contactlist component).
But no worries, we kde-telepathy devs have a sprint coming soon (September) where we will discuss problems and the future of the project and solve annoying issues.
I really believe in the integration of KDE apps data into nepomuk so don’t worry, we’ll get there.
Until my plasmoid goes public you can take a look at this nice video I hope you all will appreciate.


Tagged , , ,