Friday, 7 August 2009

Check python coding style on the fly with emacs


A nice emacs trick : using flymake-mode and this python code styles PEP8 checker script written by Johann C. Rocholl, we can have automatic real time checking for standard python coding style.

To make this work I copied the script (pep8.py) in my PATH, and then I added this block of code in my .emac file :

(when (load "flymake" t)
(defun flymake-pylint-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pep8.py" (list "--repeat" local-file))))

(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pylint-init)))

After this I can just enable flymake mode when I edit a python file, and every coding style error will be highlighted on the fly.

Saturday, 13 June 2009

Fluid dynamics engine

After I read this paper I decided to try to write a small two dimensions fluid dynamics engine for video games. It is quite fun.

Now I need to see what I could use it for.

Sunday, 31 May 2009

Tichy 1.1.0 released

Yesterday I released tichy 1.1.0. In this new release a lot of internal refactoring, improvement of the style system, the text editor, the terminal, and the PIM applications. I also added some unit tests using py.tests.

See the release notes.

Tuesday, 5 May 2009

ditaa

Never used it nor planing to do so soon, but I like the idea a lot : ditaa.

Tichy's new style


Today I created a new style for tichy's widgets.

The way we can create widgets style is very simple : we create 32x32 sized png images for each frame. The image is cut so that each 8x8 sized corner will correspond to the associated widget frame corner, the top will be used to fill the top of the widget frame and so on (see the image.)

This is not very flexible because it only allows 8x8 corners size for all the widgets, but here simplicity beats flexibility.

My previous style was done using the gimp. This time I decided to use inkscape instead. Inskape is one of the best open source software I know. Perfect for this kind of job.

I went for a very bright style, so that we can read the phone screen even outside. I also decided to use no gradient or effect at all, this increases the feeling of simplicity that I want to have in Tichy.

Sunday, 3 May 2009

Org-mode : will I finally get organized ?



I always had a love/hate relation to emacs, but recently I found a good reason to start using it a lot again : org-mode.

org mode allows to keep notes and TODO list using a simple text format. Basically you can type what you want and every line starting with "TODO" will be interpreted as a task, every date enclosed by "<" and ">" as an agenda entry, every text enclosed by "[[" and "]]" as a link. (Check the website for more detailed documentation).

It is a very complicated thing to find a way to keep organized and productive, specially when we have to deal with different projects, involving a lot of information.

One thing I did learn from the past is that online tools like google calendar or personal wiki don't work for me. I am just too lazy to take the time to go online to update my wiki or calendar. Very often when I think of a task I have to do, I am already working on something else, and I don't want to spend time going online and getting through a web interface just to write a few lines of text.

Until now my optimal solution for keeping organized was to use :
  1. A directory containing basic text files, one per project, idea or people.
  2. A TODO text file.
  3. A piece of paper on my desk where I would write every mornings the tasks for the day.
This worked fine as long as I didn't have to deal with complicated schedules and deadlines. It is not the case anymore and so I had to change my system. The system I am using now is :
  1. One org file per project I am working on.
  2. One org file for all my contacts information.
  3. One org file for other small tasks or ideas (things to buy, etc...)
I also created a cron job to email me everyday the weekly calendar as well as the list of pending tasks.

What I really appreciate with this new system is the fact that I can create TODO or agenda entries from anywhere. Org-mode will automatically harvest all the tasks and agenda entries and create a nice summary for me.

I have been using it for only a few weeks now, but I can already tell it makes things much easier than before.

Saturday, 14 March 2009

Coroutines in C

this article by Simon tathan is fascinating.

Simon explains how we can use some very dirty tricks to create coroutines directly in C, without using the setcontext functions.
It relies on a very strange feature of C that I didn't know about : being able to put a case statement inside a sub-block of the matching switch statement !

I really recommend the lecture of the article to anybody interested in coroutines, even though as Simon says : "this trick violates every coding standard in the book. Try doing this in your company's code and you will probably be subject to a stern telling off if not disciplinary action!"