Pages

Monday, August 27, 2012

MySQL becoming more and more closed source, thanks to Oracle

As highlighted on Slashdot and Hacker News, the tests suites and the commit log of MySQL are not bundled with the opensource distribution.

Oracle has an history of sabotaging opensource projects, it does not work well with their business model.

VirtualBox is still alive, but for how much time ?

MySQL is not the only RDMS, but it is the most popular free one. MariaDB claims to be an enhanced, drop-in replacement for MySQL but if was to switch, I would strongly consider PostgreSQL. It is robust, highly scalable, mature, and feature-rich.

PHP frameworks and CMS with support for PostgreSQL

And probably much more.

Harvard cracks DNA storage, crams 700 terabytes of data into a single gram

Two scientists at the Harvard’s Wyss Institute have successfully stored a 700TB of data in DNA. 

To give you an idea of how big this is, it would mean more than 35000 years of HD video of YouTube (720p at 5kbps) into a single gram. HD video is indeed a diffcult thing to store, it is even mentionned in the video. This means it is almost 60000 times more dense than a 3TB hard drive and it should fail a lot less often.

While they were able to generate that amount of data, most of it was duplicated. DNA replication is really fast, encoding the data is however much slower. They don't extrapolate on the read time either. It is not tomorrow that we will have DNA USB keys, but for long-lasting and space-hungry data, it is very promising.

A rather long time ago, tape devices held a similar function. It is now pretty obsolete, but it made the first backups possible.


Monday, August 20, 2012

Convertir le calendrier UdeM au format iCal

Amis de l’UdeM,
L’interface de visualisation de l’horaire des étudiants est vraiment à exploser de larmes
Voici une solution pour convertir le tout en .ics compatible avec Outlook, Gmail, iCal, etc.
  1. Utiliser Chrome
  2. Aller sur le guichet étudiant et consulter votre horaire.
  3. Rendu sur la page de l’horaire, ouvrir le menu développeur de Chrome: Ctrl-Shift-I
    Sur Mac, c’est Cmd-Alt-I.
  4. Cliquer sur le dernier onglet qui s’appelle “Console”
  5. Là où le curseur clignote, coller ceci:

Tout devrait fonctionner automatiquement et télécharger un fichier qui s’appellera download.ics

Si ça ne fonctionne pas, dîtes-moi le !

Monday, August 13, 2012

PHP Coding standards

For more than a year, some influent PHP programmers of the most active of the most active projects in the community have been working on coding standards.

The group is name PHP Framework Interoperability Group and is composed of, but not limited to, authors from these projects:
  • phpBB
  • PEAR
  • Doctrine
  • Composer / Packagist
  • Joomla
  • Drupal
  • CakePHP
  • Amazon Web Services SDK
  • Symfony
  • Zend Framework

Why coding standards?

You may be a fan, for example of naming your functions with underscore or use tab indentation, but really this is not point. The goal is to be able to use code from other authors and projects without having to "fix" the code style to be consistent with your project.

In the future, the group also aims at providing some interfaces so implementations from different can work together.

Accepted standards

  • PSR-0 Code structure, Class and function naming
  • PSR-1 Basic coding standards
  • PSR-2 Coding style standards (mostly whitespace)
See full repository: https://github.com/php-fig/fig-standards

I don’t want to rewrite all my code!

Well, you probably don’t need to.

Chances are that you are already pretty near PSR-0 if you have organized your classes to be autoloaded. If you haven’t, you should really look forward to it, autoloading eliminate the need to require classes, simplifying a lot class dependencies.

After complying to PSR-0, there’s a tool that will do almost all the hard work for you by fixing all the whitespace. It is called PHP-CS-Fixer and is from Fabien Potencier, member of the group.

You can try PHP_CodeSniffer, but personally a find it a pain to use because it only 'validates' and make some errors. It should probably need a rewrite.

Some editors have plugins:
You can also add a Git commit hook to patch on-the-fly.

Further reading

Great blog post from Paul M. Jones.

Reducing the load of all those social plugins

Some javascript libraries are big and they pose a stress on the browser when they are loaded all at the same time.

Most of these libraries suggest to load them in async.

Library examples

  • Google Analytics
  • Google Maps
  • Google Plus
  • Facebook Like
  • Twitter button

Problems with existing solution

  • A lot of ugly script tag with semi-minified code.
  • Most of the library suggest the same trick so we see code duplication.
  • You have to go copy-paste the code each time you start a new project.
  • If you have multiple libraries, they will all fire at the same time, possibly causing a stress on the browser
  • While the libraries are loading (usually with a lot of dependencies) the browser is sluggish and users probably want to read that article before clicking on 'Like'.

Solution

  • Load each library with a function taking an id, a url and a delay.
  • Allow each library to have a different delay.
    • You may want Google Maps to load only 200ms after the page, but the Facebook Like can wait a bit more.
  • Code on Github
  • Working example on jsfiddle

Wednesday, August 1, 2012

Is the online ad industry a fraud?

As highligthed by MacLeans, the Advertising Research Foundation did an experiment showing that:
A blank banner ad received more clicks than the average Facebook ad, twice as many as your average “branded” display ad (a static ad which promotes a brand rather than a specific offer or call to action), and only one click in ten thousand less than the average banner ad.
While we all hate advertising when browsing, it provides nice revenues and is often how a website is able to live.

What the ARF shows us is that the companies paying for advertising may be paying for air or, what is more likely to be true, inflated data.

They also asked the users if it was a mistake or if they were curious about a “blank”:
The average click-through rate across half a million ads served was 0.08%, which would be good for a brand campaign, and so-so for a direct response campaign. We detected no click fraud in the data we counted. Half the clickers told us they were curious, the other half admitted to a mistaken click.
The conclusions are yours to make.

Solving complex network problems using… fungus

Here is a part of a documentary on decay that aired on BBC.

The part I am talking about is at 1:03:45 and demonstrates a slime mold searching for its food, optimizing the network path between food sources and even creating some backup routes.

This is quite interesting considering that network resolution is a hard problem that requires quite a bit of processing.


P.s. The rest of the show is quite fascinating as well

Generate a random string of non-ambiguous numbers and letters.

I needed to generate a unique code, suitable for URLs and somewhat short so it doesn’t scare the user.

Doing md5(microtime()) is nice but it is 32 chars long. I could use base64, but it contains weird characters like "/" and "=".

So how do I restrain the encoding to alphanumeric ? I found the inspiration from Ross Duggan and I added a random function. He also removes a couple ambiguous chars, which I think is a nice touch.

The choice of random could be discussed but the idea is there.

UPDATE: As suggested by a friend, it is simpler and a better use of the range of available entropy to generate each character separately. You can see the old version in the Gist.

Tests included