Compiling libsureelec examples on OSX

install rudix’s autoconf, automake and libtool, then after running the (configure, make etc) type:

cd examples

gcc -Wall -I../ -o sureelec_test2 sureelec_test2.c ../.libs/libsureelec.dylib -lreadline

EFI boot on a MacPro 3.1

Apparently it is possible to boot Windows 7 and Windows 8 in pure EFI ( ) even if Windows 8 makes it even easier ( )

All I want is a motion-interpolation video player, such as SVP ( - and there is none under OSX.

If I can’t get good performances with a VM, maybe I’ll add a dual boot !

Changing the color of icons from OSX Terminall

And the answer is :

sudo xattr -wx 0000000000000000000C00000000000000000000000000000000000000000000 the-file-you-want-to-turn-red

red: C
orange: F
yellow: B
green: 5
blue: 9
violett: 7
grey: 3

To clear the label again, either use 0 as a value or run sudo xattr -d /Applications/Utilities.

As mentionned on

Caution: This will wipe out any other FinderInfo value there might be set for the target file/directory already. For the Utilities folder this shouldn’t be an issue but it might for others.


Adding custom mp3 ringtones, alarms and notifications to my Android Nexus

It will be a long process, so let’s take for granted that you have the mp3 file you want, and that it is already less than 30 seconds long.

First, unless you want it to play only once, you need to convert it to OGG (try and add the following tags : ANDROID_LOOP (set that to true) and TITLE (set that to the ringtone name). A good app for that is for OSX.

Then you need to move the resulting OGG file to the sdcard in Ringtones/ (alternatively, some people suggest using media/audio/ringtones along with media/audio/alarms and media/audio/notifications)

After that, several people mentioned you need to reboot (or run some ScanMedia app such as com.dcd.scanmedia to update the database), but on my nexus that does not work.

Everytime I add some new file, I have to clear Media Storage app data, then update the database, then reboot (again), unless I want to loose your default ringtones as reported on

It seems to me like a bug, since I had to do that for the ringtone first, then the alarm, then the notifications - updating the database and rebooting without clearing Media Storage app data did *NOT* work.

Anyway, you may finally enjoy your mp3 tune. Not exactly quick or user-friendly, but it works.

10 years ago, I receive the European online journalism award for a conference report my company did.  The BBC grabbed most of the other awards ( and but I’m still quite proud and but I’m still quite proud of the performance, considering I was just doing all that to pay for my studies :-)

10 years ago, I receive the European online journalism award for a conference report my company did.  The BBC grabbed most of the other awards ( and but I’m still quite proud and but I’m still quite proud of the performance, considering I was just doing all that to pay for my studies :-)

Fixing Mathematica shortcuts for non-US keyboards

Switching windows on Mathematica usually involves Cmd-` (that’s a grave accent in case you can not see it). The grave accent is just below Escape on a US keyboard, but if your grave accent key is in a different place, it may cause you trouble.

The best solution I’ve found is to edit 2 files : to remove the currrent map you want to reuse and eventually TextResources/Macintosh/ if you want to move that function to a different key that where the US key physically is.

For example, if / is the key just below Escape, in, change :

MenuItem[“Un/Comment Selection”, KernelExecute[FE`toggleComment[]], MenuKey[“/”, Modifiers->{“Command”}], MenuEvaluator -> “System”, Method -> “Queued”],

To :

MenuItem[“Un/Comment Selection”, KernelExecute[FE`toggleComment[]], MenuEvaluator -> “System”, Method -> “Queued”],

There is no need to edit the other file since the \ key on the Canadian keyboard is where the grave accent is on the US keyboard : just removing the conflicting definition will restore the key that is in this position to its default function.

Predicting diagnosis

What if you tried to predict how diagnosis and drug interact, at the population level ? 

This is what I have been trying to do for some time.

This is now the reason why I’m attending Wolfram Summerschool 2013. NKS is interesting approach, as it gives a different outlook when compared  to the standard statistical approach.

But in practice, how well will it work with healthcare data? I intend to test that empirically. We will see.

Learning mathematica from scratch

I have many defaults - IMHO the #1 being that I am not as good in math as I used to be 15 years ago (I used to do my integrals by hand - that was *before* med school). Even worse is the fact that I am not using symbolic computation software to supplement my failings.

Serendipity lead me to Mathematica, after a Hacker News post. At this moment I’m still very new with it, but since the reading list I found on Quora was not satisfying, maybe it is an opportunity to help fellow Mathematica newbies?

My suggestions : start with where you get simple examples and a good explanation of what to expect.

If you dig economics, follow that by, which will explain in plain words why it is a good to use Mathematica, and then to play with a Cournot duopoly and do some iterations, or even better (and simpler) to graph total costs and average costs.

You may then need some tips, at least to understand all of it - provides helpful things, like setting the plot range or plotting 2 functions on the same graph.

With that done, you may then benefit from a longer and more detailed text, such as

The text is a bit incomplete, for example there is nothing about bases (hexadecimal, binary). You should complete that that with the “official” guide, - for example if you are interested in bases.

If you are like me, you may have to look for some references. My total differential knowledge was a bit stale so I checked the excellent page and after that read the critic of the wikipedia current entry on

I am now starting the tutorial on learning how to program with Mathematica. More on that later.

Running PostgreSQL on Mac OSX Mountain Lion in 2 minutes

I don’t like OSX Server- I tried to live with it, but it was more pain that it was worth. With Mountain Lion, I missed having a PostgresSQL server on my laptop. But I didn’t like the idea of using homebrew either - I best like Rudix approach : unpack and you are ready to go.

So I took PostgreSQL from apple “opensource” website, recompiled it with XCode, and made a nice tarball for everyone to play with. Installation takes about 2 minutes currently, and it integrates well with an “out of the box” Mountain Lion OSX. Here we will explain what to do if you want to do the same.

First, as root we will clean the existing Apple default files (it’s a broken PostgreSQL installation missing binaries) and unpack my binaries. Since we will use rm as root, you may want to backup your system first (better be safe that sorry):

sudo bash

rm /System/Library/LaunchDaemons/org.postgresql.postgres_alt.plist

rm /Library/Preferences/org.postgresql.postgres.plist

curl > /

cd / && unzip

You can also get the sources I used, and recompile them with XCode yourself : or even the build (maybe you just want to edit one file and recompile ?) from

My XCode was missing AEP.make, so it’s included in PostgreSQL-56.sources.tar. If you don’t trust my binaries, simply grap AEP.make rebuilt everything using XCode and Apple original sourcetree from

Unzipping the into / will create a /clean directory, so you can manually move the files to /usr if you want to check them first.

The largest part of the work is done. We will now use these binaries to populate the default database:

sudo -u _postgres initdb -D /var/pgsql -U _postgres

But that’s not enough. If you try to start postgres manually and want to use Apple defaults, it will fail silently as you can see in your system.log

To see why, start it manually with:

sudo -u _postgres /bin/bash

postgres  -D /var/pgsql -c unix_socket_directory=/var/pgsql_socket/ -c logging_collector=on -c log_connections=on -c log_lock_waits=on -c log_statement=ddl -c log_line_prefix=%t  -c listen_addresses= -c log_directory=/Library/Logs -c log_filename=PostgreSQL.log -c unix_socket_group=_postgres -c unix_socket_permissions=0770

You will see the logfile is causing a problem:

2013-03-07 13:54:28 ASTFATAL:  could not open log file “/Library/Logs/PostgreSQL.log”: Permission denied

Simply create it as root and chown it for postgres to use with:

touch /Library/Logs/PostgreSQL.log

chown _postgres:_postgres /Library/Logs/PostgreSQL.log

Restart postgres manually with the previous command - success !!- but from now on, you can just start it automagically on reboot with launchd:

launchctl load /System/Library/LaunchDaemons/org.postgresql.postgres.plist 

If you plan to connect as your normal user, you may want to join the existing _postgres group with:

dscl . -append /Groups/_postgres GroupMembership guylhem

Then, before connecting under your normal username, test postgres on the default database with:

sudo -u _postgres psql template1

Now you can create databases, users and provide permissions as you would on any unix. Just be carefull not to use too much space on /var/pgsql

For example, I created a guylhem database and matching username with:




Now you can close the root session, and load all kind of data under your username. If you also want Apache HTTP server, check

You can also try locally - it is a nice app. Be sure to check the worldbank data article to have something to test your new PostgresSQL : see and to extract data for an augmented Solow growth model (Mankiw style!)

A final warning : we are not using the latest version here. For local test and development, I did not see the need to have the latest security patches, especially when considering it could encourage readers to put that online. That is not safe. You should not use binaries you wget from a stranger on the web on a production setup. Just use XCode yourself from Apple sourcetree.

Adding a Hacker News ticker to your website

A little while ago, I had this weird idea of making contact easier with people who read my essays, thanks to a single website were my “online interactions” would be gathered. But in the time of Facebook updates or Twitter comments, I had to gather them too.

So I create, but the only problem was I was not an avid Facebook and Twitter user yet, so I added my blog posts there too.

A couple of years later, while I’m still not really into Facebook and Twitter, another problem emerged: since I have started to use Hacker News, more and more of my comments are created there - and even more than on my blog, since there is more interaction with other comments on HN. (at least, this validates post hoc the “” idea!)

The solution was simple - adding a HN ticker, with my latest posts !

While there is a lot of code to do that with Facebook, Twitter, Linkedin, etc. I could not find any code to do that with HN, so I did what every hacker would do and created one myself.

HN does not offer a JSON API, so started I playing with simple regexes like with curl to create a static file I could include, for ex: curl  | grep “id=guylhem">guylhem</a>” g|grep “| on”

This was not a satisfactory long term solution, since it requires server-side scripts.

I also thought about client-side parsing, but since were are talking about non-JSON files, cross domain scripting will prevent anything unless you add something like the following to your server (see,

Access-Control-Allow-Methods: GET, POST, OPTIONS

Access-Control-Allow-Credentials: true


Access-Control-Allow-Headers: Content-Type, *

Turns out the solution was simpler than imagined - thriftdb provides an API, and a reverse time query with the following gives a JSON object:[fields][username]=guylhem&sortby=create_ts%20desc

With that in hand, creating a ticker was easy. Simply edit the following PHP code to get links to your own comments -  obviously at least replace “guylhem” with your own username and date_default_timezone_set with your location:


$user = “guylhem”;

$count = 10;

$date_format = ‘Y-m-d H:i:s’;

$url =’’.$count.’&filter[fields][username]=’.$user.’&sortby=create_ts%20desc’;


$decode = json_decode($json);

foreach ($decode->results as $comment) {

$datetime = date_create($comment->item->create_ts);

$date = date_format($datetime, $date_format).”\n”;


echo ‘<a href=”’.$article_id.’”>’;

echo $date . ’ - Comment on “’ . $comment->item->discussion->title .’”’;

echo “</a><br>”;


You can create a fancier HTML version (marquee text and the like), personally I like it simple. The goal is just to let my friends know when the latest update was (french blog - 2011 - oops ; HN - today 10 minutes ago - much better) and which topics I enjoy.