Versions of PHP in Ubuntu

If you have to maintain an open source project written in PHP, like we do with Chamilo at BeezNest, you'll have to test your software on multiple versions of PHP to make sure of how well your code is supported on these versions. Of course, being open source, you can publish it on Github and then benefit from Travis-CI to get tests run automatically, but some stuff might be tricky to do, and maybe you'd like to test one specific thing, quickly, under a specific PHP version. Well, it turns out you can probably do that with Docker.

Redirect mobile devices to alternate URL with Varnish 3.0 and Drupal 6

This is a short note for ourselves, but it might help others considering the (new for now) rules of Google indexing of non-mobile sites. Drupal 6 does not really provide all the stuff that would be really useful to switch the theme of your site depending on the browser being on a mobile device or not. There are a few modules that should help you, like switchtheme, and mobile_subdomain, but in the end, you can also do it as follows.

Setting up Apache (or web server x)

Let's assume your site is called your.site.com and you want mobile devices to see another theme. Define the m.site.co

Configure HP LaserJet 100 colorMFP M175nw scanner on Ubuntu

If you have bought an HP LaserJet 100 printer and have it connected on the network, but somehow fail to scan from it, here's how:
  • sudo apt-get install hplip (chances are you already did that, but in the worst case this will do nothing)
  • sudo hp-setup (this launches a new window)
  • search network (if you enabled this in the printer web config page, you can select the "Bonjour" protocol)
  • let it find your printer and select "download and install driver"
  • accept to "add printer"

Benchmark: dirname(__FILE__) vs __DIR__ in PHP

dirname(__FILE__) and __DIR__ give exactly the same result in PHP, although one (__DIR__) is evaluated at compile-time, while the other (dirname(__FILE__)) has at least part of it (the function) evaluated at execution time. Ever wondered what the difference is, in terms of efficiency, between the two? I've written a *very* simple script to try it out:
<?php
$loops = 100000000;
echo 'Testing dirname(__FILE__)' . PHP_EOL;
$start = time();
$dir = '';
for ($i = 0; $i < $loops; $i++) {
 $dir = dirname(__FILE__);
}
echo 'dirname(__FILE__) took ' . (time()-$start) . 's' .

How to migrate from Claroline to Chamilo

On Wednesday 21st of January 2015, the UCL (Université Catholique de Louvain), through an e-mail from its rector's advisor and its co-rector for education and training, announced that it would abandon the development (and usage) of Claroline over a period of 18 months. There's a little mention about Claroline Connect being "immature" at this time, and a comparison between (exclusively) Claroline, Claroline Connect and Moodle in terms of the direction in which the UCL is going and the uniformization of its online education. They decided to go with Moodle for the foreseeable future.

Prevent Wordpress MailmanWidget widget to hide after registering your address

If you use the Mailman Widget as an important design element, you might be annoyed by the fact it disappears once you registered your e-mail. A quick hack to this behaviour is to modify ns_widget_mailman.class.php (see comments):
 public function widget ($args, $instance) {
     extract($args);
     // Patch to continue showing block even if registered in this session
     //if ((isset($_COOKIE[$this->id_base . '-' . $this->number]) && $this->hash_mailing_list_id($this->number) == $_COOKIE[$this->id_base . '-' .