Thomas Pelletier



Untitled

I'm a French (young) student fond of IT, math and physics.






FollowedFollowedFollowedFollowedFollowedFollowedFollowedFollowedFollowed

Theme by spaceperson Powered by Tumblr

klammer
thrilld.com

I just joined thrilld.com!

10:45 pm, by thomaspelletier

thrilld.com

I just joined thrilld.com!

10:44 pm, by thomaspelletier

thrilld.com

I just joined thrilld.com!

10:43 pm, by thomaspelletier

(Source: phosphorescene)


Gunicorn / Django Debian init script

This is a simple Debian init.d script for my self-hosted Django/Gunicorn websites. Note that it runs inside a virtualenv (my installed Django versions are different in each virtualenv). If you have questions: comment this post!

#!/bin/sh 

### BEGIN INIT INFO
# Provides:       seismic_web
# Required-Start: $local_fs $syslog
# Required-Stop:  $local_fs $syslog
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Short-Description: Gunicorn processes for seismic_web
### END INIT INFO

# www-data is the default www user on debian
USER=www-data
NAME="seismic_web"
GUNICORN_RUN="gunicorn_django"
# Confdir: the Django project inside the virtualenv
CONFDIR="/home/thomas/seismic_web/seismic_web"
VENV_ACTIVATION=". ../bin/activate"
RETVAL=0
# PID: I always name my gunicorn pidfiles this way
PID="/tmp/gunicorn_"$NAME".pid"

# source function library
. /lib/lsb/init-functions


start()
{
    echo "Starting $NAME."
    cd $CONFDIR;
    su -c "$VENV_ACTIVATION; $GUNICORN_RUN" $USER && echo "OK" || echo "failed";
}

stop()
{
    echo "Stopping $NAME"
    kill -QUIT `cat $PID` && echo "OK" || echo "failed";
}

reload()
{
    echo "Reloading $NAME:"
    if [ -f $PID ]
    then kill -HUP `cat $PID` && echo "OK" || echo "failed";
    fi
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        reload
        ;;
    reload)
        reload
        ;;
    force-reload)
        stop && start
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        RETVAL=1
esac
exit $RETVAL
04:49 pm, by thomaspelletier

Ticky

I just release the first version of Ticky, a free, simple and unobtrusive OS X application which helps you to manage your daily tasks. As it’s my first complete ObjC/Cocoa application, I will probably write some posts on problems I have encountered.

06:16 pm, by thomaspelletier

Use Markdown with Wordpress

By default, Wordpress only allows you to write your posts in HTML (in the case you have not noticed the built-in WYSIWYG editor creates and renders HTML). However, there are many ways to mark up your texts on the web (HTML is not the only one). My favorite is Markdown.

The why

I think that using more document-oriented markup syntaxes has many benefits. For example :
  • Better separation between content and form, which undoubtedly leads to an improvement in interoperability and durability of your data.
  • Having fun with something different (but not really new).

The how (with Wordpress)

Before everything be sure to have the authorization to install new plugins on your Wordpress-powered web site. First, you need to render your markdown texts to HTML. This is where “Markdown for WordPress and bbPress” comes. This plugin will use a PHP markdown parser to render your text. As markdown accepts HTML, you don’t need to worry about your old posts: they will be displayed as they always did. And… that’s it! Don’t forget to take a look at the official Markdown syntax page. If you want a nicer way to type your posts (for example a real-time render of your text), you could use my Wordpress plugin called WP WMD Admin. It will replace your Wordpress text input by WMD, the WYSIWYM Markdown editor.

The limits

Markdown is nice for blogs, or short descriptions. Although it’s not really in the scope of this post, I think that Markdown misses some important markup element. The firsts that come to my mind are:
  • No table of content. It looks like markdown supports the [TOC] command since 2.0 (source)
  • No footnotes.
  • No color.

*Yeah I finally wrote my March post.*

06:16 pm, by thomaspelletier

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.

06:16 pm, by thomaspelletier

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

06:16 pm, by thomaspelletier

Dijkstra%27s 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](http://friendpaste.com/7ml2pWDYzgr0I0ZOiTU6nq)):

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]

06:16 pm, by thomaspelletier