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 timer.firedrake.org.

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.

Search
Archive
Tags 1920s 1930s 1940s 1950s 1960s 1970s 1980s 1990s 2000s 2010s 3d printing action aeronautics aikakirja anecdote animation anime army astronomy audio tech base commerce battletech beer boardgaming bookmonth chain of command children chronicle church of no redeeming virtues cold war comedy computing contemporary cornish smuggler cosmic encounter coup cycling dead of winter doctor who documentary drama driving drone ecchi espionage essen 2015 essen 2016 essen 2017 existential risk falklands war fandom fantasy film firefly first world war flash point food garmin drive gazebo geodata gin gurps gurps 101 harpoon historical history horror hugo 2014 hugo 2015 hugo 2016 hugo 2017 hugo 2018 hugo-nebula reread in brief avoid instrumented life kickstarter learn to play leaving earth linux mecha museum mystery naval non-fiction one for the brow opera perl photography podcast politics powers prediction privacy project woolsack pyracantha quantum rail ranting raspberry pi reading reading boardgames social real life restaurant reviews romance rpg a day rpgs science fiction scythe second world war security shipwreck simutrans smartphone south atlantic war squaddies stationery steampunk stuarts suburbia superheroes suspense television the resistance thirsty meeples thriller tin soldier torg toys trailers travel 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