This page contains snippets of code that don't, on their own, qualify as full-fledged projects. They are under the GNU Lesser General Public License unless specified otherwise in the source.
- ksrand.c and ksrand.h, a random number generator built around the famous Lorenz Attractor, all written in integer arithmetic. Also strange-bin.c, an example using it (or any other RNG) to produce 512x512 XBM images of noise to check if anything's obviously wrong.
- MSI Plessey Barcode Generator Like code39, MSI codes are trivial to generate in standalone PHP.
- upload.php.txt -- A method for adding an 'upload' button to Apache 'index of' folders.
- csv.pl -- simple CSV to XLS converter using Spreadsheet::ParseExcel(). Creates one worksheet per csv file.
- -- I got fed up with the huge PHP barcode libraries you see around and wrote this in a day. It uses PHP, the GD library, nothing else. Right-click, save-link-as, or left-click and view source, since it looks funny in a browser.
- strquote.sh -- a method for evaluating literal strings like "something in quotes" asdf 'something else' in shell. Instead of putting them through eval, xargs can group and split them as expected.
- combo.c and combo.h -- routines for generating combinations of items with no duplicates, i.e. ACB/BAC/CAB/ABC/BCA/CBA.
- getstring.c -- an example of how to get strings from programs via popen
- vterm.c -- an example of how to use virtual terminals in C.
- push.sh -- A push function for BASH arrays.
- xmldump.html -- PHP code for dumping raw arrays into raw XML. It derives the XML schema from the array structure. Associative arrays will give tags names, otherwise unnamed tags will be "data" tags.
- grab.c -- grabs a mouse device to stop it feeding events to /dev/input/mice. I needed it to prevent a touchscreen from interfering with the tablet screen the HP tx2000 inexplicably also has.
- micro.c, micro.h -- ever wanted a timestamp function like time() but much higher-resolution? This gives microseconds instead of seconds.
- homedir.c, homedir.h -- an extremely simple API for per-user config files in SDL applications. Just SDL_OpenSaveFile("appname/filename", "w") and process the file how you please. (needs strlist.c)
- netmask.c -- prints lists of what IP address/netmask combinations can talk to each other.
- strlist.c, strlist.h -- simple code for a growable C string list.
- tsm_getopt.c, tsm_getopt.h -- a small homemade getopt that actually does things with data instead of just checking the arrangement.
- scanf.sh -- ever wanted a scanf for BASH? Here's one.
- wce_wakeup.c, wce_wakeup.h -- routines showing how to use Windows CE's timed-wakeup functions.
- tcgets.c, tcgets.h -- An example of how to use serial ports in Linux®
- imgstat.c -- A SDL and SDL_image based commandline utility to print image statistics. It prints the filename, width, height, and bits per pixel. Useful for classifying images automatically in a shell script.
- eater.c -- Tunable UNIX® CPU eater program. Used to heat up a remote server that was running a little too cold due to bad insulation and bad weather.
- rawmap.c -- A demonstration of how to do raw memory access in Linux®. It maps the raw memory device, so needs root to work.
- sparsecat.c -- A UNIX® utility to write space-saving sparse files. It reads from standard input and writes to standard output. if stdout isn't a file, it just writes non-sparse.
- thrashing.c -- An early OpenGL experiment of mine. Supposed to display a spinning torus. It fails epically, showing an eerie thrashing ping-pong-paddle-plant thing instead. (screenshot) (Win32 bin)
- utf8.c -- A getc for UTF8, sort of.
- drunk.c -- Feed it normal text on standard input and it will feed drunken text out. It simulates actual typing on a US keyboard; h is likely to become j/n/b/g/y/u. a's might even hit the capslock.
- gulp.c -- Feeds all input from a stream into a temporary file. Useful for making a piped input stream, seekable. It takes all input at once, consuming as much space as necessary, so beware!
- hyperspace.c -- an SDL program that shows an eerie rotating starfield in redshifted colors.
- sdlsock.tar.gz -- a program that opens a one-way TCP/IP socket that you can write to, from the command line. I find it very useful for writing text to postscript printers.
- listfrom.sh -- a program that searches a text file line by line looking for the last instance of a search string, then prints that line and everything after it. I use it by injecting '>>>MARKER<<<' into my system log file, then running ./listfrom.sh '>>>MARKER<<<' /var/log/messages.
- striplinks.sh -- a program that reads in a webpage, from file or URL, and outputs a list of all links (-l option) or embeds (-e option). Uses wget.
- dirstack.c, dirstack.h -- ever wanted to use pushd/popd from a C program? Now you can.
- chomp.c, chomp.h -- removes whitespace from the end of C strings.
- SDL_subsurface.c, SDL_subsurface.h -- A simple but useful SDL function for creating surfaces from sections of other surfaces. The pixel data is not duplicated, it is shared -- modifications to data in the subsurface will be reflected in the parent surface.
- SDL_savejpeg.c, SDL_savejpeg.h -- This code does exactly what it says on the tin. It saves jpegs, from SDL. This is NOT MY CODE, it belongs to Pluto Inc., which they kindly released under their GPL-like Pluto Public License. I've cleaned up their "C++"-isms and made it usable for any image format, but this is not a radical change.
- mydebug.c, mydebug.h, debugtest.c -- compile-time and run-time debug output macros. DEBUG_PRINT only prints when DEBUG was defined at compile-time, and INFO_PRINT only prints when DEBUG was defined at compile-time or DEBUG is present in the environment variables. I use things like this ALL THE TIME.
- find-in-include.pl -- a small useful perl script to find where things are defined and/or used in include files. I wanted to take a closer look at the file_operations Linux® kernel structure but couldn't FIND the thing since it was in an indirectly included file. This found it.
- ehash.c, ehash.h -- Preprocessor macros and a function call that simplify switch statements for SDL events a great deal. Switch statements inside switch statements, to handle keys for example, are not needed because the events are converted to flat, unique integers. This can also be used for programmable input. Uses the Simple DirectMedia Layer.
- SDL_resource.c, SDL_resource.h -- a simple, modular runtime resource loader for SDL_image, SDL_mixer, and SDL_ttf. It lets you write up an array of resources to be loaded with one function call so you don't have to make tons of ugly hardcoded explicit calls to different font loading, image loading, and sound loading functions. You can also specify that a particular resource doesn't need to be loaded now, but later, so as to not clutter up memory or not bomb out when nonessential resources fail to load.
- checker.c -- an efficient way of drawing colored checkerboxes on SDL surfaces. It draws one pattern of 4 colored squares with SDL_FillRect, then keeps doubling the pattern in height and width with SDL_Blit until the given area is filled. Clipping rectangles are used to avoid drawing outside the given area.
- sudoku.c -- program for solving those 9x9 matrix puzzle things. Freeware.
Send comments, patches, ports etc to Tyler Montbriand, monttyle@heavyspace.ca.