Archive for the 'Hacking' Category

Network Problems Fixed?

Tuesday, January 5th, 2010

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?

Monday, October 5th, 2009

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 the [...]

Just A Little Bit of Planning

Saturday, April 25th, 2009

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 a lot of the time, the
function in which this [...]

Don’t Put Information in Two Places

Sunday, April 5th, 2009

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 fields as 1-2 character strings
# in [...]

Another Reason Not to Write csh Scripts

Wednesday, February 11th, 2009

In case you haven’t read Tom Christiansen’s
Csh Programming Considered Harmful,
here’s another reason not to write csh/tcsh scripts
if you can avoid it.
Unlike the Bourne Shell, the C shell exits with “Undefined variable”
if you reference an undefined variable, instead of expanding that
variable to the empty string, the way the Bourne shell and Perl do.
But there’s the $?VAR [...]

Wanted: Calendar Feature

Tuesday, September 23rd, 2008

PDAs have solved or simplified a lot of the problems I used to have
before I started carrying around a backup brain. But there’s one type
of reminder that they still can’t deal with: “do X under when Y
happens”. E.g., “Return Paul’s book next time I see him” or “Look up
Janice if I’m ever in London.”

L17n 2.0

Thursday, July 24th, 2008

If you write a software package, and want it to be usable by as many
people as possible, it’s important to translate it into other
languages. But like documentation, localization (l17n) is one of those
chores that programmers don’t want to do. But if it’s a web app, why
not ask the users to contribute translations?

Unicode Input in Emacs

Sunday, July 13th, 2008

One question that had been bugging me for a while is, how does one
input a character in Emacs, given its Unicode hex code?
Answer: use the ucs input method, then use
uHHHH to input, where HHHH is the character’s
hex code.
Unfortunately, it doesn’t look as though there’s a way to input a
character by its decimal code.
Also, C-\ toggles [...]

A Better Way to Toggle

Tuesday, July 8th, 2008

(Warning: what follows may be obvious or trivial to many.)
One of the cool things about AJAX is switching parts on and off: you
can make an element visible simply by

myElement.style.display = “block”;

or hide it with

myElement.style.display = “none”;

But the problem with this is that it requires the JavaScript script to
know a lot about the document. The example [...]

Different Stylesheets for Browsers With and Without JavaScript

Tuesday, July 1st, 2008

As hacks go, this one is pretty obvious, but I thought I’d throw it
out there anyway.
Let’s say there are three stylesheets you want to use on your web
page: one for all browsers (style.css), one for browsers with
JavaScript enabled (style-js.css), one for browsers without
JavaScript (style-nojs.css). This can be useful for things
like “display the fancy drop-down menu [...]