When I'm playing play-by-forum games, there's often a deadline.
Because players are scattered across the world and many people are bad
at time zones, it's helpful to have a countdown to remind people how
much time is left. So I made one.
"But Roger", you say, "aren't there lots of those out there
already?" Well, up to a point. For a start, most of them need some
sort of registration, have restrictions on use, and/or dump
advertisements round the edge of the timer. That's not a great start.
But more seriously, they all seem to require an embedded object
(iframe). Most boards don't allow embedded objects, because those are
a Terrible Idea from a security perspective.
So I wrote mine to be a pure image, a non-looping animated GIF with
one minute's worth of countdown. That's generated with the Imager
library for Perl, which is the best bitmap-mangling library I've ever
used; it simply generates sixty images and stuffs them into the GIF
container with one-second delays between them. (Actually a few more,
to account for reloading delays.)
The HTTP response is stuffed with no-cacheing headers (though I'm sure
there will still be a cache out there that ignores them), and includes
a Refresh to cause the browser where it's displayed to reload it after
the minute has expired.
The trick to all this is that the URL to generate the image includes a
unixtime (seconds since the epoch). So there's no need for me to store
any sort of database of countdowns people have started; just send a
valid time and you get the image generated for you.
How do I avoid having to give a cgi-bin URL? Did I use some terribly
trendy web framework? Not a chance. The URL is
(hostname)/(unixtime).gif; that's a nice short link with no room for
tracking garbage. Apache configuration rewrites it to call the CGI
script that generates the image data.
ScriptAliasMatch /([0-9]+).gif /var/www/timer_firedrake_org/cgi-bin/countdown.cgi
The script then looks at the REQUEST_URI environment variable to see
what expiry date it should use.
"But Roger, I don't think in seconds since the epoch", you say with
your puny human brain. That's why the front page of the site lets you
enter the expiry date in a variety of formats and generates the
unixtime for you.
All this is available at
timer.firedrake.org.
Comments on this post are now closed. If you have particular grounds for adding a late comment, comment on a more recent post quoting the URL of this one.