A couple of months ago, I was wondering would it be the third year or fourth year since this blog was born? I could remember the month and day, but hardly the year. Knowing which anniversary almost is impossible and that’s the reason I wrote nthanniv script in Python, a script is so simple with less than 80 lines and most of them are comments and blank lines.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik4v_OMD8slX3K-o8oN895CmaMXzQFfnzjOhgGJOQAx6CYZx7T5utrNuZ8CiJoE-pWXVq1wsUsh12AR22F4OjDmTHlYzYy8xBQEkikP_jSYxedrvzL0G8Cugu_SPXV5jsZXTdXj6lJAZk/s800/nthanniv%25202013-06-03--10%253A04%253A15.png

In the screenshot above, the first part is the configuration file. As you can see, it’s a simple plain text file. Date and description for the date, and that’s all.

The second part is the output being piped into sort command, so it shows what anniversaries come next. For example, the first entry, first column tells the second anniversary has passed and second column says that the third anniversary will be in 1 day.

Simple to read and to code.

I didn’t complicate the script. There is no options and there is no need. If you need something, pipe into your script like how I use sort. You can even write a script to generate notification when the second column is a number lower than a threshold.

For example, highlighting upcoming anniversaries within 30 days:


nthanniv | sort -k 2 | awk \
'{if($2<=30) {print "\033[1;31m"$0"\033[0m"} else {print $0}}'
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjudQDgsybjCgm_5Inj6T0YB-XQYeFetFXLCAnaqg3kfTTz9WFDhsOcYmPTJjAmC3xoeQ725CltCcSIIg9jQm6D3BhWztfFnjxbDsYgfgCQ7aaH2g7JWT6M3RoCh5Q-k-o3JAWyr1GYWDs/s800/nthanniv%2520highlight%25202013-06-03--23%253A57%253A29.png

In just one day, it marks that I’ve not eaten any meat for three years. Little more than two years ago, I revealed that I became lacto-vegetarian because of a television show. A year later, a Flickr video turned me into vegan. Last year, it’s my fifth year anniversary of being a full-time Linux user.

Time sure flies by fast and this is I need to have this simple script to help me track the dates.