Every now and then, I need to do something that I can’t find a program for, or the programs I can find don’t do the work I need (and aren’t free software.) So, if the job is small enough (and sometimes if it isn’t; cwatch, postoffice, and markdown started out as quick hacks,) I’ll reinvent the wheel for the fun of it.
stdout
, one per line.
idea by Kernighan & Pike, in
The UNIX Programming Environment,
filtered through Copeland & Haemer,
in Server/Workstation Expert (Vol 11 #2
) as a perl program,
then redone by me in C.Jot prints out numbers (in a variety of forms, either randomly or in sequence) within a specified range. It exists on FreeBSD, but not on mastodon, so I spent an afternoon fixing that wagon.
This version of jot can be renamed (or linked to as)
yes
or seq
, so it actually kills 4 birds with one stone.
To compile jot, you’ll need a random number generator, and I’ve written a manpage and a html page for it.
Stupid Block Sort – sbs for short – sorts, in the slowest manner possible, lines of text by line length. I wrote it because I wanted to see how long some of the filenames in my home directory were. At midnight. In a house with 2 babies.
Amazingly, I provided it with command-line options;
max
max
characters.min
min
characters.char
char
as the line separator instead of \n
.Mutt is a pretty good mail
program, but it’s got a couple of whopping deficiencies. One
of them is that for some inexplicable reason it doesn’t talk
smtp but instead requires you to use an external program to
get your mail to your local friendly smtp server. Several of
these programs exist, but they’re written with the modern
version of portability in mind – they work on both
redhat
and Debian
Linux, but don’t work very well
on other platforms.
One of these other platforms is DEC OSF-1, which is
able to reliably kill GNU configure dead. On 15-Jan-2004,
I was using mutt on an Alpha box and I needed to send mail
to the corporate mail (exchange. *shudder*) server, and
after a quick tour of “lets see just how confused configure
can get when it’s running on a box that doesn’t have Linux
on it!,” I wrote a little mail forwarder
that uses my network client framework to
send mail from a non-Linux machine.
getopt()
with long optionsgetopt(3)
.After a hardware failure, I had to move a web server to
a different machine, and when checking my access logs to
make sure I’d changed all of the appropriate cnames to
point at the new machine, I discovered a large wad of
hits directed not at the nicely cnamed
ed
weblog.pell.portland.or.us
, but at the physical
machine that this cname used to point to. This is not
the best sort of situation to be in, particularly when
the web server is no longer on that particular machine.
I didn’t want to install a full-blown web server to manage the 300-400 redirects I’d need per day, but the only pre-written redirector I could find was a chunk of Perl code written for Perl 5.6 when all I’ve got is Perl 5.0005somethingoranother (and that only because the Linux Counter ticker is written in that language.)
So, rather than attempt to put Perl 5.6 onto my a.out
-based
SLS development machine, I hacked up this tiny little redirection
server, which is now running on pell, 302ing people off to
weblog.pell.portland.or.us
, where they should have been
in the first place.
#
lineno “file”
directives that cpp (or at least the gcc version of cpp; the
gcc maintainers don’t seem to be very well wrapped on the C
programming language, so it’s very possible sloc
won’t work
on systems that have real C compilers) spits out to help
the compiler generate intelligible diagnostics, and uses them
to make sure it’s only counting the lines-of-code that code
from the file being counted.