tag:blogger.com,1999:blog-87244799494601067542024-02-01T23:40:32.691-08:00Charlie's Second BlogGuillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.comBlogger36125tag:blogger.com,1999:blog-8724479949460106754.post-20911337774424805472014-02-17T04:11:00.000-08:002014-02-17T04:11:29.815-08:00This blog has movedThis blog has moved to <a href="http://blog.noctua-software.com/">http://blog.noctua-software.com</a>
I finally decided to host my blog on my own machine. Please update your bookmark ;)Guillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.com0tag:blogger.com,1999:blog-8724479949460106754.post-41339144304401431092013-07-02T05:51:00.003-07:002013-07-02T10:05:11.432-07:00Object Oriented in C
<p>I decided to write this post because a few people were surprised when I told them I make video games in C (and not in C++). What I am told is that since a video game usually requires an object oriented design, using C++ is more suitable to the task. I disagree with this common opinion: writing object oriented code in C is not only possible but, I might even argue, easier than in C++.</p>
<p>Before I enter into the matter, I need to say that I am not against C++. It does indeed have a few interesting features that C does not have. I decide not use C++ in my games because, from my experience, the risk of messing up the code with no way to go back once you realized it outweigh the relatively small convenience you get from it. Yet, some people manage to use C++ in a successful way, and I think that is usually because they <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml">enforce strict guideline about what features can be used</a>.</p>
<p>So let's go back to video games. Usually the basic design of a game is to have a common class for all the game objects and then for each type of object (player, enemies, doors, decor, etc.) we create a sub-class. Each sub class reimplements a few methods like "iter", "render". We maintain a list of all the game objects and the engine is responsible for looping over them and calling "iter" and "render".</p>
<p>Of course at first glance C++ seems to be the perfect choice to implement this kind of design. We could have something like:</p>
<pre><code>class Object {
public:
virtual void iter(float dt);
virtual void render();
private:
Vec pos;
// ...
};
class Player : public Object {
// ....
};
class EnemyA : public Object {
// ....
};</code></pre>
<p>Then we could implement Player::iter to update the player position when we press a key, and EnemyA::iter to move the enemy the way we want it.</p>
<p>(Note that in practice it is not efficient to have such a "render" method, because the nature of modern GPU makes it better to batch the rendering of all the entities of a game, but this is not really important for my argument).</p>
<p>In C, there are several ways of implementing the same design, all making use of function pointers.</p>
<p>Since C++ user are rarely exposed to function pointer, lets quickly remind the somehow awkward syntax to define them:</p>
<pre><code>static void my_func(int x) {printf("hello %d\n", x);}
// Here the variable func_ptr is pointing the the function my_func.
void (*func_ptr)(int x) = my_func;</code></pre>
<p>So here is how we could do Object oriented in C: Each base object we create keep pointers to all the implementations of its methods, we then need to create a special constructor function for each type of objects, equivalent to the C++ constructor:</p>
<pre><code>struct Object {
void (*iter)(struct Object *this, float dt);
void (*render)(struct Object *this);
Vec pos;
};
static void player_iter(struct Object *this, float dt) { ... }
static voif player_render(struct Object *this) { ... }
Object *create_player()
{
struct Object *ret = calloc(1, sizeof(*ret));
ret->iter = player_iter;
ret->render = player_render;
return ret;
}</code></pre>
<div class="figure">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.blogger.com/blogger.g?blogID=8724479949460106754" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIM-vRqxTlrpYam0xHh18Z0floWUtsD_C8xHFifiuiPWlR350J1gG71o5uDAFXTtekAx_epBpzrFrnTfLZmyklzWiEFm2wQbWHNjXFNazYV_ovisIBaa_T9guHsDjfN6vgv5qzlrcEYpIL/s687/hierarchy.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIM-vRqxTlrpYam0xHh18Z0floWUtsD_C8xHFifiuiPWlR350J1gG71o5uDAFXTtekAx_epBpzrFrnTfLZmyklzWiEFm2wQbWHNjXFNazYV_ovisIBaa_T9guHsDjfN6vgv5qzlrcEYpIL/s320/hierarchy.png" width="320" /></a></div>
</div>
<p>Calling a method of an object is simple, we just need to remember to pass the "this" argument as first parameter, since C won't do it for you.</p>
<pre><code>Object *object = create_player();
object->iter(object, dt);</code></pre>
<p>Of course we are wasting a lot of memory by storing those function pointer for each object. If this is an issue, we can use instead a single pointer to a "v-table" struct that we share among objects of the same type. But for the sake of simplicity I prefer to skip this for the moment. Also this structure offers the interesting possibility to dynamically change the methods of an active object. This can be used in game to simulate state changes. Let say your enemy has two possible states: patrolling, and attacking. If we were to use C++ it would be complicated to implement this using the language classes features. Here we could simply change the "iter" pointer of the object at any time during the game to make it behave differently:</p>
<pre><code>void enemy_patrolling(Object *this, float dt)
{
...
if (player_in_sight)
this->iter = enemy_attacking;
}
void enemy_attacking(Object *this, float dt)
{
...
if (end_attack)
this->iter = enemy_patrolling;
}
Object *create_enemy()
{
struct Object *ret = calloc(1, sizeof(*ret));
ret->iter = enemy_patrolling; // Initial state.
...
return ret;
}</code></pre>
<p>One point I didn't cover is how to create specific attribute to the sub classes. I will talk about this in a next post.</p>
Guillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.com1tag:blogger.com,1999:blog-8724479949460106754.post-61425991807317819722013-01-30T08:38:00.003-08:002013-01-30T08:38:52.299-08:00Voxel Invaders ported to javascript using emscripten<p>We just released a <a href="http://noctua-software.com/voxel-invaders/play">javascript version</a> of our game <a href="http://noctua-software.com/voxel-invaders">voxel invaders</a> that can run on any browser with webgl support.</p>
<p>Turns out the port was pretty easy, and I didn't have to write a single line of javascript.</p>
<p>So how did we do it? Since our game was written entirely in C, we used <a href="https://github.com/kripken/emscripten/wiki">emscripten</a> to compile our source code directly to JavaScript. For those who don't know, emscripten is an LLVM backend that generates JavaScript code, so if a project is written in a language that can be compiled by clang, then it is in theory possible to make it run on a browser.</p>
<p>Of course there are a few restrictions, and in our cases we had to make some changes to the code before we could have it running properly on a browser:</p>
<ul>
<li><p>Emscripten has no support for client side arrays in OpenGL. Even though it has a pretty good support for OpenGL ES2 via webgl, using client side arrays is not supported. This is not really a problem: we just used array buffer everywhere we had client side arrays.</p></li>
<li><p>Some standard C functions are missing. The one that really hit me was <code>strsep</code> that we used in the levels parsing code. In that case I just modified the code to use <code>strtok_r</code> instead. As a bonus, it turns out the code using <code>strtok_r</code> was actually cleaner than the original one.</p></li>
<li><p>Sound. When doing a portable game, sound is probably the most complicated part. For the graphics, using Opengl ES2 pretty much works on every possible platforms, but for the sounds, there is still no clear standard library that can be used everywhere. So, as we already had an openAL and an OpenSL ES backends for the desktop and android versions, we created an other sound backend using <code>SDL_mixer</code> for the javascript version. [By the way, I always find it funny that OpenSL ES -that has been done by the same company behind OpenGL- is such a complicated mess compared to OpenAL].</p></li>
</ul>
<p>All in all, it wasn't that hard to port the game to JavaScript. The performances are probably not as good as it would have been if we had rewritten the game manually in javascript, but the amount of work done was negligible.</p>Guillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.com0tag:blogger.com,1999:blog-8724479949460106754.post-9586430477926415562012-10-07T01:23:00.000-07:002012-10-13T21:32:01.143-07:00Video Game in C: using X macros to define game data<p>As my brother and I recently released our last video game <a href="http://www.noctua-software.com/projects/voxel-invaders">voxel
invaders</a> on android
and symbian, I though I would share some of the technical details about it.
For my the first post I will talk about a quite useful, although rarely used, C
trick known as "X macros", and how we can use it to simplify game code.</p>
<p>The code is written in plain C, and the original design was very simple: all
the elements of the game are stored in a structure (called <code>obj_t</code> in the code)
that looks like that:</p>
<pre><code>struct obj_t {
int type;
float pos[3];
float speed[3];
sprite_t *sprite;
// A lot of other attributes follow...
};
</code></pre>
<p>The important attribute of the structure is the first one: <code>int type</code>. This
value allows us to differentiate all the kinds of objects in the game (in C++ I
would have probably used subclassing instead). We can see it as a pointer to
the object class, except that it is not a real pointer but an index on an array
of a structure <code>obj_info_t</code> that contains all the information about a type of
object (the game equivalent of a C++ class).</p>
<p>file <strong>objects.h</strong>:</p>
<pre><code>struct obj_info_t {
const char *sprite_file;
float initial_speed[3];
void (*on_hit)();
// Lot of other attributes...
};
enum {
PLAYER,
ENEMY_A,
ENEMY_B,
// And so on...
OBJ_COUNT
};
</code></pre>
<p>file <strong>objects.c</strong>:</p>
<pre><code>obj_info_t obj_infos[] = {
// PLAYER
{
"data/img1.png", // sprite_file
{0, 1, 0}, // initial speed
NULL // on hit
},
// ENEMY_A
{
"data/img2.png", // sprite_file
{1, 2, 2}, // initial speed
enemy_a_on_hit // on hit
},
// And so on..
};
</code></pre>
<p>By the way, this kind of design was mostly inspired by the code of the original
doom game by John Carmack.</p>
<p>The first improvement we can do is to realize that since we are using C98, we
can make the array declaration look better using designated initializers:</p>
<p>file <strong>objects.c</strong>:</p>
<pre><code>obj_info_t obj_infos[] = {
[PLAYER] = {
.sprite_file = "data/img1.png",
.initial_speed = {0, 1, 0},
},
[ENEMY_A] = {
.sprite_file = "data/img2.png",
.initial_speed = {1, 2, 2},
.on_hit = enemy_a_on_hit,
},
// And so on.
};
</code></pre>
<p>See how the code already looks nice and simple. Although this is how our code
looked like for a while, at some point we started to get annoyed by a problem
with this pattern. The problem is that every time we define a new enemy, we
need to modify too files: the file containing the object types enum, and the
file containing the object infos array. Beside, since there is no way to
separate the array or the enum into several files, those two files got bigger
and bigger. This might not seem too bad, but really it is, specially when you
have to find the definition of a given object in the thousand of lines of code
containing the <code>obj_infos</code> array.</p>
<p>As I mentioned, the original doom engine also used this kind of pattern, and I
think the way they overcame this problem was to use a special tool that would
automatically generate the C code for both the enum and the array. </p>
<p>In our case I though writing a C generator tool would be overkill. That is
where I realized that there is a simple way to have the C preprocessor
generates those two parts (enum and global array) for us. Later when I
searched for occurrences of this pattern online I found out this is known as "X
macros", there is a very <a href="http://www.drdobbs.com/the-new-c-x-macros/184401387">comprehensive
article</a> about it from
Randy Meyers.</p>
<p>The idea behind C macros is to use a C preprocessor macro that, depending on
the context, will expand to either the enum part, either the array initializer
part.</p>
<p>In our simple case, it would be something like this:</p>
<p>file <strong>object_defs.h</strong>:</p>
<pre><code>OBJ(PLAYER,
.sprite_file = "data/img1.png",
.initial_speed = {0, 1, -},
)
OBJ(ENEMY_A,
.sprite_file = "data/img2/png",
.initial_speed = {1, 2, 2},
.on_hit = enemy_a_on_hit,
)
</code></pre>
<p>file <strong>object.h</strong>:</p>
<pre><code>#define OBJ(name, ...) name,
enum {
#include "object_defs.h"
}
</code></pre>
<p>file <strong>objects.c</strong>:</p>
<pre><code>#define OBJ(name, ...) [name] = {__VA_ARGS__},
obj_info_t obj_infos[] = {
#include "object_defs.h"
}
</code></pre>
<p>And so, thanks to this trick, we just need to modify the <code>objects_def.h</code> file
to add or remove an object type. Both our enum and our global array will be
automatically updated by the preprocessor at compile time. As a bonus, this
makes it easy to split the object definitions into several files. For that we
just need to #include all the needed files instead of just <code>object_defs.h</code>.</p>Guillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.com2tag:blogger.com,1999:blog-8724479949460106754.post-29961439457292268262012-09-23T09:39:00.002-07:002012-10-07T05:22:43.330-07:00Voxel Invaders : space invader + 3d voxels<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAEkA75LyZp-V27sCEFuw8qHRY-4F5KhDTRoY_zhnf4msBtIciS-GHDbtm8lxWFgt60RnuFAHKxoarCDTtGukWOScQShVvVM1eZ2T_5BVHJmR9JZ6HAUOqtgATcPNUYnTyvupDj_8T2uZs/s1600/promo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="156" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAEkA75LyZp-V27sCEFuw8qHRY-4F5KhDTRoY_zhnf4msBtIciS-GHDbtm8lxWFgt60RnuFAHKxoarCDTtGukWOScQShVvVM1eZ2T_5BVHJmR9JZ6HAUOqtgATcPNUYnTyvupDj_8T2uZs/s320/promo.png" width="320" /></a></div>
<br />
<br />
This week we (noctua software) released our new video game for android phone: <a href="https://play.google.com/store/apps/details?id=com.noctuasoftware.voxelinvaders">voxel invaders</a>.<br />
This is the sequel of our previous game <a href="https://play.google.com/store/apps/details?id=com.noctuasoftware.retrocosmos2">Retrocosmos</a>,
and it follows the same principle (making a fun space invader game for
touch screen devices). Only this time we used 3d voxels (the equivalent
of pixels in 3d) for all the graphics.<br />
<br />
Voxels based games are starting to appear more and more and are
particularly interesting for independent developers because it is much
easier to generate a voxel model than a traditional 3d model.<br />
<br />
Anyway back to the game: this has been written almost entirely in C
using android ndk, with just a few java code for some of the stuffs the
ndk does not allow to do easily (like controlling the device vibrator). I
wrote the engine from scratch, using opengl es 2 for the rendering, and
some interesting C hacks using macro for the enemies behaviour state
machines (maybe I'll do an other post on that an other time). The good
thing about that is that if the game is a success it will be quite easy
to port it to other platforms like iOS or symbian.<br />
<br />
From a marketing point of view, we did two versions of the game: a <a href="https://play.google.com/store/apps/details?id=com.noctuasoftware.voxelinvaders_demo">free demo</a> and a <a href="https://play.google.com/store/apps/details?id=com.noctuasoftware.voxelinvaders">full paid version</a>.
We have little experience of this kind of approach so I might do a
follow up an other time about how much money we made from that.<br />
<br />
Here is a video of the gameplay:<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/RW5idfEPkpw?feature=player_embedded' frameborder='0'></iframe></div>
<br />Guillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.com2tag:blogger.com,1999:blog-8724479949460106754.post-6764026611788830002011-09-23T05:45:00.000-07:002011-09-23T05:47:37.158-07:00Ascii art Tetris gameI was bored so I wrote this little online <a href="http://darshak.free.fr/asctriis/asctriis.html">tetris game in ascii art</a>.<br /><br />I hope someone will have fun playing it.Guillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.com2tag:blogger.com,1999:blog-8724479949460106754.post-1427419884955445842011-07-10T08:37:00.000-07:002011-07-10T08:44:09.862-07:00Voxpaint, an opensource 3d voxels painterThis is the first release of a small 3D voxels painter I had been working on recently.<br /><br /><div>For the moment it cannot do much, but I am planning to use to create some video game graphics.<br /></div><br /><div>The code is hosted on launchpad: <a href="https://launchpad.net/voxpaint">https://launchpad.net/voxpaint</a><br /></div><br /><div>Check out the videos:</div><br /><br /><iframe width="480" height="390" src="http://www.youtube.com/embed/Bh9BNtpWlPY" frameborder="0" allowfullscreen=""></iframe><br /><br /><iframe width="480" height="390" src="http://www.youtube.com/embed/fy-VzY7gxUo" frameborder="0" allowfullscreen=""></iframe>Guillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.com1tag:blogger.com,1999:blog-8724479949460106754.post-15978940477235121792011-06-28T09:02:00.000-07:002011-06-28T09:38:53.461-07:00Compiling Qt mobility for Simulator on WindowsThese days I am working on a Symbian application using Qt 4.7.3 and Qt mobility 1.2.0.<br /><br />Since the last version of Qt SDK doesn't ship Qt mobility 1.2.0 for the simulator, I had to recompile it myself. Since it took me some time, I write a step by step how to to help people who are trying to do the same thing.<br /><br />The only real problem is that the SDK for windows doesn't include all the headers files needed to compile the sources. So I copied them from my linux installation of the SDK.<br /><ol><li>Make sure you have the latest version of Qt SDK. As I write it it is the version 1.1.2, including Qt 4.7.3 and Qt mobility 1.1.3. In my case the SDK is installed into c:\QtSDK.</li><li>Get the sources of qt mobility for the simulator from its <a href="http://qt.gitorious.org/%7Eqtbynokia/qt-mobility/simulator-mobility">git repo</a><a href="http://qt.gitorious.org/%7Eqtbynokia/qt-mobility/simulator-mobility">sitory</a>. Note that it is not the same repository as for Symbian or desktop version.</li><li>Two directories are missing in the the simulator source on windows:<span style="font-weight: bold;"><br /></span><ul><li>c:\QtSDK\Simulator\Qt\mingw\include\private</li></ul><ul><li>c:\QtSDK\Simulator\Qt\mingw\include\QtGui\private</li></ul>So what I did is copied those directory from my linux partition where Qt SDK was installed (from the directory ./QtSDK/Simulator/Qt/gcc/include).</li><li>In a windows console, set up the PATH to include all the needed tools. You need qmake from the Simulator SDK, perl, and makew32-make:<br /><br /><span style="font-style: italic;">set PATH=c:\QtSDK\Simulator\Qt\mingw\bin;%PATH%</span><br /><span style="font-style: italic;">set PATH=c:\QtSDK\mingw\bin;%PATH%</span><br /><span style="font-style: italic;">set PATH=c:\QtSDK\Symbian\tools\perl\bin\;%PATH%</span><br /><br /></li><li>Run configure. In my case I didn't need the messaging module and since it requires dependencies I removed it from the list of modules using the -modules argument of the command:<br /><br /><span style="font-style: italic;">configure -modules "bearer contacts gallery location publishsubscribe multimedia systeminfo serviceframework</span> sensors versit organizer feedback connectivit<span style="font-style: italic;">y"<br /><br /></span></li><li>Run the make command:<br /><br /><span style="font-style: italic;">mingw32-make<br /><br /></span></li><li>Finally install everything:<br /><span style="font-style: italic;"><br />mingw32-make install</span></li></ol>After this I was able to compile and run applications using qt mobility 1.2.0 on the simulator.Guillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.com9tag:blogger.com,1999:blog-8724479949460106754.post-12943284569245151362011-05-02T15:28:00.001-07:002011-05-02T15:37:14.536-07:00Gedit plugin to emulate emacs alt-qHere is a <a href="https://github.com/guillaumechereau/gedit-reflow-plugin">small gedit plugin</a> for all the people who are like me on an <a href="http://www.gnu.org/software/emacs/">emacs</a> rehab.<br /><br />If there is one emacs feature I really miss when using <a href="http://projects.gnome.org/gedit/">gedit</a> -which is by the way a great text editor- this is the alt-q command (fill-paragraph), that automatically reformats the current paragraph according to the margin width.Guillaumehttp://www.blogger.com/profile/04248189602756889056noreply@blogger.com2tag:blogger.com,1999:blog-8724479949460106754.post-10921950379639145952011-02-21T08:58:00.000-08:002011-04-25T05:06:22.721-07:00from org-mode to zimIn a <a href="http://charlie137-2.blogspot.com/2009/05/org-mode-will-i-finally-get-organized.html">previous post</a> I shared my enthusiasm with <a href="http://orgmode.org/">org-mode</a>, the great emacs module for keeping notes and getting things done.<div><br /></div><div>At the time I was using org-mode for pretty much everything : taking notes, keeping my contacts list, monitoring the time spent working on different projects, etc.</div><div style="text-align: center;"><br /></div><div>But these days, even though I still think org-mode is one of the most powerful notes taking system out there, I don't use it anymore. Now I am using a mix of <a href="http://live.gnome.org/ProjectHamster">hamster</a> and <a href="http://zim-wiki.org/">zim</a>. Here is the list of reasons that made me switch from org-mode:</div><div><br /></div><div><br /></div><div><b>1. I don't use emac</b><b>s anymore.</b></div><div><b><br /></b></div><div><b><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZQDTqd0mOURR0TX_RrjH0Ejy9mrpvPaFoOuoksR2r0pKJeY_BSLbbZHbIY_VvJ512kPkao-vd7ieBTKcaD4q1lYD9iWsFAnCYeSaYlA4ICeL3l76nFeglw4eRjek0g2y_4hNAFXAN4AE/s320/emacs.png" style="cursor:pointer; cursor:hand;width: 320px; height: 108px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5576191945956732818" /></b></div><div><br /></div><div> I am not going to start the old flame war about emacs vs other text editors, but the fact is that org-mode is only useful for people who know how to use emacs. I don't like to use too many different tools, I am already currently using gedit, netbeans and vim. Having to use emacs at the same time confuses me too much.</div><div><br /></div><div><b>2. No integration with gnome</b></div><div><b><br /></b></div><div><b><content="text charset="utf-8""><span class="Apple-style-span" style="font-weight: normal; "><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI-LSMkNq3I04zBTlc48j52hzZ8YQngNP1Rd1-AS8EdAs61_yK-KMWIwzm-mojbT3AxhyphenhyphenSj1n3SX1GguTkV1elEav_zL6vjYJOtmg90f1VlkktbCZh478RjKUgFF-EVcMa0_oGU-bqLH8/s1600/gnome.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI-LSMkNq3I04zBTlc48j52hzZ8YQngNP1Rd1-AS8EdAs61_yK-KMWIwzm-mojbT3AxhyphenhyphenSj1n3SX1GguTkV1elEav_zL6vjYJOtmg90f1VlkktbCZh478RjKUgFF-EVcMa0_oGU-bqLH8/s320/gnome.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5576192487185132402" style="cursor: pointer; width: 320px; height: 180px; " /></a></span></content="text></b></div><div><b><br /></b></div><div> </div><div> This is specially important for time tracking. I need to be able to see at every moment the task I am working on, and be able to change it in a few seconds. With org-mode I had to switch to the workspace where I run emacs, then enter several commands to see the current task and changing it. Very often when working on a task I would forget to start or stop the timers. In contrast, hamster always show very clearly in the gnome bar what I am doing and the time spent on the task. A simple click and I can stop the task and start a new one.</div><div><br /></div><div><b> 3. Too complicated (but this is related to the point 1)</b></div><div><br /></div><div> </div><div> Not really a problem for people who use emacs all the time, but when I use it only for org-mode, then I spent many time simply learning the commands. Getting Things Done is all about spending time doing things, not learning about how to do things.</div><div><br /></div><div><b> 4. Zim organization of files is much better for my needs</b></div><div><br /></div><div><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7-hMd7fqVcY8L2H5alXtnuja_5-_FRoLl9JjF2D9ws9yGIGeVWillxSC9fTrwkZqydW0V_-2guqmlWaQJnIJFQIl459S_gNztGZgeMuHUeDVpcmRa1OkJ8-_befWBmPOEohgvBn-m3wQ/s1600/zim.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7-hMd7fqVcY8L2H5alXtnuja_5-_FRoLl9JjF2D9ws9yGIGeVWillxSC9fTrwkZqydW0V_-2guqmlWaQJnIJFQIl459S_gNztGZgeMuHUeDVpcmRa1OkJ8-_befWBmPOEohgvBn-m3wQ/s320/zim.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5576192886505204802" style="cursor: pointer; width: 320px; height: 266px; " /></a></div><div><br /></div><div> The most important thing that org-mode (and zim) got right is that all the data should be stored in plain text files that can be read and edited by any text editor. This way I can always access my notes no matter where. Now the problem with org-mode is that if it works very well with one file per project, it doesn't scale well for wiki style notes where you have many small text files linked to each other. Zim on the other hand make it super easy to have as many files as needed. Each file is automatically added into the ~/Notes directory, which is exactly what I want. On the left</div><div><br /></div><div><b><span class="Apple-style-span">So, here is the typical way I use zim and hamster</span> :</b></div><div><br /></div><div>Every morning after I turn on my computer (and I am done reading blogs and emails), I click on the hamster notification to start a new task. The timer always remind me of what I am supped to do, and this is a good physiological fence that prevent me from focusing on anything else that</div><div>the current task.</div><div><br /></div><div>I keep a general Zim note for each project I am working on, that mostly look like a TODO file. Before I start to work I can read it and see what are the important things I should do.</div><div><br /></div><div>If I suddenly have an idea or find a link that would be useful for a task that is not the one I am working on, I open zim (takes half a second) and add the idea/link in the relevant note.</div><div><br /></div><div>When I find useful general informations, I add then into my personal wiki that is also managed by zim.</div><div><br /></div><div>Every time hamster reminds me that I have been working for more that one hour on a task, I allow myself to make a pause, and eventually switch task.</div><div><br /></div><div>At the end of the day I can review the total time I spent working during the day.</div><div><br /></div><div>In the end my workflow is pretty much the same as before, but the overall experience is much better than it was with org-mode.</div><div><br /></div><div>Now of course there are some things I wish I could get from zim / hamster</div><div><br /></div><div><b> 1. Tables</b></div><div> </div><div> This is the killer feature of org-mode, and to be honest the only reason I still sometime turn on emacs these days. org-mode just make it super easy to edit tables.</div><div><br /></div><div><b> 2. Calendar integration</b></div><div> I would love to have gnome automatically parsing my notes for entry containing dates and adding them in the calendar. Once again org-mode had it almost right, except that they don't care about gnome or any other desktop. For them the working environment is emacs.</div><div><br /></div><div><b> 3. Better wiki syntax and text editing</b></div><div> Disclaimer : I am a fan of restructured text, and I wish that every wiki would use its syntax.</div><div> Being a programmer, I feel more comfortable working with mono-spaced font, with if possible a way to automatically format the lines to 80 characters. Currently zim don't allow to edit the notes directly in plain text, and I understand it is the better option for most people, but that is one of the cases where I think more choices would be good.</div><div><br /></div><div><span class="Apple-style-span"><b>So should you use org-mode or zim / hamster or something else ?</b></span></div><div><br /></div><div>My opinion: If you already use emacs a lot (and if you like it), then go for org-mode, you can do pretty much anything with it and it can be quite enjoyable to use.</div><div><br /></div><div>If you don't like emacs, and use gnome, then go for zim/hamster. You can get 80/100 of what you get with org-mode, and you won't spend much time learning it.</div><div><br /></div>Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com1tag:blogger.com,1999:blog-8724479949460106754.post-80758474996741848082011-02-08T02:39:00.000-08:002011-02-08T02:40:17.667-08:00Chatocracy released<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhscC8za6JXgzPJCCpuQBfp127lIS4xpnqPg_L64JAC4uMOng_7UpoTkAK9I3e83VqzP9lkk5k9emmO1AI257muvTCDGH3NfoQyvXuYNcz668awYT6a2d5GD8qnK9YYZPkQXYjEdzIuEGM/s1600/logoName.png"><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 310px; height: 42px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhscC8za6JXgzPJCCpuQBfp127lIS4xpnqPg_L64JAC4uMOng_7UpoTkAK9I3e83VqzP9lkk5k9emmO1AI257muvTCDGH3NfoQyvXuYNcz668awYT6a2d5GD8qnK9YYZPkQXYjEdzIuEGM/s400/logoName.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5571266544269369730" /></a><br /><br /><br /><div><br /></div><div><a href="http://www.chatocracy.com/">Chatocracy</a> is a website that allows people to have one to one conversations on the webcam. After each conversation you can rate the person you have been talking to ; the better ranking you get, the more people you can talk to.<br /><br />My brother and me have been working on this for the last few weeks. It is still beta so if you encounter problems please report it.<br /><br />url : http://www.chatocracy.com<br /></div><div><br /></div>Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com0tag:blogger.com,1999:blog-8724479949460106754.post-75044560795428128692010-02-28T20:45:00.001-08:002010-02-28T20:48:27.036-08:00Laoshi release 0.1.0<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_T4IqPwi8aLKMqq7A9wsat7QGkmiYDDSSSIsF6G6sP6NCmmh0leE4WwpwAjwH9RNtzqWp_7zejpcDF7DqottBq3ADlwP1Yj1y4D6_jpR5m6MDQMm0Tew8XL8fL-0-eOC5hFQjBESXu1c/s1600-h/laoshi.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 96px; height: 96px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_T4IqPwi8aLKMqq7A9wsat7QGkmiYDDSSSIsF6G6sP6NCmmh0leE4WwpwAjwH9RNtzqWp_7zejpcDF7DqottBq3ADlwP1Yj1y4D6_jpR5m6MDQMm0Tew8XL8fL-0-eOC5hFQjBESXu1c/s400/laoshi.png" alt="" id="BLOGGER_PHOTO_ID_5443522204662735682" border="0" /></a>I announce the first release of laoshi, my Chinese learning application. In this release I include four lessons for beginners. The code and files can be downloaded from the <a href="http://code.google.com/p/laoshi/">google code</a> page.Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com0tag:blogger.com,1999:blog-8724479949460106754.post-90566382387041060382010-02-20T02:18:00.000-08:002010-02-20T02:28:14.603-08:00laoshi : A Chinese learning application<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG6yydLqf4IDNuznh5yplcHoG8WzjkvoFHbOh2hVQiUE8R9HRQGDwHsCzn-YJZXRqT3HCjsTWiXTnJU4p34AT5aB5wFaX3VZhv84koSbE4svWiLouUr_ZJpRfWnhif3_d6Y4B01_VF6NU/s1600-h/Screenshot-Laoshi.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 372px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG6yydLqf4IDNuznh5yplcHoG8WzjkvoFHbOh2hVQiUE8R9HRQGDwHsCzn-YJZXRqT3HCjsTWiXTnJU4p34AT5aB5wFaX3VZhv84koSbE4svWiLouUr_ZJpRfWnhif3_d6Y4B01_VF6NU/s400/Screenshot-Laoshi.png" alt="" id="BLOGGER_PHOTO_ID_5440269701976819298" border="0" /></a><br />I had some free time recently so I created a small application to learn Chinese. The name "laoshi" is the pinyin for "老師" which means "teacher".<br /><br />For the moment the application features :<br /><ul><li>A dictionary, using the database from <a href="http://us.mdbg.net/chindict/chindict.php?page=cedict">cedict</a> containing more than 90,000 entries.</li><li>A lessons viewer, with automatic dictionary lookup when we pass the mouse over the text.</li><li>A flash card player.</li><li>Two lessons that I wrote for beginners.</li></ul>I wrote everything in python using gtk for the interface, so it should work on every platform. I don't provide any package yet, but people interested can check the code at <a href="http://code.google.com/p/laoshi/">google code</a>.Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com2tag:blogger.com,1999:blog-8724479949460106754.post-28292841974602568052010-02-03T05:57:00.000-08:002010-08-11T18:14:42.589-07:00Writing a resume using reStructuredText<a href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> (rst) is a simple markup language perfect for writing documentation. Altough it may not be as powerful as Latex, it is much simpler to use.<br /><br />I decided to give a try at using rst to create my resume : here is the <a href="http://darshak.free.fr/cv/cv.rst">input file</a>.<br /><br />Now, thanks to this <a href="http://code.google.com/p/rst2pdf/">rst to pdf converter</a> project (written in my <a href="http://www.python.org/">favourite language</a>), I can easily generate a nice pdf version of my resume. Here is the <a href="http://darshak.free.fr/cv/cv.pdf">resulting pdf</a>.<br /><br />This approach has many advantages compared to my previous way of doing (using open office). I can easily update the document, change the style, and generate my resume not only in pdf, but also in html or almost any formats I want.<div><br /></div><div>[edit] : as some people pointed out, the input file for my CV needs an extra file for the style. This file can be found <a href="http://darshak.free.fr/cv/cv.pdfstyle">here</a>.</div>Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com30tag:blogger.com,1999:blog-8724479949460106754.post-9243624829570632142009-11-19T06:49:00.000-08:002009-11-19T07:01:25.511-08:00monitor long compilation timeFor people who like me like to keep logs of everything they do, this little script can be used to automatically add entries into a log file before and after running a long command.<br /><br />It fits nicely into my org-mode system, I put the logs entries into an org file and they then appear into my agenda :<br /><br /><pre class="src src-sh"><span style="color: rgb(205, 0, 0);">=====================================================================<br />#</span><span style="color: rgb(205, 0, 0);">!/bin/bash<br /></span><br /><span style="color: rgb(205, 0, 0);"># </span><span style="color: rgb(205, 0, 0);">Automatically logs the task given as argument into my org log file.<br /></span><span style="color: rgb(205, 0, 0);"># </span><span style="color: rgb(205, 0, 0);">This is useful when running long compilations.<br /></span><br /><span style="color: rgb(205, 205, 0);">LOG_FILE</span>=/home/guillaume/Org/Logs.org<br /><span style="color: rgb(205, 205, 0);">CMD</span>=$@<br /><br /><span style="color: rgb(205, 205, 0);">TMP_FILE</span>=$(<span style="color: rgb(205, 0, 205);">tempfile</span>)<br /><span style="color: rgb(205, 205, 0);">LABEL</span>=$(<span style="color: rgb(205, 0, 205);">pwd</span>)<br /><br /><span style="color: rgb(0, 0, 238); font-weight: bold;">echo</span> <span style="color: rgb(0, 205, 0);">"* start: ($LABEL) $CMD <$(</span><span style="color: rgb(205, 0, 205);">date</span><span style="color: rgb(0, 205, 0);"> +'%F %a %R')>"</span> >> $<span style="color: rgb(205, 205, 0);">LOG_FILE</span><br /><br /><span style="color: rgb(205, 205, 0);">STAT_FORMAT</span>=<span style="color: rgb(0, 205, 0);">"\<br /> - time :: %E<br /> - retun status :: %x<br />"</span><br /><br /><span style="color: rgb(0, 205, 205); font-weight: bold;">trap</span> ctrl_c INT<br /><br /><span style="color: rgb(0, 205, 205); font-weight: bold;">function</span> ctrl_c() {<br /> <span style="color: rgb(0, 0, 238); font-weight: bold;">echo</span> <span style="color: rgb(0, 205, 0);">"* killed: ($LABEL) $CMD <$(</span><span style="color: rgb(205, 0, 205);">date</span><span style="color: rgb(0, 205, 0);"> +'%F %a %R')>"</span> >> $<span style="color: rgb(205, 205, 0);">LOG_FILE</span><br /><br /> <span style="color: rgb(0, 205, 205); font-weight: bold;">exit</span> -1<br />}<br /><br />/usr/bin/time -o $<span style="color: rgb(205, 205, 0);">TMP_FILE</span> -f <span style="color: rgb(0, 205, 0);">"$STAT_FORMAT"</span> $<span style="color: rgb(205, 205, 0);">CMD</span><br /><br /><span style="color: rgb(0, 0, 238); font-weight: bold;">echo</span> <span style="color: rgb(0, 205, 0);">"* end: ($LABEL) $CMD <$(</span><span style="color: rgb(205, 0, 205);">date</span><span style="color: rgb(0, 205, 0);"> +'%F %a %R')>"</span> >> $<span style="color: rgb(205, 205, 0);">LOG_FILE</span><br /><br />cat $<span style="color: rgb(205, 205, 0);">TMP_FILE</span> >> $<span style="color: rgb(205, 205, 0);">LOG_FILE</span><br />rm $<span style="color: rgb(205, 205, 0);">TMP_FILE</span><br />=========================================================================<br /><br /></pre>Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com0tag:blogger.com,1999:blog-8724479949460106754.post-4361210193744271662009-08-07T10:22:00.000-07:002009-08-07T10:40:34.220-07:00Check python coding style on the fly with emacs<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYXpDwQArNlh2wxkWtPpsVP8F5R1rY8yeVh-oL5zraRqadqYgZnThKwX_dj7coMegaXCyfTG6J7uw1wGBwQHaPHxOK39CFn7C5xrq99c8yDmZ1w2PNPgaVt2ihNrEodoy-EWdNSREhjVc/s1600-h/flymode.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 237px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYXpDwQArNlh2wxkWtPpsVP8F5R1rY8yeVh-oL5zraRqadqYgZnThKwX_dj7coMegaXCyfTG6J7uw1wGBwQHaPHxOK39CFn7C5xrq99c8yDmZ1w2PNPgaVt2ihNrEodoy-EWdNSREhjVc/s400/flymode.png" alt="" id="BLOGGER_PHOTO_ID_5367274996832795698" border="0" /></a><br />A nice emacs trick : using <a href="http://flymake.sourceforge.net/">flymake-mode</a> and this <a href="http://svn.browsershots.org/trunk/devtools/pep8/pep8.py">python code styles PEP8 checker script</a> written by Johann C. Rocholl, we can have automatic real time checking for standard python coding style.<br /><br />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 :<br /><pre><br />(when (load "flymake" t)<br /> (defun flymake-pylint-init ()<br /> (let* ((temp-file (flymake-init-create-temp-buffer-copy<br /> 'flymake-create-temp-inplace))<br /> (local-file (file-relative-name<br /> temp-file<br /> (file-name-directory buffer-file-name))))<br /> (list "pep8.py" (list "--repeat" local-file))))<br /><br /> (add-to-list 'flymake-allowed-file-name-masks<br /> '("\\.py\\'" flymake-pylint-init)))<br /></pre><br />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.Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com9tag:blogger.com,1999:blog-8724479949460106754.post-88662291764042745102009-06-13T09:17:00.000-07:002009-06-13T09:22:47.098-07:00Fluid dynamics engineAfter I read <a href="http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf">this paper</a> I decided to try to write a small two dimensions fluid dynamics engine for video games. It is quite fun.<br /><br />Now I need to see what I could use it for.<br /><br /><object height="344" width="425"><param name="movie" value="http://www.youtube.com/v/Uez4jwg1gu8&hl=en&fs=1&rel=0"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/Uez4jwg1gu8&hl=en&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="344" width="425"></embed></object>Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com0tag:blogger.com,1999:blog-8724479949460106754.post-54954917036843600262009-05-31T22:58:00.000-07:002009-05-31T23:02:35.949-07:00Tichy 1.1.0 releasedYesterday I released <a href="http://code.google.com/p/tichy/">tichy 1.1.0</a>. 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.<br /><br />See the <a href="http://tichy.googlecode.com/svn/release/1.1.0/README">release notes</a>.<br /><br /><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Zv8t3XtNF5w&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Zv8t3XtNF5w&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com1tag:blogger.com,1999:blog-8724479949460106754.post-68414406296105189412009-05-05T04:02:00.000-07:002009-05-05T04:04:11.082-07:00ditaaNever used it nor planing to do so soon, but I like the idea a lot : <a href="http://ditaa.sourceforge.net/">ditaa</a>.Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com0tag:blogger.com,1999:blog-8724479949460106754.post-65418126900802039052009-05-05T03:40:00.000-07:002009-05-05T04:08:29.134-07:00Tichy's new style<div style="text-align: left;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZoO59lijuEZo_8_t5H07PSjh7Dbjwr1CaRdt38sxw_y9jEOWxP0wrx8etRO_VXEzKXDkoXBGZxEyQBExclv68XtGeB5c2X3HGLGszCgmjPz4WPvdJhL8WFlyKZVxNsejduGI1N5P9gfI/s1600-h/frame.png"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 128px; height: 128px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZoO59lijuEZo_8_t5H07PSjh7Dbjwr1CaRdt38sxw_y9jEOWxP0wrx8etRO_VXEzKXDkoXBGZxEyQBExclv68XtGeB5c2X3HGLGszCgmjPz4WPvdJhL8WFlyKZVxNsejduGI1N5P9gfI/s320/frame.png" alt="" id="BLOGGER_PHOTO_ID_5332291251128139314" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnEGp8-LCo5rJpOVH7kD8rX18Np7_ao-s5zu9GLae_e4ZFMSlGLe6zNei9-0_W59DZweBoHAs1Ra1UvOtVqnOdYwlCaWxJJj8CLNPanBrIbPpDrM0ciMHZy_az6Dix177UyMbdPO3jvzY/s1600-h/message.png"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 240px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisgEusC1j5KTmg-XPx-ouLfWphvVpUw5AYjjYmYPImN_Vzrwft7WqkQ1s0aI9Kfuv2r0F3w8jtZdsEUdockmRDbEJHo-aE9lXXe6Lu8Lqbj0g9LLoNQROV6gR2IQTBDjyG6xJTB34fmxo/s320/home.png" alt="" id="BLOGGER_PHOTO_ID_5332291379877643778" border="0" /><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 240px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnEGp8-LCo5rJpOVH7kD8rX18Np7_ao-s5zu9GLae_e4ZFMSlGLe6zNei9-0_W59DZweBoHAs1Ra1UvOtVqnOdYwlCaWxJJj8CLNPanBrIbPpDrM0ciMHZy_az6Dix177UyMbdPO3jvzY/s320/message.png" alt="" id="BLOGGER_PHOTO_ID_5332291590263247842" border="0" /></a><br /></div>Today I created a new style for <a href="http://code.google.com/p/tichy/">tichy</a>'s widgets.<br /><br />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.)<br /><br />This is not very flexible because it only allows 8x8 corners size for all the widgets, but here simplicity beats flexibility.<br /><br />My previous style was done using <a href="http://www.gimp.org/">the gimp</a>. This time I decided to use <a href="http://www.inkscape.org/">inkscape</a> instead. Inskape is one of the best open source software I know. Perfect for this kind of job.<br /><br />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.Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com2tag:blogger.com,1999:blog-8724479949460106754.post-70273744541555176062009-05-03T05:27:00.000-07:002009-06-28T02:57:53.103-07:00Org-mode : will I finally get organized ?<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://orgmode.org/img/tasks.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 523px; height: 341px;" src="http://orgmode.org/img/tasks.png" alt="" border="0" /></a><br /><br />I always had a love/hate relation to emacs, but recently I found a good reason to start using it a lot again : <a href="http://orgmode.org/">org-mode</a>.<br /><br />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).<br /><br />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.<br /><br />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.<br /><br />Until now my optimal solution for keeping organized was to use :<br /><ol><li>A directory containing basic text files, one per project, idea or people.</li><li>A TODO text file.<br /></li><li>A piece of paper on my desk where I would write every mornings the tasks for the day.<br /></li></ol>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 :<br /><ol><li>One org file per project I am working on.</li><li>One org file for all my contacts information.</li><li>One org file for other small tasks or ideas (things to buy, etc...)</li></ol>I also created a cron job to email me everyday the weekly calendar as well as the list of pending tasks.<br /><br />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.<br /><br />I have been using it for only a few weeks now, but I can already tell it makes things much easier than before.Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com2tag:blogger.com,1999:blog-8724479949460106754.post-6104491936435601082009-03-14T08:48:00.000-07:002009-03-14T08:59:05.875-07:00Coroutines in C<a href="http://www.chiark.greenend.org.uk/%7Esgtatham/coroutines.html">this article</a> by <a href="http://pobox.com/%7Eanakin/">Simon tathan</a> is fascinating.<br /><br />Simon explains how we can use some very dirty tricks to create coroutines directly in C, without using the setcontext functions.<br />It relies on a very strange feature of C that I didn't know about : being able to put a <span style="font-style: italic;">case</span> statement inside a sub-block of the <span style="font-style: italic;">matching</span> switch statement !<br /><br />I really recommend the lecture of the article to anybody interested in coroutines, even though as Simon says :<span style="font-style: italic;"> "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!"</span>Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com0tag:blogger.com,1999:blog-8724479949460106754.post-86992431640698810162009-01-22T07:15:00.000-08:002009-01-22T07:36:17.949-08:00online javascript game, in python<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp7K0qWMlyed_wzDJAmLC22sui5VwMExQ4nhDYdIDE04y3hqoNE80VDIFyvOENp13bdEfmPGD2xFsEkCKsjQQ9akNGR26p37bPdl00L6m2xW-cgv3O6ScN6PAEz5DuaEsbd9LluQAAmvQ/s1600-h/Screenshot.jpg"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 257px; height: 258px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp7K0qWMlyed_wzDJAmLC22sui5VwMExQ4nhDYdIDE04y3hqoNE80VDIFyvOENp13bdEfmPGD2xFsEkCKsjQQ9akNGR26p37bPdl00L6m2xW-cgv3O6ScN6PAEz5DuaEsbd9LluQAAmvQ/s320/Screenshot.jpg" alt="" id="BLOGGER_PHOTO_ID_5294138090107666578" border="0" /></a><a href="http://charlie137-2.blogspot.com/2009/01/pypy-is-great.html">Last time</a> I spoke about <a href="http://codespeak.net/pypy/dist/pypy/doc/">pypy</a>, which allow (among other things) to translate python code into other languages.<br /><br />This week I wrote a small video game (inspired by the famous <a href="http://en.wikipedia.org/wiki/Boulder_Dash">boulder dash</a> game) in rpython and used pypy to create an online version of the game out of it.<br /><br />You can play the game <a href="http://darshak.free.fr/Boulder/static.htm">here</a>.<br />The sources can be found <a href="http://darshak.free.fr/Boulder/">here</a>.<br /><br />The game as it is now is not really fun, but I only wrote it as an example of using pypy.<br /><br />What I like with this approach is that I can develop in rpython, and even run the game using python interpreter, and only before I publish it use pypy to create the javascript version.<br /><br />I could also create a C version using the same code for the game engine (only the graphic functions would have to be rewritten for each backends.)<br /><br />This open the door to a lot of interesting applications.<br /><br />On a side note, the pypy javascript translation is really not optimised. For example, let's try to guess what this generated function does :<br /><br /><pre><span style="font-family:courier new;">function (){</span><br /><span style="font-family:courier new;"> var v1086,v1087,self_145;</span><br /><span style="font-family:courier new;"> var block = 0;</span><br /><span style="font-family:courier new;"> for(;;){</span><br /><span style="font-family:courier new;"> switch(block){</span><br /><span style="font-family:courier new;"> case 0:</span><br /><span style="font-family:courier new;"> self_144 = this;</span><br /><span style="font-family:courier new;"> self_145 = self_144;</span><br /><span style="font-family:courier new;"> block = 1;</span><br /><span style="font-family:courier new;"> break;</span><br /><span style="font-family:courier new;"> case 1:</span><br /><span style="font-family:courier new;"> v1086 = 'H';</span><br /><span style="font-family:courier new;"> block = 2;</span><br /><span style="font-family:courier new;"> break;</span><br /><span style="font-family:courier new;"> case 2:</span><br /><span style="font-family:courier new;"> return ( v1086 );</span><br /><span style="font-family:courier new;"> }</span><br /><span style="font-family:courier new;"> }</span><br /><span style="font-family:courier new;">}</span><br /><br /></pre>I don't want to spoil the fun of figuring this out by giving the answer...Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com6tag:blogger.com,1999:blog-8724479949460106754.post-89874499640389451982009-01-11T01:36:00.000-08:002009-01-26T08:07:00.903-08:00Pypy is greatEven though I was in holidays recently, I spent some time to have a look at the update from the <a href="http://codespeak.net/pypy/dist/pypy/doc/home.html">pypy project</a>.<br /><br />I get really excited by what the project has achieved so far.<br /><br />Pypy is a python interpreter written in python.<br />The most interesting part of the project is the ability to use it to translate python code into other languages, like C, java, javascript, and LLVM.<br /><br />So far only a subset of python language is translatable (for example generators won't work.) [<span style="color: rgb(255, 0, 0);">edit:</span> as the pypy people pointed out, full python language will <span style="font-weight: bold;">never</span> be translatable, that is not the goal of the project.]<br /><br />But this simplified python (called RPython) is already good enough for many projects. As an example pypy interpreter itself is written in RPython and so can be compiled into machine code.<br /><br />The good thing about this is that you can develop an application totally in python and then use the translators to generate fast machine code. So python could become some sort of universal language that replaces all other languages.<br /><br />An other interesting things about pypy is the ability to generate stackless code, that allow many cool things, like tasklets (see the <a href="http://codespeak.net/pypy/dist/pypy/doc/stackless.html">documentation</a> about this).<br /><br />Now I can't help thinking about OpenMoko paroli project, that uses python and tasklets. Could it be possible to use pypy to translate the python code into machine code and so create optimized version of paroli ?<br /><br />The idea is very seducing, but many problems would need to be solved before we can get to there. The first thing is that we would have to modify our code to remove all the things that are not supported by pypy.<br /><br />The second things is that even though pypy supports tasklets, it is impossible to do it using the python yield statement and the trick explained in <a href="http://www.python.org/dev/peps/pep-0342/">PEP342</a>.<br /><br />An other good use of pypy would be to create web application without having to write -quite ugly- javascript code.Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com4tag:blogger.com,1999:blog-8724479949460106754.post-39676863468915185252009-01-11T00:54:00.000-08:002009-01-11T01:36:18.735-08:00Paroli get a websiteHappy new year everybody !<br />I just come back from holidays, and haven't worked for a few weeks, but now I am back to Taipei where I still work for OpenMoko, with a few news about our next software stack :<br /><br />The tichy project had a lot of modifications ; it is now entirely based on etk and edje (part of <a href="http://en.wikipedia.org/wiki/Carsten_Haitzler">raster</a> <a href="http://www.enlightenment.org/">enlightenment</a> windows manager). It has also been renamed "paroli-core". We loose the ability to use different graphic back-ends, but the other features are still presents. Paroli-core offers :<br /><ul><li>Signal / slot objects (à la Qt.)</li><li>A service system to allow user to register and retrieve python object based on there role.</li><li>A tasklet library for easy creation of chained callback function.</li><li>A plug-in system.</li><li>A set of services that create a layer between the plug-ins and Mikey <a href="http://www.freesmartphone.org/index.php/Main_Page">FSO framework.</a><br /></li></ul><br />The <a href="http://www.paroli-project.org/">Paroli project</a> based on paroli-core started.<br />The project includes paroli-core (ex tichy), plus a set of applets that aim at providing basic telephony functionalities.<br /><br />More information (and the sources) can be found from the <a href="http://www.paroli-project.org/">paroli-project web site</a>.Guillaume Chéreauhttp://www.blogger.com/profile/05367152763264281576noreply@blogger.com0