Since I got asked several sh-related questions, I might as well get a post out of them. One person asks: I’m writing a portable shell script to download a file from the web, and then compare it to a locally-stored version of the same file, using diff. My first version of the script used mktemp… Continue reading A Couple of Shell Quickies
Over on the right, in the sidebar, you should see a countdown clock entitled “Countdown to Backpedaling”. (If not, then something went wrong.) If you’ve been listening to Ask an Atheist, then you should recognize this as a widget version of the Countdown to Backpedaling clock. And if not, then you should definitely be listening… Continue reading Countdown to Backpedaling Widget
So I was thinking about how to refactor our custom Linux and Solaris init scripts at work. The way FreeBSD does it is to have the scripts in /etc/rc.d define variables with the commands to execute, e.g., start_cmd=’/usr/sbin/foobard’ stop_cmd=’kill `cat /var/run/foobar.pid`’ run_rc_command “$1″ where $1 is “start”, “stop”, or whatever, and run_rc_command is a function… Continue reading Bourne Shell Introspection
This was definitely a “D’oh!” type of problem. One thing I’d been meaning to figure out for a while was how to send gzip-compressed files to a browser. That is, if I have a large HTML file, it’d be nice if the server could compress it to save bandwith and transmission time. Yes, Apache has… Continue reading Pre-Compressing Web Content
MacOS plist XML files are evil; even more so than regular XML. For instance, my iTunes library file consists mostly of entries like: <key>5436</key> <dict> <key>Track ID</key><integer>5436</integer> <key>Name</key><string>Getting Better</string> <key>Artist</key><string>The Beatles</string> <key>Composer</key><string>Paul McCartney/John Lennon</string> <key>Album</key><string>Sgt. Pepper’s Lonely Hearts Club Band</string> … </dict> You’ll notice that there’s no connection between a key and its value, other… Continue reading Evil Hack of the Day
Like a lot of people, I have to submit a monthly “bullet” report, listing the things I’ve done in the previous month. Since I use Org-Mode for planning, scheduling, and organizing tool (or rather: I tend to throw a bunch of notes into a file and tell this love child of a day planner and… Continue reading Monthly Reports with Org-Mode
As far as I can tell, FreeBSD 8 tickled something in the driver for my ethernet card, and caused it to behave unreliably. Rather than muck around with half-tested kernel patches or ifconfig settings, I slapped a $30 Whatevertheyhadontheshelf-3000 (read: common chipset that’s been debugged by a lot of people), and as far as I… Continue reading Network Problems Fixed?
Every so often, I need to find out whether I have a certain Perl module installed. Usually it’s either because of a security alert, or because I’m wondering how much of a pain it would be to install some package that has Some::Obscure::Module as a prerequisite. I don’t know how y’all do it, what with… Continue reading Quick and Dirty Perl Hack: Is Foo::Bar Installed?
One thing I’ve noticed about my code is that an awful lot of the comments are of the form call_some_function(); // XXX – Error-checking (where XXX is an easily-grepped marker for something that needs to be fixed.) The proximate reason for this accumulation of “do something smart if something goes wrong to-do items is that… Continue reading Just A Little Bit of Planning
While playing around with a Perl script to look up stock quotes, I kept getting warning messages about uninitialized values, as well as mising data in the results. I eventually tracked it down to a bug in an old version of the Finance::Quote Perl module, specifically to these lines: # Yahoo uses encodes the desired… Continue reading Don’t Put Information in Two Places