In this section, I began to publish some (a micro-fraction) of the code I wrote in the past years. There are currently two subsections for the following projects:
VigraQt is a small library that allows you to use our VIGRA library with Qt more easily.
fig.py is a python module which you can use to read/create/modify XFig files with python.
I used it to write a sophisticated fig2tikz converter that can convert .fig files into TikZ commands for inclusion in LaTeX. Eventually, it should be able to recognize graphs with text nodes etc. at least in a basic way, but it is very usable already as it stands.
Contents
On this very page you can find some of my smaller scripts that I think to be of general use.
lowerfn
You know the problem: You copy files from another computer, a CD-ROM, a flash memory device or similar, and the files are UPPERCA.SED because of archaic operating systems and/or filesystems. Most often this is accompanied by the fact that the files have their executable bits set, although they're clearly just image files for example.
| File: lowerfn | (7628 bytes; Tue, Dec/02/2008) | |
When Sven asked me which was the simplest way of downcasing filenames that I knew, I quickly quickly wrote a small Python script, since the problem seemed common enough. The first version was trivial, but then we realized additional features that would be nice to have, thus the current version supports:
- quite/verbose modes (--quiet or --verbose, the latter is default)
- command line help (--help)
- be careful and don't overwrite existing files (if --force switch is not given), e.g. if both TEST.PNG and test.png exist in the same directory
- remove exec permissions from files known to contain images/video/audio data
- at first, this was done based on known file extensions
- now, it also supports 'file' magic (needs GNU 'file' with support for mimetype output, activate with --mime)
- leave MixedCase filenames alone
- recognition of filenames with uppercase extensions (e.g. Test.JPG), change only extension of these
- ignore uppercased filenames without extensions (to save standard filenames like README, INSTALL, ... from being renamed)
- overrideable with --renameall, which will simply make everything lowercase
- a pretend-mode, which shows the normal output, but does not carry out the real actions of changing permissions or filenames (--pretend)
Be aware that lowerfn requires Python 2.3 or higher.
| File: cvs-chroot | (4313 bytes; Tue, Dec/02/2008) | |
cvs-chroot
This small script facilitates changing the cvsroot stored in the CVS/Root files, e.g. in order to change a directory checked out from an anonymous server to you own, personal cvs account or vice versa (e.g. for re-distributing directories using your own account).
It does not have commandline help, but it's very easy to use:
- Just issueing cvs-chroot without parameters will output what cvsroots are currently set in this dir and its' subdirectories.
- Calling cvs-chroot <old> <new> will change all cvsroots that are currently set to <old> into <new> (usually, you would cut&paste the output from the previous command for the <old> part).
| File: urls | (2730 bytes; Thu, Mar/20/2008) | |
urls
This script will search one or more files for urls and output them on stdout. There must be different implementations of this tool out there - but I was not happy with the ones I tried. In contrast to some of them, this script does not rely on <a href=...> or sth. like that, but will simply look for stuff that looks like URLs (i.e. also catches Javascript URLs etc.).
Furthermore, it allows to specify a base URL in order to convert relative URLs to absolute ones. I.e. if you downloaded http://www.example.com/subdir/somefile.html, you would use urls -b http://www.example.com/subdir/somefile.html somefile.html to convert links like ../images/bg.jpg into http://www.example.com/images/bg.jpg. If that's what you're looking for. ;-)