Today in History

index | misc


This shows how I made the page http://tonybaldwin.me/pages/today.php, which shows relevant historical facts every day.

I used the BSD program calendar to generate the data, and simply embedded it in the webpage. I have a cronjob1) once a day do:

  1 0 * * * calendar -A 0 > /tmp/tday

That is, once a day, at 1 minute past midnight, it runs

  calendar -A 0

and pipes the output to a file (tday) in my /tmp dir.

Then, I just have the webpage read that file when it loads, with php.

<?php
highlight_file('/tmp/tday');
?>

Pretty simple, really. I can embed the same code here:

Today in History

Sep 25     Sandra Day O'Connor becomes first woman on US Supreme Court, 1981
Sep 25     Army Day in Mozambique
Sep 25     Referendum Day in Rwanda
Sep 25     John Bonham (Led Zeppelin) dies of alcohol poisoning, 1980
Sep 25*    Family & Community Day (ACT)
Sep 25     Prins Johan Friso (1968)
Sep 25     N'oubliez pas les Hermann !
Sep 25     À la saint Firmin
    L'hiver est en chemin.
Sep 25     Eufrozina, Kende
Sep 25     Татьянин день. Студенческий праздник
Sep 25     День таможенника
Sep 25     Коляда (сдвинутое зимнее солнцестояние)


GOPHER version

I have a gopher version in my gopher hole, by also adding to my crontab:

  1 0 * * * calendar -A 0 > /var/gopher/today

and just linking that file in my gophermap.

Histobot

You may have seen me posting these history tidbits to this history group on Friendica (and crossposted from my friendica to any of the various blogs I keep). I have this automated, as well.

#!/bin/bash
 
# post history to @history group on friendica
 
filedate=$(date +%m%d%y%H%M%S)
 
calendar -A 0 > ~/$filedate
echo "#history @history" >> ~/$filedate
echo "http://tonyb.us/today" >> ~/$filedate
sed 's/\&/and/g' ~/$filedate > ~/histob0t
ud=$(cat ~/histob0t)
 
title="Today in History"
 
curl --ssl -u tony:****** -d "status=$ud&title=$title&ljpost_enable=1&posterous_enable=1&tumblr_enable=1&dwpost_enable=1&ijpost_enable=1&statusnet_enable=1&source=myHistobot" https://soc.beardyunixer.com/api/statuses/update.xml
 
rm ~/$filedate
rm ~/histob0t
 
exit

and I have cron fire that off every morning at 02:05 am with

   5 2 * * * /usr/local/bin/histobot

tonybaldwin 2012.01.22.12.45