il ricci furioso

July 30, 2010

l’articolo “Il Ricci furioso” di Massimiliano Panarari, apparso stamattina su MicroMega e’ misteriosamente scomparso

non conosco le ragioni della sparizione, ma google cache ha la memoria lunga e ricorda l’articolo nella sua forma originale.

dato che, pero’, anche google cache dopo un po’ dimentica, ad eterna memoria potete trovare una copia qui (e in formato zip qui).


missing Dec_0 and friends from python decimal

July 29, 2010

This fails in py2.4, py2.5.1 and py2.6:

from decimal import Dec_0

But it works in all the other py2.5 subversions!

It seems that exposing Dec_0 (and other similar constants) was considered a bug and “fixed” on Jan 3rd 2009 by renaming it _Dec_0.

Indeed, if I had looked at the source code, I would have seen that Dec_0 was for “internal use only”.

From /usr/lib/python2.5/

##### Useful Constants (internal use only) ################################

# Reusable defaults
Inf = Decimal('Inf')
negInf = Decimal('-Inf')
NaN = Decimal('NaN')
Dec_0 = Decimal(0)
Dec_p1 = Decimal(1)
Dec_n1 = Decimal(-1)

Those definitions are missing in py2.4 and py2.5.1, and renamed in py2.6.

Damn: never use undocumented features!

wordpress python library

June 6, 2010

today, I found this.

it’s a wonderfully simple Python library to manage your WordPress blog via XML-RPC.


editors’ speed on opening big files

May 17, 2010

while playing with different editors (namely vim and
sam) I tried to time how long some common editors
take to open a big file (~140Mb).

here are the results:

editor real user sys
ed 4.866s 3.440s 3.440s
vim 2.086s 0.836s 0.232s
nano 16.264s 15.361s 0.172s
sam way too long

then, for curiosity, I timed less with and without (-n) line numbering:

less 3.552s 0.200s 0.072s
less -n 0.182s 0.016s 0.016s

not sure what to do with these numbers, yet…

charm, markdown and wordpress

April 28, 2010

following my previous post, a nice enhancement is using markdown to filter your post before submitting it to wordpress.

you can either filter it in your preferred editor (vim uses the ! command) or invoke the formatter (for example, markdown) from charm: command x.


trivial terminal speed benchmark

April 28, 2010

today, while playing with st, I tried a very simple benchmark.
here it is:

	$> time seq -f 'teeeeeeeeeeeeeeeeeeeeeeeeeeeeeest %g' 999999

here are the results:

	xterm: 0m28.508s
	rxvt: 0m8.568s
	st: 0m12.082s

all the terminals shared the same fonts, but xterm and rxvt had saveLines=1024 set for scrolling purposes, feature that st lacks.

being st at such an early stage of development, I think this is a good result.

surf browser hints /3

January 9, 2010

another couple of hints about surf, after my previous post.

honestly, I stopped using surf after 0.3 release. I think that the authors stripped out of the code too much sugar that, not being suckless, was nonetheless useful: a status bar showing the current URI, for example. now URI editing is done via xprop and dmenu, which is great piece of software, but not always user friendly (it does not have editing capabilities).

moreover bookmarking is a pain as it relies on external shell scripts. or does it not?

I realized that there is no need to use external shell scripts, as they can be “embedded” in C code. Here is how.

in config.h put these lines, right before the definition of keys[]:

#define BM_PICK { .v = (char *[]){ "/bin/sh", "-c", \
"xprop -id $0 -f _SURF_URI 8s -set _SURF_URI `cat ~/.surf/bookmarks | dmenu || exit 0`", \
winid, NULL } }

#define BM_ADD { .v = (char *[]){ "/bin/sh", "-c", \
"(echo `xprop -id $0 _SURF_URI | cut -d '\"' -f 2` && cat ~/.surf/bookmarks) | sort -u > ~/.surf/bookmarks_new && mv ~/.surf/bookmarks_new ~/.surf/bookmarks", \
winid, NULL } }

then inside keys[] definition, add:

{ MODKEY, GDK_b, spawn, BM_PICK },

now, recompile. in your shiny new surf, CTRL-B pops-up dmenu with the list of bookmarks and CTRL-SHIFT-B adds the current page to the bookmarks (making sure to remove duplicate entries).

no need for shell scripts!

dwm restart

January 8, 2010

dwm is a wonderful window manager for X: it’s small, fast and stable.

the only thing I missed, until today, was the possibility to restart it without losing my X session (i.e. all the open windows, etc.). restarting dwm is something you might need to do often, as it does not have config files: changes are done by recompiling the sources.

the trick is to execute dwm in background and sleep forever!

take a look at the last two lines of my .xinitrc:

dwm &

where sleeper looks like this:

while `/bin/true`; do
sleep 1000

now, if you kill dwm (usually with ALT-SHIFT-q) the windows (and X) will still be alive and you can type dwm& in any xterm to get dwm up and running again.

if you really want to quit X, you need to kill the sleeper.

installing pcf fonts in X

January 7, 2010

as I keep forgetting, here is how to install pcf fonts in X

  1. create a new directory for the fonts, usually under /usr/share/fonts:
    $> mkdir /usr/share/fonts/
  2. copy the pcf file(s) into it (sometimes the pcf files are gzipped):
    $> cp /path/to/pcf/*.pcf* /usr/share/fonts/
  3. run mkfontdir, to create a fonts.dir file, used by X to find font files
    $> mkfontdir /usr/share/fonts/
  4. add the new dir to X font path. The easiest way to do it is to stick this line in your .xinitrc:
    xset fp+ /usr/share/fonts/

now your new font should compare in xfontsel and you should be able to use it as normal.

by the way, this is a very nice font for programming!

the List and the Truth

September 13, 2009

Spoon Boy: Do not try and bend the list. That’s impossible. Instead . . . only try to realize the truth.
Neo: What truth?
Spoon Boy: There is no list.
Neo: There is no list?
Spoon Boy: Then you’ll see that it is not the list that bends; it is only yourself

from “Practical Common Lisp