Apple hypocrisy

I’m a regular reader of TechCrunch. I’ve just read “Apple, There’s Pornography On My iPhone The App Is Called Safari. You made it.” by MG Siegler (by the way I’m a big fan of this guy, I really like what he writes). This article exactly reflects my point of view concerning recent Apple’s decisions. I advise you to take a look at it.

Posted in None at February 23rd, 2010. View Comments.

Test of distraction-less text editors on OS X

Note: If you think that I missed a really nice disctration-less text editor, or that one of my comment is groundless, feel free to drop me an email.

Competitors:

  • Ommwriter
  • Pyroom
  • WriteRoom
  • JDarkroom

Ommwriter

Ommwriter is developed because of an internal need at Herraiz Soto & Co, a digital creative agency.

I like to call it the “Zen” editor, because of its default background images and ambiance musics: they all bring the belief of zen out by subtle, “quiet” images and sounds.

It runs fast: instant launch, easy switch between applications (for a dictionary search for example).

Ommwriter

Ommwriter

It really takes it promise of being a distraction-less text editor.

Ommwriter interface

Ommwriter interface

The full interface is clean that’s true. Buttons are explicits, the scrollbar is thin but really efficient. Nice.

Pyroom

I put it there only because I know it exists and because a really nice French guy works on it.

Here is the (huge) problem: it is such a pain to install Pyroom on OS X that all urge to use it leaves me instantaneously.

WriteRoom

WriteRoom is a $25 software created by Hog Bay Software. It seems that is name is like a reference in the world of distraction free text editors on OS X.

WriteRoom

WriteRoom

I do not really like to pay software, except if they are so nice that I can’t do without. Fortunately, I received WriteRoom in my MacHeist bundle a few months ago.

WriteRoom is really customizable: this is a great point for it. You can indeed set everything from the fullscreen colors to the auto-save frequency.

WriteRoom preferences

WriteRoom preferences

In addition, it can create two types of documents: plain text and rich text, which can be a really useful feature for people who need text formatting without markup syntax (such as Markdown, I highly recommend it). For example, using the rich text mode allows you to set color, font weight and many other attributes such as text alignment of your text. WriteRoom produces RTF compliant files so they are editable by any other RTF editor.

WriteRoom Rich Text

WriteRoom Rich Text

I don’t use this function because of two things. The first is that I have an heavy use of Markdown. The second is that I think this feature is out of distraction-less text editing.

One more thing I do not really like is that you need to move your mouse cursor to the bottom left corner of the screen to display informations on your document (file name, words and lines numbers). I prefer the behavior of Ommwriter: you just move your mouse (it is equivalent for me to a light gentle touch on my trackpad) and those informations appears.

JDarkroom

JDarkroom OSX integration fail

JDarkroom OSX integration fail

To be frank : I hate it. Firstly, it is made with Java. It is not that I dislike Java, but it leads to problems: slow performances (it is long to start, not really swinging) and bad system integration (does not totally hide when I press +tab, keeps other applications from taking focus…) mainly.

Another JDarkRoom fail (+tab)

Another JDarkRoom fail (+tab)

Furthermore it doesn’t deal nice with UTF-8. For example, I opened and saved my document in JDarkroom, without modifications. Here is the result back in Ommwriter :

My doc in Ommwriter after JDarkroom

My doc in Ommwriter after JDarkroom

(Trust me, I don’t let my 2400 bauds modem write my documents)

Conclusion

To conclude, I have a preference for Ommwriter because of the real simplicity of its look & feel. I also enjoy its ambiance songs! :)

Note: for each editor, I used it to write the corresponding paragraph.

Posted in None at February 22nd, 2010. View Comments.

Dijkstra’s algorithm Python implementation

Here is my implementation of Dijkstra’s algorithm (also known as the shortest path) in Python. I wrote it for a project at school and put it there for memory only.

Note:

  • I don’t test the graph.
  • Graph is oriented. If you want a non-oriented graph, you need to add vertices twice in your graph.
  • May be improved (time).

Here is the source (on Friendpaste):

def dijkstra(graph, start, end):
    """
    Dijkstra's algorithm Python implementation.

    Arguments:
        graph: Dictionnary of dictionnary (keys are vertices).
        start: Start vertex.
        end: End vertex.

    Output:
        List of vertices from the beggining to the end.

    Example:

    >>> graph = {
    ...     'A': {'B': 10, 'D': 4, 'F': 10},
    ...     'B': {'E': 5, 'J': 10, 'I': 17},
    ...     'C': {'A': 4, 'D': 10, 'E': 16},
    ...     'D': {'F': 12, 'G': 21},
    ...     'E': {'G': 4},
    ...     'F': {'H': 3},
    ...     'G': {'J': 3},
    ...     'H': {'G': 3, 'J': 5},
    ...     'I': {},
    ...     'J': {'I': 8},
    ... }    
    >>> dijkstra(graph, 'C', 'I')
    ['C', 'A', 'B', 'I']

    """

    D = {} # Final distances dict
    P = {} # Predecessor dict

    # Fill the dicts with default values
    for node in graph.keys():
        D[node] = -1 # Vertices are unreachable
        P[node] = "" # Vertices have no predecessors

    D[start] = 0 # The start vertex needs no move

    unseen_nodes = graph.keys() # All nodes are unseen

    while len(unseen_nodes) > 0:
        # Select the node with the lowest value in D (final distance)
        shortest = None
        node = ''
        for temp_node in unseen_nodes:
            if shortest == None:
                shortest = D[temp_node]
                node = temp_node
            elif D[temp_node] < shortest:
                shortest = D[temp_node]
                node = temp_node

        # Remove the selected node from unseen_nodes
        unseen_nodes.remove(node)

        # For each child (ie: connected vertex) of the current node
        for child_node, child_value in graph[node].items():
            if D[child_node] < D[node] + child_value:
                D[child_node] = D[node] + child_value
                # To go to child_node, you have to go through node
                P[child_node] = node

    # Set a clean path
    path = []

    # We begin from the end
    node = end
    # While we are not arrived at the beggining
    while not (node == start):
        path.insert(0, node) # Insert the predecessor of the current node
        node = P[node] # The current node becomes its predecessor

    path.insert(0, start) # Finally, insert the start vertex
    return path
Posted in None at February 15th, 2010. View Comments.

Demi-finale au Prologin 2010

Concernant le Prologin

Il s’agit d’un concours national français d’informatique mit en place en 1991 (et non pas 97, merci à Alexis) ayant pour but de tester les participants sur le capacité à concevoir un algorithme répondant à un sujet précis, ainsi que leur capacité à l’implémenter dans le langage de leur choix.

Le concours se déroule en trois étapes :

  1. Présélections
  2. Demi-finale
  3. Finale

Présélections

Les présélections se déroule à distance. Vous devez envoyer par la poste ou par le formulaire en ligne dédié (plus efficace, disons le tout de suite) vos réponses à un QCM portant sur une culture générale informatique, ainsi qu’à une série de sujet d’algorithmique. Les réponses sont évaluées par les organisateurs, puis les participants sont triés et sélectionnés suivant leur note.

Demi-finale

Les candidats restants sont soumis à une épreuve théorique de 3h : ils doivent établir une suite d’algorithmes pour répondre au sujet. Ensuite vient l’épreuve pratique (ou “machine”) : ils se voient recevoir successivement jusqu’à 7 sujets de difficulté croissante, auxquels ils doivent répondre par un programme qui subit une batterie de tests afin de valider son fonctionnement.

Finale

Un sujet est donné aux candidats. Ils doivent y répondre en 36h. En général il s’agit de développer une intelligence artificielle pour un jeu développé pour l’occasion.

De mon point de vue.

Un soir où je m’ennuyais ferme, je cherchais donc de quoi m’occuper. Complètement par hasard, au fil des liens de la toile je me suis retrouvé sur http://prologin.org. Tiens, un concours d’informatique français pour les moins de 20 ans. Mais encore ? Après avoir lu (en diagonale) les diverses pages d’information du site j’ai décidé, pour le fun et tuer l’ennui de compléter le formulaire d’inscription. Mes algos paissaient, j’avais répondu au QCM, allez, j’me lance. 1 mois plus tard, j’ai reçu un email comme quoi j’avais été sélectionné pour la demi-finale du concours. Il me semble) que mon expression a été relativement claire : woot!

Pourquoi pas après tout. Me voila alors aujourd’hui samedi 13 février à Lyon pour le concours. J’avoue n’avoir absolument pas bossé pour par manque de temps, étant déjà très pris pour assurer mes résultats scolaires.

Bref, il est 8h45 et j’entre dans le bâtiment marqué sur le plan qui accompagnait la convocation. Un type à l’air sympathique m’affirme que je viens pour le Prologin. Ça devait être écrit sur ma tête, ou bien c’était mon allure de touriste perdu qui l’a aiguillé. 5 minutes après, j’attaque le petit dej’ offert. Sur le papier, ce moment est décrit comme étant fait pour que “les candidats fassent connaissance”. En pratique, tout le monde est dans le pâté, et à part un groupe, personne ne fait signe de communication.

9h, début de l’épreuve théorique. Je ne m’attendais vraiment pas à ça. En fait, je n’avais pas d’idée précise et définitive de ce à quoi pouvait ressembler un sujet de d’algo. J’ai été très déçus, par plusieurs points. Premièrement, le sujet était très brut: le site décrit l’épreuve comme étant une suite d’algorithme pour une problématique générale. Ils n’ont pas vraiment fait preuve d’imagination ici : “Monsieur X aime beaucoup utiliser des algorithmes pour diriger sa vie, c’est ce que nous allons faire” (bon ok, le sujet n’était pas posé comme ça, je l’écris de tête dans le train). Deuxièmement, et c’est là le plus gros : c’est mon manque de théorie qui s’est fait sentir. Je me suis rendu compte que je n’avais quasiment jamais manipulé d’arbres, or le sujet consistait à définir une structure de donnée puis à implémenter une série de fonctions. On pouvait, d’après la correction rapide d’un des organisateurs, utiliser une autre structure, mais je n’ai pas réussi à retenir le nom.

Vers la fin de l’épreuve, j’ai eu le droit à mon entretien. Il s’est je pense pas trop mal passé, mais j’ai eu très honte lorsque que je n’ai pas su répondre aux questions “qu’elle est la complexité du tri par bulles ?” et surtout “qu’est-ce que vous aimez à par l’informatique ?”. Oups.

12h, pause pizza. Il y avait déjà beaucoup plus d’ambiance que le matin, ça discutait pas mal à ma table. Ça m’a permit de me rendre compte qu’une bonne partie des candidats étaient en IUT ou prépa, c’est à dire avec de plus ou moins solides connaissance en algorithmique. Cependant j’ai vu aussi que je n’étais pas le seul à être déboussolé et très limité par mon côté autodidacte (qui est, soyons franc, bien moins efficace qu’un cours traditionnel).

13h30, début de l’épreuve machine. Enfin, début théorique de l’épreuve machine : nous n’avons démarré qu’à 14h. En effet, l’installation n’est pas vraiment au point. Je ne blâme aucunement les organisateurs car nous étions dans les locaux d’une école de commerce, donc pas nécessairement orientés vers le bidouillage et l’écriture de code. Le fond du problème certainement : toutes les machines sous Windows XP. Je ne pense pas qu’on ne puisse développer sous windows. Juste qu’il agit en bel obstacle à votre efficacité. Ensuite, pour des raisons diverses, certains programmes, tels que bash et codeblocks (entre autres) ne fonctionnaient pas sur certaines machines, et ce de manière assez aléatoire. J’ai d’ailleurs moi même été obligé d’utiliser Internet Explorer 7 au lieu de Firefox pour interagir avec le serveur du concours. Oui, IE est bien le seul navigateur que je connaisse tel que le clic-droit mette en moyenne 5 secondes à se manifester. De manière globale, les épreuves se sont bien passées. D’après leur classement, j’ai fais 5ème sur environ 35. J’espère que les sujets seront bientôt en ligne, j’aimerais bien trouver une solution à ceux que je n’ai pas su faire.

18h, c’est la fin. Direction gare de la Part-Dieu pour 2h30 d’attente afin de rentrer chez soit (il faudrait d’ailleurs m’expliquer pour la SNCF note “train à l’heure” dans le champs “particularité” du tableau d’arrivée des trains).

Bilan

Bien sympathique. Que j’aille en finale ou non, je me serais quand même bien amusé et j’en aurais appris pas mal. À l’avenir, j’essayerais de bien faire attention à la complexité de mes algorithmes !

Spoiler : billet rédigé dans le train avec Ommwriter. C’est fou ce qu’on écrit bien plus quand on a rien qui nous embête.

Posted in None at February 13th, 2010. View Comments.

Chrome vs Safari: my opinion

On my computer (MacbookPro), I have two browsers: one for web development and the other for the rest of my web activities. Firefox is definitely the best for my coding tasks, mainly because of its flexibility, its rank on the most used web browsers (please don’t ask me why I don’t want to use Internet Explorer) and numbers of insanely efficient extensions. Nevertheless, Firefox is, in my opinion, far to slow for my daily use. So the problem is: which browser for the rest? I wasn’t sure which one to use, especially between Safari and Google Chrome. But I finally decided: Chrome. Here is why.

Software

Chrome 5.0.307.5 dev
Safari 4.0.4 (6531.21.10)

Benchmarks and tests

I ran a few tests as a matter of form.

Google benchmark
Safari: Score: 1575
Chrome: Score: 4123

Sunspider
Safari: 547.0ms +/- 10.7%
Chrome: 444.2ms +/- 7.6%

Acid 3
Safari: 100/100
Chrome: 100/100

Security check
Safari: 3 tests passed.
Chrome: 3 tests passed.

Conclusion: Chrome looks a bit faster than Safari.

Extensions

There are two features I need to have in my browser.

  1. Ad blocking, done with AdBlock on Firefox.
    Chrome: AdBlock
    Safari: AdBlock too but forces me to use Safari in 32bits mode. #fail

  2. Display the download progress in the dock
    Safari: built-in
    Chrome: need a revision superior to 38304 (not even in dev channel yet) #fail

Bookmarks

I use bookmarks.google.com to manage my bookmarks.

Safari: No way.
Chrome: No smart way. (strange)

#doublefail

RSS

I rarely read news feeds in my browser, yet I need an RSS feature in my browser to easily add the given feed to Netvibes (for example).

Safari: Built-in is really nice.
Chrome: Needs an extension. One is provided by Google and it does the thing really well.

Extensions

Potentially, extensions represents the chances the program may have to fulfil my eventual features wishes.

Safari: few
Chrome: dozen

Write extensions

As I love to tweak the softwares I use, writing extensions for them must be easy.

Safari: ObjC, not really well documented. #fail
Chrome: JSON+Javascript. Well documented with videos.

Web development

Both has the same Developper toolkit, but Chrome’s default view source is smarter (color/lines/links).

Posted in None at February 7th, 2010. View Comments.

Songbird: Music player for OSX

I hope you like The Beatles! ;)

That’s it, I’m finally tired of iTunes. On my MacBookPro, it takes close to 3 minutes to cold start, and I see the spinning ball each time I click on its window. Such a pain! I needed to find a solution, quickly (well, I’m of those guys who don’t know how to live without music). I gently  asked Google, then I discovered… Songbird!

Songbird Logo

It’s amazing, it really blew me away! First of all, it starts in less than 5 seconds! Incredible. Here is what it looked like, at my first start (right after it finished importing my 70GB iTunes library without an effort):

First start

No lag, everything is smooth. Let’s dig a bit more. In the menu bar, I found that:

Songbird strange window

What the… ? Well, a Firefox-like console in a music player? I thought it was an easter-egg. I closed it then I opened the preferences window, and I found…

This window looks familiar

A Firefox-like extension window! Wow, it looked like Songbird and Firefox are cut from the same cloth. But it’s not the end! I then discovered the built-in… browser!

It allows me to browse Songbird's extension list

And watch my beautiful weblog

And finally grab its characteristics

So, I have a Firefox/Gecko with a music player on top. It really came out of left field. What else? Remember, I left iTunes only because of its bad performances. Hopefully, Songbird has a lot of iTunes’ features:

Songbird iTunes like sidebar

Songbird coverflow-like (plugin needed)

Furthermore, I really prefer its miniplayer over iTunes’:

Songbird miniplayer

As you may have noticed, Songbird is, because of its Firefox foundation, highly customizable. So if you, like my, prefer a lighter skin, then just download it through the built-in browser! Here is the Gonzo 2.0 theme I chose:

Songbird Gonzo 2.0

So for me, slow and not customizable music players are all water under the bridge.

Posted in None at February 4th, 2010. View Comments.

Writing articles with LaTeX

I had to write a quite short article for school a few weeks ago. I’m used to write my homework with Apple’s Pages, with always the same template I’ve built once. But this time, I wanted to change the look of my document, yet there is a bug I can’t manage to solve with Pages: I have a paragraph, it has a background color, inner margins, and I want borders on its top and its bottom. I don’t know why, but borders stop before the inner margin.

Borders are nasty with me

I’ve eared about an amazing, powerful, word processor called LaTeX. Well, OK why not. I decided to give it a try. After several cups of coffee hours I had finally wrote my document with my own custom style document class.

In my opinion, LaTeX is nice, nevertheless it has a major drawback: it is old. Oh, I like writing text with non-WYSIWYG programs, I don’t really like icons, and the less my macbook does the best it runs. But LaTeX, because of its age needs a serious cleaning. There are dozen of packages (some kind of pluggable pieces of code for your document) which does nearly the same things, but not exactly. So you need 2 or 3 of them to reach your goal. More over, I think something like CSS is far more efficient (okay, it has some drawbacks (e.g. IE) that LaTeX doesn’t but…).

If you are curious and want to see what I’ve done, here are my files:

LaTeX source file PDF render The picture which is used in the document My custom document class

Oh, and I’m still looking for a work around for my Pages problem!

Posted in None at February 4th, 2010. View Comments.

Simple mail server report

Here is a small script I wrote a few minutes ago. It gather some informations from the local machine and send them by email to the administrator (me). I plays nice with a @weekly rule in Cron.

It is easily customizable without further explanation. However, I think some enhancements should be added (multiple recipients, generic information addition etc.)

#!/bin/bash

# Configuration
SUBJECT="Server repport of `date +%m.%d.%y`"
EMAIL="root@domain.tld"
MSG="/tmp/weekreport"
touch $MSG

# Uptime
echo "Uptime" >> $MSG
echo "`uptime`" >> $MSG
echo "" >> $MSG

# Disk usage
echo "Disk usage" >> $MSG
echo "==========" >> $MSG
echo "" >> $MSG
echo "`df -h`" >> $MSG
echo "" >> $MSG

# Lighty status
echo "Lighttpd" >> $MSG
echo "========" >> $MSG
echo "`/usr/local/etc/rc.d/lighttpd status`" >> $MSG
echo "" >> $MSG

/usr/bin/mail -s "$SUBJECT" "$EMAIL" < $MSG
rm $MSG
Posted in None at January 21st, 2010. View Comments.

About Apple’s Magic Mouse

In short: wow!

I recognize my not really inventive attitude, but I think there is no better summarize about my feelings.

The Apple Magic Mouse

Look

Well, just by itself, the mouse is really beautiful. I admit it would not be worse with a soft white light coming from the Apple logo, or from the sides of the mouse, but I think it looks really nice on my black desk. Furthermore its bright tactile surface reflects as a mirror does which makes the mouse “pop”.

Feel

My dear old PC mouse

My dear old PC mouse

My Apple computer is a Macbook Pro (of de 5th family I think. It looks like theses ones and costs me 1200 €), so it has a built-in mutltitouch trackpad which works very well. However, I missed my dear old PC mouse. You know, there is something really different between a trackpad and a mouse : the depth. The Magic mouse is really nice from this point of view: it allies the power of the multitouch technology and, with its subtle curves, the presence of a classic computer mouse.

First approach

There is nothing easier than connecting this mouse with your OS X based computer. Just power on the mouse (with a little brushed button like the power on/off on iPod Nano). If Bluetooth is enabled on your computer, a window should pop up, print you some messages, and disappear. That’s it. The mouse is running on your Mac. It’s a bit strange at first, but I got used to its smooth surface blazingly fast.

Get ready to ride

Since the mouse is available to sale, you can read everywhere that you must use MagicPrefs. That’s why I downloaded it to custom my mouse gestures. This tool is really nice (I don’t understand why Apple doesn’t provide such a software with Snow Leopard). But it has one major drawback: it doesn’t support tab (⇥) composed keyboard shortcuts. I wanted to use them for my Firefox (with ⌃⇧⇥ and ⌃⇥ to switch between opened tabs). After digging, let’s say, 2″40 seconds with Google, I found BetterTouchTool, a software similar to MagicPrefs but which is far more flexible (and it works for touchpads too). So I dropped MagicPrefs and installed BTT. Well, I can say I’ve never felt so relaxed with a computer (except when I switch from PHP to Python, but…).

[BetterTouchTool screenshot]

BetterTouchTool

Conclusion

To put it in a nutshell, I highly recommend you this mouse. Unless you are a narrow-minded conservative fundamentalist of keyboard as the only real interface with a computer, the Magic Mouse is really pleasant and easy to use. A nice purchase in my humble opinion.

Posted in None at January 21st, 2010. View Comments.

Quicksort C++ implementation

Hello. I just had to implement a quicksort algorithm version in C++ for an exercise. Here is what I’ve done:

The code on friendpaste.com

#include <iostream>
#include <vector>

using namespace std;

void swap(int &a, int &b)
{
    int temp;
    a = b;
    b = temp;
}

int split_array(vector<int>& array, int pivot, int start_index, int end_index)
{
    int left_boundary = start_index;
    int right_boundary = end_index;

    while (left_boundary < right_boundary) {

        while (pivot < array[right_boundary] && right_boundary > left_boundary) {
            right_boundary--;
        }

        swap(array[left_boundary], array[right_boundary]);

        while (pivot >= array[left_boundary] && left_boundary < right_boundary) {
            left_boundary++;
        }

        swap(array[right_boundary], array[left_boundary]);
    }

    return left_boundary;
}

void quicksort(vector<int>& array, int start_index, int end_index)
{
    int pivot = array[start_index];
    int split_point;

    if (end_index > start_index) {
        split_point = split_array(array, pivot, start_index, end_index);
        array[split_point] = pivot;
        quicksort(array, start_index, split_point-1);
        quicksort(array, split_point+1, end_index);
    }
}
Posted in None at January 19th, 2010. View Comments.