2009-05-20

How to uninstall a python program, packaged with distutils (setup.py)

So you have installed a program by running something like sudo setup.py install and want to remove it, without forgetting a file or mess with the system ?
It's simple in fact. Install checkinstall. And run sudo checkinstall python setup.py install to create a package for your system, and remove it with dpkg -r NAME_OF_PACKAGE.
Checkinstall is an handy tool, it replays the install procedure while inspecting what is being done, and creates a package doing the same thing. With uninstall.

2009-04-10

Luc Besson contre la Joconde

"On ne vole pas les tableaux au Louvre il me semble !" -- Luc Besson

Non, on n'a pas le droit de voler la Joconde...
Mais on a le droit d'en avoir une photo.
On a le droit de faire une copie de la photo.
Et le droit de faire une copie de la copie de la photo.
Et la Joconde est toujours en place, épatant non ?

2009-03-01

Nautilus-folder-actions

You want to add buttons in the Nautilus toolbar, all read from a custom file in the current view ?
You want to add a button to launch "git gui" from your code folder ?
So nautilus-folder-action is for you !

2008-06-26

Auto Vectorize Decorator


def vectorize(f):
"""
Allows a traditionnal python function to be called with
iterables arguments.

So when you call func([array]) it will do the iteration for you,
call func() for each element in array, and return an array.

All arguments must be iterable, if you want to pass something else,
use a keyword argument.

"""
def _vectorize(*args, **kwargs):
if not isiterable(args[0]):
return f(*args, **kwargs)
else:
return [f(*arg, **kwargs) for arg in zip(*args)]
return _vectorize

# to use it:

@vectorize
def my_func(arguments):
# do something interesting, on ONE element.

my_func(my_args)
my_func(my_super_list_of_many_values)


2008-03-18

Get a hash of a given module in python

This small function use the inspect and sha modules to return you a hash of the given module/class/function.
Note that we only hash the bytecode, so only really modified code will change the resulting hash.


import inspect

def get_module_hash(root, obj=None, hash=None, verbose=False):
if not obj:
obj = root
if verbose:
print obj.__name__
if not hash:
import sha
hash = sha.new()

for member in inspect.getmembers(obj):
name, child = member

if inspect.ismodule(child):
if child.__name__.startswith(root.__name__):
if child != root:
if verbose:
print child.__name__
hash = get_module_hash(root, child, hash, verbose)

if inspect.isclass(child):
if child.__module__.startswith(root.__name__):
if verbose:
print ' ', child.__name__
hash = get_module_hash(root, child, hash, verbose)

if inspect.ismethod(child):
if verbose:
print ' ', child.__name__
hash.update(child.im_func.func_code.co_code)

if inspect.isfunction(child):
if root.__name__ in child.func_code.co_filename:
if verbose:
print ' ', child.__name__
hash.update(child.func_code.co_code)
return hash

hash = get_module_hash(yourmodule)
print 'version hash:', hash.hexdigest()

2008-02-12

Dose2 - Now in fullscreen splendor

I love the Dose2 [1] demo by mfx, but I always wanted it to run in a better resolution, as it is fully vectorial. So here it is, finally you can run it in 1600x1200 if you dare!

Download the sources [2], compile and run!

You can try the following command line options:
  • -fullscreen : obviously, switch to fullscreen.
  • -stretch : use the current resolution.
  • -nofill : do not apply the magic xor - some kind of wireframe, search fillcopy() in main.c to see some f*cking clever code.
  • -WIDTHxHEIGHT : choose resolution. WIDTH and HEIGHT can be any size.

[1] http://pouet.net/prod.php?which=3289
[2] http://kassoulet.free.fr/files/dose2_2008-05-03.tar.gz (new, 2x faster version!)

Ed: Now also on github.
Ed2: Backbuffer was blitted two times, new version is 2x faster in big resolutions!

2008-01-23

Splitting a mp3 album (mp3+cue) in separate files without recoding

So you have demovibes and you would like to have it with separate tracks so you can skip one?

This is really simple, here is the magic command: (in one line)

mp3splt -c demovibes3.cue demovibes3-80mn_scene_music_compilation_mixed_by_willbe.mp3 -d demovibes3 -o @n-@p-@t

You will need the nice mp3splt of course, and it works also for ogg vorbis!
If you want tags, you can extract them from filenames, with easytag for example.

2007-12-05

How to clear disk cache in Linux


sync ; sudo echo 3 | sudo tee /proc/sys/vm/drop_caches


edit: better safe than sorry: flush caches before, as suggested...

2007-07-30

Vice Dual Sid patch

Here is my crappy patch to Vice 1.21 to add my special 6581 + 8580 stereo output. You can listen to some examples.

After applying the patch, you will just have to select the dual sid option (note that this will also disable the previous dual sid functionality). You will now have both 6581 and 8580 in separate channels, in real time and record mode. Enjoy!

edit: updated patch for Vice 2.0

2007-07-09

Knights demos on youtube.

Yeah I encoded styler2 and schtroumpf2 and uploaded them on youtube.
The quality is rather bad, I will upload high quality videos somewhere else soon.