Enfin comprendre le programme des candidats, grace à des bots sur Twitter

Toi même tu sais, cette période électorale pré-présidentielle-2017 est un plaisir quotidien. J’ai eu le malheur de vouloir m’intéresser aux candidats via Twitter et ça m’a rappelé la superbe vidéo de Franck Lepage qu’un copain a eu le bon goût de me partager. Voulant être de bon goût, je te la partage à mon tour:

Les bots Twitters étant apparemment un passe-temps dont j’ai du mal à me défaire (Je prends quasi l’entière responsabilité de la création de ces bots : @PassionSirene, @PassionTocsin, @PassionMouton, @pdesproges), je me suis dit qu’il manquait dans ce monde les pendants algorithmiques des candidats à la présidentielle. Sauf une, pour certaines raisons. Les voici, dans le désordre:

Et le compte meta: @2017_ebooks qui RT chaque tweete, de chaque compte.

Un  peu comme un débat sur TF1, je ne les ai pas tous inclus (car je te l’avoue, la Flemme c’est comme la Force, c’est puissant). Petit florilège:

Alors voilà, on clone les hommes politiques, on injecte leurs paroles publiques dans des robots, et un algorithme génère des phrases surréalistes.

Qu’est-ce qu’on apprend ?

Je ne sais pas trop, mais en tout cas, je me marre bien !

Un palindrome musical, inspiré par le cosmos

Je suis tombé le week-end dernier sur ce bijou musical.

Dans cette vidéo, Daniel Starr-Tambor (portant fièrement un joli combo barbe-casquette) dévoile une création unique : le palindrome musical le plus long du monde. Oui oui. Grace à un tour de passe-passe solfégique (dont je t’avoue ne rien maitriser), il assigne à chaque planète une note de musique différente.

Mercure sera la note Si.

Pluton sera un Do# à 2 octaves et des poussières plus haut.

(Entre les deux, regarde la partition au milieu de la vidéo).

S’ensuit une autre preuve que ce garçon est plutôt malin.

Il calcule mathématiquement la fréquence de répétition de chaque note grace à une équation de son cru: période orbitale de la planète * 15779059,2 = fréquence de répétition. (oui monsieur).

L’alignement musicalo-planétaire  finissant par arriver (en tout cas je lui fais confiance), la pièce se transforme en palindrome.

Magnifique, je te dis !

2014, my retrospective in music

Last year, I started what I would like to become a personal tradition. I
decided to create a playlist that would describe my prominent emotions of the
year that just passed. The creative process would be a way for me to look back
at the year, both emotionaly and musically. I was afraid though that it would
be an endless process and that I would end up putting up an endless collection
of tracks without any meaning. I needed some limitations.

I always liked the length limitation of vinyls. Back in the days, album were
also designed with that limit in mind and you could really feel how it
influenced the construction of the album. The original LP
had a maximum playing time of
nearly 45 minutes, or 22 minutes by side. I decided to take this restriction
and to add another one: Only 4 tracks by side.

These constaints gave me a framework which enabled me to focus myself on the
most important phases I went through during the year. I added a soft constraint
as well: Tracks should be the one I listened to during this year.

Without further ado, here is my 2014 retrospective.

2014 retrospective: “Mont-Royal LP”

Side 1:

  • Pachanga Boys – Black Naga (Hippie Dance)
  • Flore – Numen (POLAAR)
  • Suuns – Music won’t save you (Secretly Canadian)
  • Kool & The Gang – Summer Madness (Polygram)

Side 2:

  • Flore – Random (POLAAR)
  • Parquet Courts – Ducking & Dodging (What’s Your Rupture?)
  • Run The Jewels – Love Again (Akinyele Back) (feat. Gangsta Boo) (Mass Appeal)
  • The Beatles – Tomorrow Never Knows (Parlophone)

The 2013 retrospective is still available on

2014’s inspirations

Well the year isn’t over yet but I wanted to write down what inspired me in the past 12 months. Like you, I’m always looking around for interesting work to nourish my mind. Sign of times, I haven’t read many books. It’s been mostly an audio/video year. I watched a hell lot of TV though. Netflix doesn’t help in that matter… I’ve had a huge interest in comedy. I discovered the american alt-comedy scene and have been struck by their creativity and blunt thoughts.

Stand-Up specials

TV Shows

Once again, comedy was a central theme in my choices. I stopped watching other
shows that I won’t name here.


I watched other great movies than those present in this list, but I prefer to
keep it short.



This year was really interesting on the music side. I started buying vinyls
again and went back to my turntables. I discovered really good house and techno
tracks, but in the end I prefer to list these indie bands.

Club Night

Laurent Garnier at Stereo Night Club in Montreal. This club has the best sound system. Period. Forget the clinical coldness of a Funktion One system. This one has a warm and beautiful
sound. Laurent Garnier did a good set, sticking perfectly to the club’s atmosphere.


I haven’t read much. Or not as much as I’d like. Or maybe too much. My whole days are spent reading stuff. Be it code, articles, emails, social medias. At the end of the day, I much prefer watching and listening than reading


Does this post need a conclusion? Naaah. You’ll do fine without.

In the last 24 months

The last time I wrote something here was in 2012. What happened since then?
It’s been quite a ride actually. I lived in 3 different cities on two continents and had some realizations on the way I want to work and the importance it had on my life.

If you (still) follow me on twitter, you might have seen some changes. I’m tweeting more and more in French and less and less about technologies. It didn’t went unnoticed to @clochix and he asked me what I was doing and if there was a chance that I could wrote about that somewhere.

In the last 24 months, I left Paris and lived in Montreal, Berlin and now Amsterdam. I met a whole bunch of people, made new friends along the way and basically hadn’t too much to worry about because as I often say to people I meet “when you’re a developer, you can basically work from anywhere”. The freedom you get by doing that has its obvious drawbacks, but the upsides are really fun.

In the last 24 months, my views on work changed as well. As I was reading on autonomy and independence, I realized that being an employee was unsatisfying to me. It has its good sides but it was mostly frustrating in the end. I decided to become a freelancer. Who doesn’t need some php/symfony2/golang expertise in this world right now? Of course, there’s more to that: I wanted to
create something from my hands and my brain. This is something incredibly hard to do when you’re in an office for 5 days a week and that you also happen to enjoy your evenings and your weekends. Freelancing gives me the possibility to balance my workload between my clients and my projects. With freelancing, I can confront my classic gen-x/gen-y developer bullshit to the real world. And I can’t really tell you how good it is. In times where offices are transformed into playgrounds and that your company is paying for your breakfasts and your friday booze, trying to accomplish something by yourself can be seen as mad. Why would you refuse all these privileges? I don’t really know, but I just had to the feeling that I should do it.

In the last 24 months, I must admit I lost interest in the IT industry. I could state a lot of reasons for that but it would raise endless debates because none of us would be right or wrong. The fact is that I can get bored quickly when things look and act the same. This industry has bored me. I’ll get more involved again when the monoculture is less strong.

I tried to build (alone) different products but somehow always failed developing them past a certain point. This is something utterly frustrating.

Luckily during the Symfony Live 2013 in Berlin, I had the chance to have a few conversations with Dustin Whittle, Fabien
and Francois Zaninotto who gave me really good advices: “Don’t create a business alone”, “It’s harder than you think, but rewarding”, “Think of the future of your product and how it will evolve”, and “expose your projects to like-minded people”.

Now the funny thing in life is that if you give room for surprises to happen, they might actually do. At the beginning of the year, a conversation with my good friend Flore led to something like that (jokes, usual stupidity and facebook stickers removed for clarity).

  • Her: “I think I want to start a record label, but it’s tough”
  • Me: “I never told you that but I have this idea in my mind since quite a while now.”
  • Her: “Well it would be fun to do that together. We should think about that maybe…”
  • Me: “Yeah, let’s think about it”

A few weeks later, it was on. We were creating a record label. This is a new adventure and even if I’m clearly out of my comfort zone, I enjoy it more and more. Music is my passion
and I’m glad I can see tech not as an end, but as a mean. I often asked myself who would create a time-consuming small business in the worst industry to do business at this time? The only answer I got is “Maybe the same guy who doesn’t like his office to look like a playground.”

Why I Stopped self-hosting my mails, IM and website

A year ago, I started an experiment. I wanted to quit gmail and gtalk services
and prove me that I could host my emails and my IM myself. It went quite well
but I decided to stop and subscribed to and


A year ago, I spent some days installing a fully functionnal mail/web/jabber
server. Hopefully, I had some good tutorials
about setting up a mail server. On the jabber side, it was quite easy even if
sometime, my WTF-o-meter level was really high. I blame my totally absent
knowledge of erlang and mnesia here.

The easiest part was to set-up varnish and nginx on the server. This is
because I use these technologies every day. I still think that serving static
files with a reverse proxy could be much more easier and quicker to setup.

Backuping is easy and cheap, thanks to Amazon S3. I did not suffer any crash
and did not have to restore my data. I think I would have cried if I had to do
that because of the time needed to set-up the server again. The pain would
have been bearable thanks to the EBS (if it doesn’t fail).

My final set-up used these technologies: Amazon EC2, Amazon S3, Amazon
CloudFront, Amazon Elastic Block Storage, Postfix, Dovecot, Sieve, Varnish,
Postgrey, Spamassassin, Nginx and Ejabberd.

Running it

Here is what I learned:

  • SMTP servers obey Murphy’s Law. If you have an important mail to send, it
    will fail. Fallbacking to gmail happened too many time.

  • ejabberd is stable. In a year of operation, it failed once and restarting
    it made did the trick. The guys behind
    did a really great job.

  • Spam was virtually absent from my mail. Spamassasin and postgrey worked

  • Sieve
    is great. I mean really really GREAT. Filtering mail in gmail is a pain.

  • Mail clients all suck. Sparrow was an exception.

  • I’m not nerdy enough to use Mutt.

  • I should have used a configuration management system like Chef, Puppet or
    CFEngine to create the server. It would have doubled/tripled the time
    required to configure it properly, but it would have been an asset if I
    wanted to migrate my services to another host, which I considered at some


Yesterday, and after too many problem with my SMTP server, I decided to end
this experiment and started looking for a reliable mail provider. I chose because of the price, migrations processes and the Sieve support.

This website is now hosted by Amazon S3. The only cron job that I had is now
run on heroku. My jabber service is being migrated to

This will costs me around 50$ a year and this is definitely worth the time I
won’t put in managing a server.

Creating, installing and configuring software is easy. Achieving reliability is

Authenticated Cross-Domains AJAX Requests with CORS

Yesterday, I lost a significant amount of time dealing with cross-domain
AJAX requests and I thought I might share a bit of what I learned.

  1. jQuery 1.5.0 is BROKEN when it comes to cross-domain AJAX requests.
    Upgrade to at least jQuery 1.5.1.

  2. Access-Control-Allow-Origin WON’T accept a wildcard value if your
    XHR’s withCredentials option is set to true. Also, it won’t
    accept a list of origin. If you want to accept requests from a lot
    of domains, you can match the Origin request header against a set
    of domains and set the Access-Control-Allow-Origin accordingly.

  3. Access-Control-Allow-Headers and Access-Control-Allow-Methods
    CORS header does not support * as a value. You have to be specific,
    even during your prototyping phase.

Hope it helps.

Serving a maintenance page with varnish

Yesterday during the SOPA Blackout, this website was on strike. The
billions of readers of this blog had a static page explaining why this
website was offline instead of the normal content. As a good nerd, I
turned this operation into a technological one and instead of serving a
static html with nginx, I decided to use
varnish. Yes, varnish. I never wrote
anything about the absolutely amazing architecture of this blog but
basically, static files are generated from
RestructuredText, served by
nginx and cached by varnish. Let’s get back to the
point. I wanted varnish to serve a static page with a 503 status code
(for SEO purpose). It took a bit of VCL knowledge and here is how to do

“` text /etc/varnish/maintenance.vcl
backend default {
.host = “”;
.port = “8080”;

sub vcl_recv {
error 503;

sub vcl_error {
set obj.http.Content-Type = “text/html; charset=utf-8”;
# you can put absolutely what you want
synthetic {“
My maintenance page
<h1>This website is under maintenance.</h1>
return (deliver);

The trick here is the `synthetic` keyword which is described in the
varnish documentation like this:

> The synthetic keyword is used to produce a synthetic response body in
> `vcl_error`. It takes a single string as argument.

Now that you have a cool VCL for your maintenance page, you can load
this vcl in varnish like this:

``` bash
varnishadm -T -S /etc/varnish/secret "vcl.load maintenance /etc/varnish/maintenance.vcl"

and to replace the original rules by those described in maintenance.vcl

varnishadm -T -S /etc/varnish/secret "vcl.use maintenance"

And varnish will serve the maintenance page. Like a boss.

Feature flags with Symfony2

Feature flags is a really common design in modern web applications and is heavily used by startups. It permits you to enable/disable features for some users or groups of users. It’s really handy if you want to deploy to production a feature for testing purpose in order to have data on how your infrastructure reacts in a live environment.

Let’s have some fun and try to implements a simple feature flags design in your Symfony2 project without writing too much lines of PHP. Sure, we will use the as complex as powerful Security component for that. I won’t dig deep inside it, so you’ll better be well versed about roles and roles hierarchy.

What we want for this project is three types of feature groups: ‘alpha’, ‘beta’ and ‘prod’. I want the admins of my website to have access to the alpha/unstable features, the beta testing group to the beta features and all the oser users to all the rest of my application.

We can express this by using role hierarchy:



Thus, anyone whom is granted the FEATURE_ALPHA role will have access to all
the features and the other groups won’t have access to the “lower” features.

This is a rad way of defining who have access to what, but currently,
it’s not supported by the SecurityBundle because only roles prefixed by
ROLE_ are supported by the current voter.

So, we need to define a new voter that supports the newly created FEATURE_*
roles. Is it complicated? Hell no. Add this to your bundle xml configuration:

“` xml Acme/Bundle/AwesomeBundle/Resources/config/config.xml


This simple piece of xml will register a new voter based on the actual role
hierarchy. The difference is that this voter will be specialised in the
`FEATURE_` prefixed roles.

Now, we need to specify in our user class how the roles will be distributed:

``` php
// You can implement your own logic there, be inventive.
public function getRoles()
    if ($this->isAdmin) {
        return array('ROLE_ADMIN', 'FEATURE_ALPHA');

    if ($this->isBetaTester) {
        return array('ROLE_ADMIN', 'FEATURE_BETA');

    return array('ROLE_USER', 'FEATURE_PROD');

From now on, the user class will be able to tell wich roles he has, and the
Security context will be able to vote on them. The only thing left to do is to
“secure” parts of your application.

In your templates:

    {# bla bla bla #}
{% endif %}

or in your controllers:

public function indexAction()
    if ($this->get('security.context')->isGranted('FEATURE_SUPER_SECRET')) {
        // do stuff

or your routes thanks to the built-in firewall:

yaml app/config/security.yml
path: ^/my/route/to/my/feature.*$

Here we are! You enabled feature flags in your project with a few lines of PHP
and 5 lines of XML. Have fun!

Back from SfDay 2011 Cologne

I’m now back to my daily work at SensioLabs after some days spent at Cologne, mostly for the Symfony Day 2011. It was truly great to be there. I had the chance to put faces on twitter nicknames and to talk in front of the crowd. I was a bit nervous and wasn’t as relaxed as I would liked to be. I will try to work on my english pronunciation for the next times.

Many thanks to the SensioLabs Deutschland & Interlution team, it was really a nice moment.

Oh, and here are the slides of my talk.

I assure you, it’s open

Kids. Backuping your data is great. But assure you that your backups
also contain your database. I’ve lost all the posts of this blogs and
much more. Nothing to say that I was really pissed off.

I wanted to recreate this blog from scratch but got distract by other
things. After a few months of procrastinating and slapping myself for
not having a place to write, I found a great theme based on twitter
bootstrap for wordpress and decided to give it a go. I’m pretty happy
with that.

Let’s hope I’ll have the strength to write some interesting articles.

Oh, I’m currently concerned by twitter/facebook tracking on the web and
won’t add “tweet this” or “like” button but I will, for now, conserve
the Google analytics tracking script and the feedburner thingy.

P.S : The picture and the post’s title come from the awesome
Clerks and Clerks
movies. If you haven’t seen
them, it’s never too late.

Semantic Coding?

Don’t worry. Semantic coding is not a new concept. Actually, you’re
already doing it each time you code. At least, I hope for you and your
teammates. The principle of semantic coding is simple and is a great
part of what we all name “code readability”.

Look at those 2 pieces of code:

class A
    public function A($a, $b)
        return $a + $b;

    public function B($a, $b)
        return $a - $b;

    public function C($a, $b)
        return $a / $b;

    public function D($a, $b)
        return $a * $b;

This is not semantic code.

class Calculator
    public function Add($a, $b)
        return $a + $b;

    public function Substract($a, $b)
        return $a - $b;

    public function Divide($a, $b)
        return $a / $b;

    public function Multiply($a, $b)
        return $a * $b;

This is semantic code.

The difference between the two is that the second example class and
method names carry a meaning. When reading the code, you don’t have to
remember what the ‘Add’ method does because it’s clearly indicated
within its name.

In the first example, you have to remember which method name does what.
In the second example, what the method does is its name. It’s a major

Speaking in cognitive terms. Writing code should be a high cognitive
effort in order for the reading process to be a low cognitive effort.

Don’t forget that code is often read 100x time more that it’s written!

Now let’s apply semantic coding principle to exceptions!

Too much sfException is bad for the health

The use of sfException is a commong thing among all symfony projects’
code I have the chance to read. While it’s harmless to use it from time
to time, I think that using nearly only sfException in your code is like
using $a, $b or $c as unique variable name.

What is sfException?

As the sfException phpDoc says: > sfException is the base class for all
symfony related exceptions and provides an additional method for
printing up a detailed view of an exception.

If you look at the code of
sfException you’ll see that sfException has a bunch of tool to wrap an exception
inside an sfException. That’s why when an exception of any kind is
thrown in symfony, you see a nice html output.

In a symfony application, every thrown exception that bubbles up is
eventually catched in the sfFrontWebController
class. Then this exception is wrapped into an sfException one and is
displayed to the user.

The catching mechanism

     // application running…
 catch (sfException $e)
 catch (Exception $e)

The wrapping mechanism

static public function createFromException(Exception $e)
    $exception = new sfException(sprintf('Wrapped %s: %s', get_class($e), $e->getMessage()));
    self::$lastException = $e;

    return $exception;

As you can see, sfException was created mainly to display a nice debug
trace and not to replace ALL exceptions! Don’t worry to throw other
exception php provides, there’s always be a nice debug trace! 😉

PHP provides a lot of different exceptions

PHP provides 2 predefined exceptions known as Exception and

Exception is the base class from where all other exceptions inherit
from. ErrorException can be used when you want that PHP throws exception
instead of reporting errors. For more information about ErrorException,
you can read the dedicated

The Standard PHP Library (SPL) provides 13 more
. These exceptions

Each of these exception have a name that provide information on what the
problem is which is pretty useful.

Now let’s use those exceptions and see how they improve the global
readability (and scanability) of your code.

Semantic exceptions

Let’s read those two pieces of code.

This one with the uncool sfException everywhere:

class Container
        $maxItemCount = 2,
        $container = array();

    public function addItem($item)
        if (count($this->container) < $this->maxItemCount)
            $this->container[] = $item;
            throw new sfException('Cryptic long message saying container is full');

    public function sliceItem()
        if (empty($this->container))
            throw new sfException('Cryptic long message saying container is empty');


And the cool one with semantic exceptions:

class Container
        $maxItemCount = 2,
        $container = array();

    public function addItem($item)
        if (count($container) < $this->maxItemCount)
            $container[] = $item;
            throw new OverflowException('Cryptic long message saying container is full');

    public function sliceItem()
        if (empty($container))
            throw new UnderflowException('Cryptic long message saying container is empty');


In the second example, you don’t have to read the message to know what
it’s all about. The name is sufficient. Furthermore, you’ll get more
informations while scanning the code with correct exceptions name than
with sfException everywhere.

More significative code = More readable code = More scannable code =
Happy developer = Rainbows in kittens’ eyes.

Keep cool, use vim

Fed up by using Eclipse (So slow) and Netbeans (always crashing), some
folks at Sensio Labs told me to start using Vim. At first, I said: “Just
the name makes me want to puke, but why not.”. A few weeks later, guess
which tool I used to edit my code? Yes, Vim. No, I didn’t even puke!

VIM does not stand for “VIM Is Magic” but it could. It’s lightweight and
usable everywhere. Whether you’re editing code, writing a blogpost in
markdown or configuring an apache vhost over an ssh connection, it’s a
wonderful tool to do the job.

The hard part with vim is the learning. It will take you some time… But it worth it.

The exquise beauty of vim is that it’s nearly entirely customizable. If
you’re not satisfied with keyboards shortcut, change them! Do you want
to have the key F10 do something when you type it, you can! I configured
this key to remove spaces filled lines in my code with a simple regular

VIM is so customizable and extendable that with installing a few plugins
and tools, you can transform it in a full featured blazing-fast IDE.

The first thing you need to do is to install “exuberant-ctags”. Without
it, vim cannot auto-complete from files you didn’t open or jump to
another method in other files. Once your tags are generated, the
method-hop won’t be as good as eclipse because it’s not contextual, but
it’s pretty acurate and it’s DAMN FAST!

Then I use these plugin to give an “IDE” feel to my vim:

  • NERDTree: A file explorer in your vim? yay!
  • minibufexplorer: Switch between buffers easily!
  • NERDCommenter: (Un)/Comment your code quickly
  • snipMate: I can haz Textmate styles snippets!
  • surround: Tired of navigating through your code to change double
    quote to simple quote? Surround do it with only a few strokes.
  • php-doc: Speed up the phpDoc editing
  • Align: Align your code in a few strokes!
  • matchit: Navigate in control structures or html tags, only with the
    % key.

Also, one of the more important point of using vim: It’s available

But be warned, once you’ll get used to the vim philosophy, it will be
difficult to switch back to an other IDE. 😉

If you’re curious and want to give a try without searching and
installing the plugin by yourself, clone my vim
. But you’ll still have to
read the docs 😉