With a little bash script, the posting service dlvr.it and Linux's fortune program, we created a simple little bot that annoyingly spews out a random fortune of 140 characters or less every 15 minutes. You can see the bot's Twitter stream here. If you are on Twitter, you could follow the account but... consider that you'd be getting four random fortunes an hour -- that's almost 100 tweets a day. Some may not even make any sense. It's your call.
A few nights ago I was searching the ether to see what would be required to have the server report warnings, issues and statistics (hd space, load, etc.) via Twitter. The advantages -- aside from a high neat factor -- would be that we'd get immediate, steady updates through our respective Twitter streams. I don't check my email often, but for some reason I always have Twitter on -- and can even selectively have particular tweets sent straight to my phone at any time of the day or night.
Unfortunately, it turns out that in order to do so, you need to have a good understanding of Twitter's API and access policies, which went a little beyond what I had in mind of doing -- I'm lazy.
So why not just use a simple RSS feed? If I can feed this website's RSS feed to Twitter, Identica and Facebook, I could probably use the same system. And so, with a little bash script, I created an RSS file that would be generated every fifteen minutes via a simple cron job running through the www-data user. The script looks like this:
echo "<?xml version='1.0'?><rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>" > /var/www/bottune.xml
echo "<channel><title> /usr/games/fortune </title><link> http://con.ca/ </link><language> en-us </language>" >> /var/www/bottune.xml
echo "<copyright> Capital of Nasty Electronic Magazine ISSN 1482-0471 </copyright>" >> /var/www/bottune.xml
echo "<description> A quote every 15 minutes. </description>" >> /var/www/bottune.xml
echo "<atom:link href='http://con.ca/rss/rss.xml' rel='self' type='application/rss+xml' />" >> /var/www/bottune.xml
echo "<item>" >> /var/www/bottune.xml
echo "<title>" >> /var/www/bottune.xml
/usr/games/fortune -s -n 140 >> /var/www/bottune.xml
echo "</title>" >> /var/www/bottune.xml
echo "</item>" >> /var/www/bottune.xml
echo "</channel>" >> /var/www/bottune.xml
echo "</rss>" >> /var/www/bottune.xml
As you can see, it's not rocket science. You'll notice the fortune command has -s for short and -n 140 to limit the number of characters. Also, I only used one > in the first line ( [...] > /var/www/bottune.xml) so the XML file is recreated from scratch at each turn.
After that, I created a Twitter account -- which took longer than writing the above script because it seems that all the good names are taken -- and linked it with dlvr.it. Every 15 minutes, dlvr.it checks the RSS XML file, polling the quote in there and automatically posting it on Miss Fortune's Twitter account. And that's it.
You can potentially replace the /usr/games/fortune/ command with any other Linux command to your liking and have it pump out that information directly to a Twitter stream.
Useless? Totally. Neat? You betcha. But it doesn't take much to amuse a nerd like me.
|Deutche Post DHL's Parcelcopter Delivers Medicines|
|Autonomous Vehicles in Operation in China|
|Using Miniature Robots as an Interface Mechanisms|
|"Giving old people robots to talk to is a dystopian view that is being classified as utopian."|
|Disney's Research Hub Showcases their Physical Face Cloning for Animatronic Characters|
|“The idea of the self-empowered Uber driver or Airbnb host is a rarity if not an outright myth.”|
|“It is financially insane to buy anything other than a Tesla.”|
|Be an Unfucker|
|CaptchaTweet: Write Tweets in Captcha Form|
|How to Avoid Jury Duty|
|The (Very Scary) People of Public Transit|
|“Netflix has competition now, so it must be better, right?”|
|Fake Name Generator|
|U.S.S. Enterprise Owner's Manual|
|“Impossible Aerospace founder and CEO Spencer Gore hopes to make self-flying electric planes.”|
|Naked Preacher Lady [NSFW]|
|Recycled Vacuum Lamps|