MRI proton spin: 3D animated mathematical curve in the browser using MathBox.js

My partner is defending her thesis today and she needed some help to produce visuals for the presentation. The goal was to illustrate the relaxation of the spin of a proton that received a radio-frequential impulsion in a constant magnetic field, which is the principle at the root of Magnetic Resonance Imagery.

The visualisation needed to be animated and in 3D. I thought it would be a good use case for MathBox.js, a JavaScript library built on top of three.js, which is built on top of WebGL and developed by Steven Wittens.

This library is designed for mathematical visualisations. You focus on curve expressions and not on geometrical primitives, the engine is then evaluating and interpolating them on every frame to draw them. It works in 2D, 3D space and is not restricted to cartesian space.

I created a 3 step animation. MathBox allows you to write an animation script: you define for each step what is added, removed or animated.

You can load it in your browser at this address.
Or simply watch this youtube video:

I am also glad to use this animation to illustrate the Wikipedia article about MRI and MRN.

Using chrome as my code editor
I wanted to experiment with something that I think will happen more and more in the future: This short project was entirely developed inside the browser.

Code in Chrome dev tools

I had to create the local git repository and its submodules, but then I did not use an other editor than the “Source” tab of Chrome’s Dev Tools. This is possible thanks to Chrome’s “Workspaces” that allow it to map the current page source to a specific folder of your computer. It is then possible to edit and save the resources that are usually read-only. This workflow is more streamlined, than the regular workflow of debugging in the Dev Tools, then going back to the editor, find the line to change, save, go back to Chrome and reload. Here, you do not leave the browser’s window and can edit and save the JavaScript file at the same time of debugging.

Of course, this is a different approach than using an online IDE such as cloud9 IDE, that I also appreciate, but both are interesting and we should definitely keep an eye on these new workflows.

Learning AngularJS by re-writing my small portfolio website

I’ve been working with Backbone.JS for the past two years as front-end JavaScript framework for desktop and mobile web apps. I wanted to try a more structured framework. While I read a lot about Web components, that are for me the future of web programming, I had issues using them in a very simple use case. The Polymer project (based on them) looks interesting, but is still in very early stage. That is how I selected the AngularJS framework.

portfolio made with AngularJS

A refactoring of my simple portfolio at was a perfect candidate as a simple project to learn this framework. You can check the code on github.

I started with Angular’s great getting started tutorial and was then able to start working using the official Documentation and the rest of the interweb.

The app is very simple :

  • It contains two Views (described in partials), that are using the same Controller
  • The data comes from a JSON file and accessible from a Service.
  • I had to write a custom Filter to filter works based the checked checkboxes.

What is interesting is that I didn’t needed to code any data-binding or manual refresh, Angular is handling this for me since everything is properly wired. For example: clicking on  the sort radio-button changes the ‘sort’ variable that are linked to the works filters.

Read and fork the portfolio code on github.

Poker tournament tracker

My parents are regularly playing poker with friends. They keep track of every game in a spreadsheet but had issues determining the overall winners and see who has the best score across games. They were either doing it by hand or using ugly Excel macros that nobody could understand.

poker tournament

I quickly helped them and wrote a Google Spreadsheet custom function that does the job. They now just have to fill in the position of every participant for each game, the final scores and stats are automatically generated.

Get the code on this gist. To use it, you have to copy paste it in a new script linked to your spreadsheet.

I’ve been more and more using Google app scripts for personal or professional projects. I like the fact that they selected JavaScript as scripting language and that a lot of Google products have a script API. Very often, it avoids you creating a full web app for a simple task.


This Friday, I joined CédricMarc and the guys from Little Workshop for a quick coding session.
It all started when I noticed a very nice project: SculptGL by Stéphane Ginier. Stéphane created a great 3D scuplting tool that implements some very nice adaptive subdivision and decimation.
Final version of Sculptfab

Final version of Sculptfab

We decided to refine the UI and to add the ability to directly upload to Sketchfab without leaving the tool.
On my part, I created the foundation of a small script that, when inserted, would help an application creator to upload model data to Sketchfab. it displays a model window asking for Sketchfab API key and basic information.
Then, an archive containing the model data is created on the client using JSzip after the model has been transformed to the .obj file format. Screenshot of the current canvas is taken from the client too. and both are submitted to the Sketchfab API.

Try Sculptfab online at

Using MailJet as mail server for “Cadeaux entre nous”

My old website “Cadeaux entre nous” is seeing a large traffic during the christmass season:

  • around 2000 events were created during the last 2 months
  • between 500 and 1000 people visit the site each day.

This naturally lead to a mailing issue: I was previously using gmail to automatically send emails, I guess I reached the limit since it constantly required me to change the password.

I recently heard about MailJet, a French company that raised quite a lot of money last week. I knew Sendgrid but was willing to try something fresh.

Mailjet has a nice UI, clear instructions and allows you to setup your SMTP server in a few clicks. The real-time dashboard with analytics is a real plus to see if everything goes well.

I quickly reached the free plans limit (which is 200 mails per day), but thanks to a few donations from my users, I could upgrade a Bronze plan and since then, all is runnign smoothly. I guess I will downgrade when the holiday season is over.

Bringing video support to Phonegap Android

Phonegap for Android had serious issues with inline videos: HTML <video> tag was not supported at all on Android inferior to 4. (On Android 4.X, they require the View to be hardware accelerated)

On behalf of Joshfire, I worked on the main cordova Android source code by adding elements from the original Android browser. In the end, clicking on a video on a Phonegap application starts a fullscreen video player view. Hitting the “back” button goes back to the app. This is far from perfect, but better than nothing.

After submitting my pull request, I had warm and polite feedback from Simon Mc Donald of the Phonegap team, he helped to test my work and added the final touches before accepting the code into his branch.

Today the feature has been shipped into Phonegap 2.2.0. I had great feedback from both Phonegap creators and users. That’s something very motivating.

See the final commit in Phonegap’s source code.