RogerBW's Blog

A free countdown timer 12 December 2017

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

Tags: computing

  1. Posted by Dr Bob at 08:53pm on 14 December 2017

    With my geological hat on... seconds since which Epoch? :-)

  2. Posted by RogerBW at 09:07pm on 14 December 2017

    Unix epoch, midnight GMT on 1 January 1970.

    (It's not quite that simple because it's adjusted so that midnight-GMT is always a multiple of 86400, i.e. it doesn't count leap-seconds.)

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.

Tags 1920s 1930s 1940s 1950s 1960s 1970s 1980s 1990s 2000s 2010s 3d printing action advent of code aeronautics aikakirja anecdote animation anime army astronomy audio audio tech aviation base commerce battletech beer boardgaming book of the week bookmonth chain of command children chris chronicle church of no redeeming virtues cold war comedy computing contemporary cornish smuggler cosmic encounter coup covid-19 crime cthulhu eternal cycling dead of winter doctor who documentary drama driving drone ecchi economics en garde espionage essen 2015 essen 2016 essen 2017 essen 2018 essen 2019 essen 2022 essen 2023 existential risk falklands war fandom fanfic fantasy feminism film firefly first world war flash point flight simulation food garmin drive gazebo genesys geocaching geodata gin gkp gurps gurps 101 gus harpoon historical history horror hugo 2014 hugo 2015 hugo 2016 hugo 2017 hugo 2018 hugo 2019 hugo 2020 hugo 2022 hugo-nebula reread in brief avoid instrumented life javascript julian simpson julie enfield kickstarter kotlin learn to play leaving earth linux liquor lovecraftiana lua mecha men with beards mpd museum music mystery naval noir non-fiction one for the brow opera parody paul temple perl perl weekly challenge photography podcast politics postscript powers prediction privacy project woolsack pyracantha python quantum rail raku ranting raspberry pi reading reading boardgames social real life restaurant reviews romance rpg a day rpgs ruby rust scala science fiction scythe second world war security shipwreck simutrans smartphone south atlantic war squaddies stationery steampunk stuarts suburbia superheroes suspense television the resistance the weekly challenge thirsty meeples thriller tin soldier torg toys trailers travel type 26 type 31 type 45 vietnam war war wargaming weather wives and sweethearts writing about writing x-wing young adult
Special All book reviews, All film reviews
Produced by aikakirja v0.1