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

Nov 21     Announcement of 18 1/2 minute gap on Watergate tape, 1973
Nov 21     Olivér
Nov 21     День инженерных войск
Nov 21     День работников налоговых органов
Nov 21     День победы русских полков во главе с великим князем Дмитрием Донским над монголо-татарскими войсками в Куликовской битве (1380 год)
Nov 21     Рождество Пресвятой Богородицы
Nov 21*    Зимнее солнцестояние
Nov 21*    Летнее солнцестояние
Nov 21     День Стрибога
Nov 21     День Сварога и Семаргла
Nov 21     Різдво Пресвятої Богородиці


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