#!/usr/bin/env ruby # remind.rb by Tom Morris # I've been meaning to write this script for a while. The backstory is this: # I travel on a train which has overhead storage shelves. I seem to always # forget that I leave stuff up there if, by chance, I get into 'flow' while # on my computer. I figured that having a little remind a few minutes before # I got to London would be very useful. # And so, remind.rb lets me do that. # > remind +30m "Don't leave your bag on the shelf, you forgetful goofball." # Will use the UNIX atq to store a growlnotify job. # # If you use Mac OS X, you'll need to turn the atq on by following the # instructions at http://is.gd/RoJZ # # Dependencies: Ruby, the 'chronic' gem, Growl and growlnotify, at/atq/atrun # # Feel free to substitute the growlnotify command with anything else that # will prod you out of your stupor. libnotify on Linux, maybe. say (but not on # the train or you'll hopefully be kicked by your rightfully angry fellow # commuters). Maybe some clever XMPP/Jabber or SMS or Twitter stuff for the # cloudish types. require "rubygems" require "chronic" def date_pre_parser (date_str) # not gsub! because ARGV freezes input strings. date_str = date_str.gsub(/\+?(\d{1,})[h|H]/i, "in \\1 hours") date_str = date_str.gsub(/\+?(\d{1,})[m|M]/i, "in \\1 minutes") return date_str end date_string = ARGV[0] date = Chronic.parse date_pre_parser(date_string) string = ARGV[1] `echo "growlnotify -m \\"#{string}\\" > /dev/null 2>&1" | at -t #{date.strftime("%Y%m%d%H%M")} > /dev/null 2>&1`