Troy D. Hanson <tdh@tkhanson.net>
Back to tkhanson.net main page.
These are miscellaneous small scripts and snippets that I’ve written on Linux and OS X. These are all placed in the public domain.
Download misc.tar.bz2
Browse source tree
Clone git clone http://tkhanson.net/misc.git
Examples of using common libraries and other reusable bits:
example of using dlsym() |
C |
|
example of using the Lemon parser generator |
C |
|
example of UDP client and server |
C |
|
example of TCP client and server |
C |
|
code to list network interfaces, their IPv4/v6 addresses and MACs |
C |
|
example of doing DNS lookup |
C |
|
example of signal driven I/O notification |
C |
|
a few x86 assembly programs that call C library functions or are called from C |
asm |
|
example of getting inotify file events (Linux 2.6.13 and higher) |
C |
|
example of a parent process managing multiple worker processes |
C |
|
example of using pcre library |
C |
|
example of using libpcap to capture packets |
C |
|
example of using readline library |
C |
|
example of UNIX domain socket client and server notes |
C |
|
a control port library: an administrative interface to a server |
C |
|
builds a Bloom filter from lines of one text file, tests lines of another file on it |
C |
|
a time series library, series comprised of arbitrary elements |
C |
|
measuring entropy of a byte stream notes |
C |
|
example of implementing a simple gzip/gunzip using the zlib C API |
C |
|
simple function to read key-value configuration file entries |
C |
|
macros to wrap read/write, which loop until "len" bytes are read or written |
C |
|
example of using the iconv library |
C |
|
an incremental grep that reads a stream piecemeal scanning for a pattern |
C |
|
example of using read or mmap to "slurp" a whole file |
C |
|
a C program that gets signalled when its parent exits using prctl |
C |
|
macros for utf8 handling including character length, validity and utf32 conversion |
C |
|
example of iterating over lines of input from file or stdin using readline |
C |
run commands whenever a fifo is readable (useful when triggered by a vim hotkey) notes |
Perl |
|
reduce a text file to x% of its lines (default 10%) |
Perl |
|
list files changed since last run notes |
Perl |
|
send email with attachments, configurable from address, etc |
Perl |
|
list lines in file A but not in file B |
Perl |
|
convert stdin to hex bytes |
Perl |
|
convert hex args to binary bytes on stdout |
Perl |
|
print region (from position s of length l) from a file |
Perl |
|
parse access.log and store daily hits for each url, or view cumulative hits |
Perl |
|
type "remember", run some commands you want to remember, then "remember -s" to save them notes |
sh |
|
sample of using rrdtool |
Perl |
|
embedding ditaa diagrams into Asciidoc documents notes |
ditaa |
|
configure some of my preferences in .bash_profile, .gdbinit, .vimrc and .inputrc |
sh |
Virtual Memory in a Nutshell slides I wrote in 2009.