Programs and code

This page collects the various programs and useful code snippets I’ve released over the years. Some of them are quite old and no longer supported, but I’m including them here as people might still find some of the code useful and/or interesting.

Unless otherwise stated, all code is licensed with the LGPL. Other sources of programming material on this website are the articles page and the programming category of the blog.

Complete programs with source code

  • pycparser - (Updated: 15.11.2008) C language parser written in Python. Generates an AST from C code.
  • wxPyTris - (Updated: 31.05.2008) A Tetris clone written in Python (2.5) using the wxPython (2.8) GUI toolkit. It works on both Windows and Linux with native widgets (courtesy of wx). Here’s a zipped executable (4.8 MB) that will run on Windows without Python/wxPython installed.
  • Sudoku solver in Ruby using SAT - (Updated: 08.04.2007) This is a Ruby implementation of a Sudoku solver. The Sudoku is converted into a SAT problem, which is then solved with a simple SAT solver. Read the readme.txt file in the package for more details and instructions of use.
  • Perl Serial communication - (Updated: 18.11.2006) a small utility written in C++ along with a Perl module which in unison provide a convenient method to communicate on the serial port (RS232) with Perl.
  • Perlmix - (Updated: 13.04.2006) A Perl implementation of the MIX machine and MIXAL language devised by D. Knuth in TAOCP. Includes two separate packages - a compiler/assembler of MIXAL -> MIX machine code, and a simulator of MIX machine code (with a simple built-in debugger), including the MIX devices.
  • Perlines - (Updated: 31.12.2004) A clone of the “Colorful lines” (distributed as “Glines” with Gnome) game, written in Perl/Tk. Download the single Perl file and run it. I tested it on Linux and Windows (with ActiveState’s Perl). Warning: the game is very addictive !
  • Pbombs - (Updated: 31.12.2004) A Minesweeper clone, written in Perl/Tk. I only tested it on Windows.
  • ESMS - (Updated: 29.06.2007) simulator and toolset for running fantasy soccer leagues.
  • Jamca - (Updated: 05.05.2004) a chess playing agent I put together in C++ a few years ago. It’s not complete (no search/AI), but can serve as a great learning tool for chess programming.
  • Chuck - (Updated: 10.12.2002) a checkers playing program I wrote in C++ a long time ago, to get some hands-on experience with game AI programming. It was one of my first projects, so the code is (very) far from perfect. Read the readme.txt file in the package to get started.

Code snippets and scripts

Some of the files downloadable from this section are not ZIPped, but uploaded as is, with .txt added to their extension - so you can just open them in your browser. If you download a snippet and want to run / compile it, remove the trailing .txt from its extension.

  • pyqt_dataplot_demo.zip (Updated: 23.05.2009) - Demo of plotting .csv data in PyQt, using matplotlib and PyQwt.
  • regex_fsm.zip (Updated: 28.04.2009) - Implementation of a simple regular expression recognizer, using finite state machines.
  • py_rd_parser_example.zip (Updated: 20.03.2009) - Several related recursive-descent parsers written in Python. Includes a general regex-based Lexer class.
  • qt_mpl_bars.py (Updated: 20.01.2009) - Demo code of matplotlib with PyQt. Displaying a bar plot with information that can be changed by user commands. Allows some interaction with the plot.
  • memmgr.zip (Updated: 17.10.2008) - A small C library to dynamically allocate memory from a fixed pool that is allocated at link time. Useful for embedded systems. Also see this post.
  • google_web_search and google_api_search (Updated: 13.09.2008) - search Google from Python. Also see the CGI interface here.
  • list_rotation.py (Updated: 29.08.2008) - Several space-efficient list rotation algorithms.
  • wx_mpl_bars.py (Updated: 01.08.2008) - Demo code of matplotlib with wxPython. Displaying a bar plot with information that can be changed by user commands. Allows some interaction with the plot.
  • wx_mpl_dynamic_graph.py (Updated: 01.08.2008) - Demo code of matplotlib with wxPython. Displaying a “live” dynamic graph. Allows user interaction and configuration of the plot.
  • libcollect.py (Updated: 03.07.2008) - A Python module that helps you collect all the libraries your script uses into a convenient distribution directory / zip file. Read the embedded documentation for more details.
  • lexyacc_examples.zip (Updated: 27.07.2007) - Some examples of scanners and parsers coded with Lex and Yacc. The examples are well documented and show many important features of the Lex & Yacc tools.
  • lis_algorithms.rb - (Updated: 18.04.2006) Presents three different implementations of the Longest Increasing Subsequence problem, in Ruby
  • fixnum.cpp - (Updated: 06.03.2003) A very simple library implementing fixed number arithmetic. I needed a Verilog (a hardware description language) implementation of fixed point operations for a University project, so I first wrote it in C++ to understand how things work (oh, and C++ is so much easier to debug than Verilog…)
  • Utils - (Updated: 19.08.2005) A collection of C++ utility functions / classes. String tokenization, smart pointers, benchmarking, simple command line parsing, and more.
  • namegen.cpp - (Updated: 08.10.2004) a very simple random name generator. Don’t expect too much though, the names it generates are at best in the ridiculous/hilarious spectrum.
  • largest_files.pl - (Updated: 06.03.2003) Give this script a starting point and it will recursively dive into the directory tree and return with the 20 largest files. Can be very useful when you must clean up some space quickly.
  • foggy.pl - (Updated: 12.03.2003) Useful for manager reports - prints piles of meaningless but extremely smart looking text. Check it out !
  • huff.pl - (Updated: 12.09.2003) A simple implementation of Huffman encoding/decoding
  • win_to_unix_text.sh - (Updated: 06.03.2003) Get rid of those annoying ^M (or \r) characters when you transfer text files from Windows to Unix. This is actually a C-Shell script, but it invokes a Perl one-liner to do the work.
  • weighted_random.pl - (Updated: 16.03.2003) Say you want to pick at random between X and Y, but you want Y to have a larger chance of being picked… The code solves a generalization of this problem.
  • levenshtein.pl - (Updated: 27.03.2003) Calculates the Levenshtein distance (also called Edit distance) between two strings. This can be used for approximate string matching

generic acomplia purchase cialis overnight delivery cheap acomplia online buy generic clomid buy cialis low price viagra without prescription where to buy cialis lowest price levitra where to buy propecia cheap cialis from canada lasix no prescription viagra without rx cheap accutane tablets viagra online without prescription viagra no rx buying cialis online zithromax viagra in uk free cialis cialis us where to buy acomplia find cialis online buy viagra lowest price accutane prescription buy cheap accutane online cialis buy buy generic cialis online acomplia order propecia online lowest price synthroid synthroid without a prescription synthroid online buy propecia online cheap levitra online where to buy levitra cialis online review synthroid prices cialis generic cialis buy drug buy viagra on line viagra pharmacy cialis for order price of levitra zithromax online where to buy synthroid soma generic generic clomid propecia online stores viagra cheap drug cheap generic soma cialis cheap zithromax online cheap order accutane online purchase zithromax online purchase viagra online buy cheap clomid cheap generic propecia zithromax pharmacy online pharmacy cialis cheapest acomplia cost of cialis no prescription viagra free viagra purchase lasix online cialis from india viagra from india order discount cialis soma online stores find no rx cialis cialis no rx required find viagra without prescription approved cialis pharmacy lasix discount