Category: Hacking

  • Fun With Barcodes

    If you have an Android phone, odds are that you have the Barcode Scanner app. And if you’ve looked in the settings, you may have noticed one called “Custom Search URL”. This is, as the name says, a URL you can fill in. Once you do, you’ll get a “Custom search” button at the bottom […]

  • A Couple of Shell Quickies

    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 […]

  • Countdown to Backpedaling Widget

    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 […]

  • Bourne Shell Introspection

    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/`’ run_rc_command “$1″ where $1 is “start”, “stop”, or whatever, and run_rc_command is a function […]

  • Pre-Compressing Web Content

    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 […]

  • Evil Hack of the Day

    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 […]

  • Monthly Reports with Org-Mode

    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 […]

  • Network Problems Fixed?

    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 […]

  • Quick and Dirty Perl Hack: Is Foo::Bar Installed?

    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 […]

  • Just A Little Bit of Planning

    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 […]