Rework by 37signals

I did a one-month internship at Novapost.fr on August (more about this in a future blog entry). When I left, they offered me Rework, the latest book of 37signals. It was the first time I read a business book, so I wondered whether its content would keep my interest. A week later, I can tell it is the book I’ve the most enjoyed reading. Ever.

To sum it up, Rework is a succession of tips and best practices you should consider when you are starting your business, thinking about it or even already on board. It goes from takedowns to promotion through many topics such as productivity, competitors and evolution (among many others). The book is rather short (something like 300 pages with pictures, big margins and big letters) but it is explicitly meant to be.

I obviously can’t tell about the truth and the accuracy of the content because I am not an expert and I’ve never started any business.

However David Heinemeier Hansson and Jason Fried have an awesome writing style! They express thoughts with such a strength that they seem to you as established, obvious facts. As far as I’m concerned this way of formulating ideas without nuances nor never-ending sentences has an incredible power on me. The KISS principle applied to written communication. Very pleasant.

The best is that they use this style to punch universally acknowledged “truths” which seem very questionable afterwards. The fact is that I have barely worked in companies (take a look at my bio: I’m an near-18 year old student), still I haven’t got any problem understanding described problems and considering the advantages of the provided solutions. Moreover, their ideas basically look like my vision of a near perfect company to work for, so I am very pleased to see them written by professional and creative people.

Like they say, the book is not based on academic theories but on their experience. So they give real-world examples throughout the book which enhances the feelings of completeness and sustainability I had about the corresponding ideas. By the way I wonder how the authors got these examples: did they look for them while writing the book or are they part of their earlier knowledge? Anyhow, the examples make authors’ thoughts feel real (let’s say, not shaped for an imaginary, perfect world like some of the books we all had or still have to read for school).

I only regret one thing: I think they don’t talk enough about publicizing your product during the launch (unless I missed something). That’s to my mind both a pretty important and rather difficult moment.

To conclude, if you are looking for nice tips on getting your project off the ground through a business, or even just if you want to learn an unusual way to see business management, I highly advise you to read this book!

Posted in None | Tagged | View Comments

Rails-like configuration style for Django

Django’s default settings system is not very suitable for multiple configuration profiles — development, testing, production and so on: you have the settings.py, and that’s it. As far as I’m concerned, my settings are sometimes very different between my notebook and for instance my production server. First of all, it is obviously out of the question to change the settings.py on deployment. Some people append at the end of their settings.py a simple from deploy import *, surrounded by a try / except ImportError clause. In my opinion this workaround is neither sexy nor flexible. I finally decided to use the Rails way to manage configuration in my latest pet project.

The principle is simple: replace the content of the settings.py by the one provided further, create a config/ directory, as if it is an application, and in this folder, put the default configuration in init.py, and add a Python module per configuration profile. You should come up with something like that:

Files tree

Files tree

The default profile is ‘development’ (read the settings.py). If you want to use a specific profile, prepend DJANGO_ENV=”theprofile” to your shell command. It must become very long to type this at each command, that’s why I recommend you to add this line to the ‘bin/activate’ script of the corresponding virtualenv, or in your ~/.bash_profile.

Posted in None | Tagged | View Comments

Websocket + Tornado + Redis

Here is a simple example of a Websocket + Tornado + Redis Pub/Sub protocol interaction. The principle is very simple: when your user loads the page, she is automatically added to a list of “listeners”. An independent thread is running: it listens for messages from Redis with the subscribe command, and send a message through Websocket to every registered ”listener”. In this example, the user can send a message to herself with a simple AJAX-powered form, which calls a view with a payload (the message), and the view publish it via the publish command of Redis.

This is basically a web chat! If you want to have fun, you can then add a roster, with a presence system, authentication etc…

Posted in None | Tagged , , , | View Comments

Python dictionaries differences

Here is a simple function I wrote a week ago. It computes the differences between two dictionaries, and returns them as a list of tuples. I’m still not sure about its usefulness…

Posted in None | Tagged | View Comments

Python dynamic module loading

The following function allows you to load every Python modules contained in a folder. Useful to create plugins systems.

Posted in None | Tagged | View Comments

Hg update hook

Note for myself : add the following to the .hg/hgrc file to automatically update the repo when a changeset is pushed:

[hooks]
incoming = hg up

Posted in None | Tagged | View Comments

Virtualization as development tool

Okay, the title is not well choosen, that’s because my prefered one is too long for the blog layout: Linux Virtualization for a nicer development workplace.

Why using virtualization? In my opinion, the anwser this quite simple. Today, computers are widely able to virtualize at least one operating system (the guest) without GUI. Consequently you can use a virtual system to run a pre-production or a testing environement, more similar to the final production system, and without spoiling your so loved work environement. In my case, I use a virtual machine which runs the exact same software as the final production server does (NGinx, Gunicorn, Django, CouchDB, RabbitMQ, Debian), so I can for example solve many deployment problems, well, before they happen! Furthermore, virtual machines are containted in files. Want to see what would happen if you would upgrade your production server to the latest version? Just copy your current VM, upgrade it, and see the result :) Now that I’m sure you want to virtualize thousands of system, let take a look at the way I achieve this.

In this example, I use Ubuntu Lucid as host and Debian Lenny as guest.

First, install kvm and qemu in your Ubuntu host:

sudo apt-get install kvm qemu

If you (like me) run an Intel-based computer, load the proper kernel module:

sudo modprobe kvm-intel

Now let’s add your user to the kvm group (you must run KVM machines from a user who is in the kvm group) :

sudo adduser thomas kvm

Then create a folder for our virtualized systems:

mkdir ~/Virtualization

Create a file which will contain our VM (here I ask it to use a dynamic-sized file: only the used space will be written on the hard disk, and it can be up to 6GB):

qemu-img create -f qcow2 Virtualization/base.img 6G

Download Debian Lenny.

Let’s start the VM with the downloaded ISO mounted in the cdrom drive, and allow it 256MB of memory:

kvm -m 256 -cdrom ~/Téléchargements/debian-504-i386-netinst.iso -boot d Virtualization/base.img

Then install Debian the way you like it.

Finally, run your VM:

kvm -m 256 Virtualization/base.img
Posted in None | Tagged , | View Comments

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
Posted in None | Tagged , | View Comments

FreeBSD : Static IP

This is a simple memorandum. In order to assign a static IP to a FreeBSD computer, just add the following to /etc/rc.conf:

    ifconfig_sk0="inet 192.168.0.42 netmask 255.255.255.0"
    defaultrouter="192.168.0.1"

Posted in None | Tagged | View Comments

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.

Posted in None | Tagged | View Comments