Code Snippet Page

Here lists pieces of short code/scripts written in various languages by myself. Most of them are small fraction of code that do only one thing, and try to do it well. All of them are provided with source code under a BSD-like license. In a few cases of half-baked project, only binaries are provided at this point. Feedback welcome!

Here's a short summary:

  • Minimal http server written in python.
  • C/C++ mmap wrapper: A platform independent mmap() wrapper in C
  • C iconv wrapper: An iconv() wrapper in C
  • lbfgs_wrapper: C wrapper code for the Fortran lbfgs and lbfgsb optimisation routine

Code Snippets

    This is a minimal http server written in python. It's useful for fast transferring files in LAN. Just run the script '' then all files under current directory (and sub-directories) are available to your browser.

  • C mmap() wrapper
    A platform independent mmap wrapper for unix and win32. It is by no means perfect. Generally I find it works well and may be useful to others. A C++ wrapper is also included.
    Download: mmapfile-20050521.tar.gz

  • C iconv() wrapper
    An iconv() wrapper for unix and win32 (libiconv). iconv() call is a versatile tool for converting strings in different encoding from/to unicode. Unfortunately the C interface of iconv() is very difficult to use. The C wrapper code simplifies the task of using iconv(). By default all strings are converted to/from UCS2 (2 bytes).
    Download: iconvert-20050529.tar.gz

  • C wrapper for Fortran lbfgs/lbfgsb code
    Believe it or not, some of the best written numerical routines are still available in Fortran only. This is the case for the Fortran implementation of lbfgs (limited memory BFGS method) and lbfgsb (bound constrained limited memory BFGS method) for solving large scale non-linear optimisation problem. The code was written by Jorge Nocedal and Ciyou Zhu in 1990s. I've been using lbfgs in my C code in place of Conjugate-gradient for a while with good results. Now I put the C wrapper code here in the hope it will be useful to others.
    Download: lbfgs_wrapper-20071213.tar.gz
Edit - Print