Here are programs and utilities written by me. They are published without warranties as usual. Test them before applying to important data.
To use python scripts presented here you need some implementation of Python language interpreter (see also python.org).
Transparent viral persistence for Python
Proof of concept for transparent object persistence implemented in Python. User gives reference to an object and changes to it and all other objects transitively reached from it via attributes become persistent. Changes are written to a log. System state can be restored from that log.
Digital camera pictures copy
This short program copies photos and videos from flash card to a directory on your computer while sorting files into sub-directories by their modification date. It needs a Java runtime to be run. Usage (if you're on Windows): unpack program into a directory, start cmd.exe, go into directory with program and start pcopy.cmd:
pcopy source_directory target_directory
For example:
pcopy.bat H:\ C:\MyMedia
It is written in Scala. To modify it you need Scala 2.8 compiler.
Prevayler implemented in Python
This is implementation of "object prevalence system" AKA Prevayler in Python.
Hessian protocol client implemented in Python
Go to Project's Sourceforge site
Sources of this site
Feeling that I've played enough with XML/XSL generation I decided to write simple template engine in Python. HTML for this site is generated with simple Python script.
enconv (encoding convertor)
This simple utility lets to convert a file written in one character encoding to other encoding (character set). Sthis is extremely simple utility is written in Java and uses java.nio facilities to convert encodings. Available encodings are the same as those available in your Java runtime.
Usage:
java -jar Enconv.jar input-encoding output-encoding input-file output-filefor example:
java -jar Enconv.jar KOI8 UTF-8 myletter.txt utfed-letter.txt
Below is link to archive file containing whole tree of NetBeans project. Compiled JAR is in dist subdirectory
Simple backup copy utility
This script lets to create backups easily and restore files state.
For example, if you want to save a.txt file execute 'bak.py a.txt'. To restore saved state tell 'bak.py -r a.txt'. Note that this utility lets to save several versions of a file in stack-like manner. To find out more options tell 'bak.py --help'.
Download latest bak.py. CHANGES: Additional deletion check. Command line options checked more consistently.
Version 1.1 of bak.py CHANGES: This version lets to specify multiple files at once and lets to make compressed backups (tar+bzip2). Note that command line switches have changed.
DSP folders sorter
This script lets to sort folders in Microsoft Visual C++ v.6 project file
MSVC6 does not sort sub-folders in project view. If you have many of sub-folders in random order it becomes difficult to find something particular. To recursively sort folders in project file tell 'sort_dsw.py project.dsp'
Include directive converter
Lets to retarget relative path references '#include "somefile.h"' of C/C++ preprocessor to other directory. It is useful if you have moved some C/C++ module to different directory and want to correct relative references to it.
This script has been used only once to convert paths in a large software project. Please inspect source to find out how it works.
SourceSafe file updater
This program lets to update your local files from M$ SourceSafe repository. The difference (aside from being command line) is that you are not asked those annoying irritating repetitive silly questions about writable files, confirmation for overwrite and so on. You specify everything in configuration file.
Note to run this you need PyWin32 package which gives python access to COM Windows services. It can be downloaded from sourceforge.net.
Download latest version (1.1) (this version allows recursive item specifications)
Download initial version (1.0)
Flood memory manager
This is defragmenting memory manager with garbage collector. Since no one expressed interest in it, this is rather proof of concept than production quality library. It also suffers to some degree from "second system syndrome" :) as it is reimplementation of original manager which was written completely in "plain" C.
Software volume for alsa-lib
This is a patch for alsa-lib 1.0.7 which adds volume plugin. I started to write this because I have on-board sound card without volume control for PCM DAC channel. This hardware only lets to mute/unmute this channel. The idea of this patch is to have volume plugin whose coefficient can be linked to state of some volume control. The patch is useable as is. You can describe 'volume' plugin and link it to the Master control of your card for example.
To get complete solution you may also wish to implement virtual control which can emulate behaviour of hardware control (that is to have some value and allow to change it thru usual alsa-lib interface). This plugin also uses linear mappling between control state and volume coefficient. Usually one may prefer to have logarithmic function here (less values change volume a litte while big values change volume significantly). By the way, this is how it's implemented in svol plugin (see below).
The plugin is based on alsa-lib's copy plugin and has same limitations (input and output formats should be the same).
Note that since version 1.0.8 alsa-lib have svol (software volume) plugin which emulates absent volume controls for given device and thus is a sufficient solution for this problem.
Get asoundrc sample for the volume plugin
PS: Finaly I decided to buy fully functional sound card and thus do not need this anymore :)
File wiper
This tiny script lets to safely erase a file. Content of the file is overwritten with random garbage before deletion. This will not work reliably with all combinations of storage device and filesystem. But for flash drive with FAT it should work fine.
Note that for large files it may be too slow (it processes about 150Kb/sec on decent system)
Sources of older site
This web page was generated from hand-crafted XML sources using XSL. You may look at the sources if you curious or probably it may give you some inspirations of how to construct your own site. I use SCons (which provides functionality similar to classic make utility but written completely in Python). You will probably need to change SCons configuration file SConstruct in the archive to suit your environment.
Description of XML - related standards can be found at www.w3c.org
Replication system prototype
This is a proof of concept for replicaion system that I've tried to design. This work thaught me several things that better not to do :) In the first place it become far more complicated than I expected when started working on this. Adhering to SPOT ("single point of truth") principle would make all synchonization simpler. See for example Ganymed project. Besides this master/slave mechanism lets to relax some assumptions about data and operation properties.
This prototype was developed with some billing system as use case. Such system has several incoming queues with messages about services consumption and should change states of accounts according to some business rules (tariffs).
The main idea of this system is to have set (at least two) message processing servers that process messages in parallel. Messages from some event source to replicating servers are delivered using some reliable multicast protocol (e.g. Jgroups). Messages are marked with serial number so if some message (or message range) is missing then this can be detected and recovered from available replicas. Moreover each message is marked with timestamp when it is issued.
When one of servers goes offline due to some reason, remaining servers continute to process messages in parallel. If a server goes online it automatically brings it's state up to date (even if it is a completely new server with empty data set) and continues to process incoming messages.
State of a server is comprised of several data items each having version number that increases by 1 each time after a message affecting this item has been processed. There can be several independent message sources and it is assumed that order of processing all messages issued up to any given moment does not affect actual state of a data item.
To compicate things further :) I've added mechanism of "synchronous command". This mechanism allows issuing a command that should be executed by all servers without compromising data set correctness. It is guaranteed that for each incoming queue synchronous command will be at same position in all servers
Prototype has several threads each emulating a server in replica set. Also a queue recovery mechanism is implemented and simple data item that is used instead of some real data. In cource of execution many invariants are checked.
Sources of prototype: sync-queues-src.zip
I also found a very useful paper regarding correctness of distributed systems: Brewer's Conjecture and the Feasibility of Consistent Available Partition-Tolerant Web Services