Federico's Hacks

None of these are polished programs. Use them at your own risk. If something breaks, you get to keep both pieces.

Performance scripts

Right now these only contain plot-timeline.py, a script to plot timelines that help you see where a program spends its time.

Check them out like this:

git clone git://gitorious.org/performance-scripts/mainline.git performance-scripts

Read the instructions on how to instrument your code first so that the timeline script will know what to plot.

Here is the project page at Gitorious for the performance-scripts.

Phonebook in C# and gtk-sharp

phonebook.tar.gz (3.7 KB) — 2006/Feb/24

This is a simple phonebook written in C#, using the gtk-sharp toolkit.

It is mainly a demonstration of how to use the Gtk.TreeView widget in a very simple fashion, and store the phonebook data in XML format.

Activity Log for Emacs

activity-log.el (12.8 KB) — 2004/Dec/02

I wrote an ad-hoc chunk of Emacs Lisp to maintain my activity log. With it, I can hit C-x 4 n to create a new entry in my activity log. After I'm done writing a new entry, saving the file will cause this to happen:

  1. The saving hooks will scrape the HTML in the news.html file, looking for daily chunks.

  2. Those daily chunks will be put in archive files called news-YYYY-MM.html. For example, the archive for July 2004 is called news-2004-07.html.

  3. All the daily chunks from news.html will be munged into an rss.xml file for aggregators.

There is a lot of hard-coded stuff: file names, style sheets, the magic chunks of HTML that get sought for and which indicate the start/end of daily chunks. If you change the basic structure of the HTML, things will break. The code also requires that you install the psgml package for Emacs, which allows you to edit SGML and XML nicely, and also that you install the HTML 4.0 DTDs and that you make them visible to psgml. You'll probably want to grab my own news.html, see which style sheet files it loads, download them, and start playing.

Nice things about this code:

Not so nice things:

If you don't like this, you may prefer Lame Blog, a Mono-based weblog system.

Dynadraw for GTK+

gddraw.tar.gz (9.8 KB) — 1998/Nov/15

Dynadraw is a very cool trick to filter mouse positions so that you can draw calligraphic strokes nicely. It does this by modeling the brush as a physical object with inertia, mass, and friction.

Nat Friedman did the initial port from GL to Xlib, and then I hacked it to use GTK+ instead. The original Dynadraw code was snarfed from Grafica Obscura, a cool page of graphics hacks. The original code is by Paul Haeberli.

Note that the code above is for GTK+ 1.2.x, or perhaps 1.0.x. It is really old! Porting it to GTK+ 2.x should be trivial, but I haven't even compiled it in a few years now.