Skip to content

Instantly share code, notes, and snippets.

marcaube / outbound.js
Last active Aug 29, 2015
Track outbound links using google analytics. This script pushes an event when clicking on <a> tags with the `js-ext` class.
View outbound.js
* Utility to wrap the different behaviors between W3C-compliant browsers
* and IE when adding event handlers.
* @param {Object} elem The element on which to attache the event listener
* @param {string} event The event type to listen for (e.g. load, click, etc.)
* @param {function()} callback The callback function that receives the notification
function addListener(elem, event, callback) {
// W3C
marcaube /
Last active Feb 11, 2021
On Domain objects and code organization

A few days – or was it weeks – ago, I answered hastily to a question on the Symfony2 Google Group. The question is simple but the answer is not : How do your organise your code in a Symfony project?

I've had some time to think about it and wanted to elaborate on the subject. Writing makes me think, and thinking is good.

Everyone has their own way to do this. Some organize their code in a way that makes them faster – like in the RAD edition. Some others take the time and put the emphasis on making things isolated, modular and re-usable. Most of us fall somewhere in the middle, still trying to find the structure that suits us, our workflow or our organization the most.

My original answer to the question was to keep the domain logic separate from the bundle code, i.e. place it in a re-usable library. The reason is that your business logic should be encapsulated into models, outside of persistance concerns, logging and al

marcaube / watchr_script.rb
Created Aug 28, 2013
Automatically generate styleguide with styledocco from less files with the watchr gem. Lauch with `$ watchr watchr_script.rb`
View watchr_script.rb
watch('(.*).less') do |match|
marcaube /
Last active Dec 16, 2015
Performance web et publicités


Ces derniers temps, j'ai été confronté à un problème de performance sur le site d'un client. Le site est développé avec Symfony2, utilise l'ORM Doctrine2, il est responsive, utilise adaptive-images pour servir des images optimisées, etc etc.

Jusque là, le site avait été optimisé pour mettre en cache les requêtes à la base de données (Query & Result cache), mettre en cache des fragment de template (avec les ESI) et utiliser au mieux les entêtes HTTP pour mettre en cache les pages du côté client.

Les résultats de ces mises en cache granulaires était un temps de chargement entre 60ms pour une cache navigateur primée et ~150-200ms quand il y avait un hit sur l'application, parce que la plupart du temps il n'y avait aucun hit sur la base de données.

Le problème

Le problème est arrivé quand le client a décidé d'ajouter des publicités sur son site. Ne voulant pas utiliser un ad-network existant, le cl

marcaube / vendors
Created Sep 19, 2012 — forked from ubermuda/vendors.php
A symfony2 vendors script hacked to handle svn urls
View vendors
#!/usr/bin/env php
* This file is part of the Symfony Standard Edition.
* (c) Fabien Potencier <>
* For the full copyright and license information, please view the LICENSE
marcaube / bootstrap-hugrid.js
Created Mar 26, 2012
Twitter Bootstrap Heads-Up Grid
View bootstrap-hugrid.js
definegrid = function() {
var browserWidth = $(window).width();
if (browserWidth >= 1200)
pageUnits = 'px';
colUnits = 'px';
pagewidth = 1170;
columns = 12;