With Halloween completely over, done and dusted for another year, spooky avatars and haunting usernames firmly put back into storage, Twitter was feeling a little less scary than usual this morning.
Fortunately, I found a solution that is guaranteed to terrify everyone who dares nudge against my Twitter feed:
Yes, now each avatar-laced tweet of mine will advertise the number of days remaining until Xmas. There’s no escape…
With (checks avatar) 54 days to go, this would ordinately require that I change my Twitter avatar every day at the moment the clock struck midnight. As thrilling as this would have been to do manually every 24 hours, I couldn’t help but think I should delegate it somehow.
Hence I wrote a shell script so my puter can experience the excitement instead.
The script is pretty simple - it calculates the day of the year Xmas falls on (359) and subtracts from that the current day of the year (305) to get a ‘days left’ figure. (This means it’ll fall to pieces on Boxing Day…)
Next, it uses the ever-magnificent ImageMagick to draw that number onto my avatar image in a couple of passes to get a ‘pleasant’ outline effect, so the number is clearly readable even at lower resolutions (THERE’S NO ESCAPE, remember?)
Finally, it uploads to Twitter.
Now, usually manipulating the Twitter API from a shell script calls for
curlish, but I didn’t really fancy having to install a Ruby or Python env. So I finally got to use a web service I saw a while ago but - until now - had no reason to use: foauth.org! (Foauth is a cool little service that lets you interact with services like Twitter and GitHub with Basic HTTP auth, which is perfect for stuff like this.)
A little fiddling with the Twitter API (using a standard multipart upload failed - the image had to be explicitly base64 encoded) and the job was done.
Of course the crucial step is automating this so it happens each day, hence
You can find (a version of) the script I’m using here should you also wish to try tormenting your followers in this way.