Ruby Deadline Script
#!/usr/bin/env ruby -w
# This tells me in no uncertain terms how many pages I need to
# get through in a given day in order to meet a deadline, and
# offers a Valentino Rossi-like GO!!!!!! by way of encouragement.
# Require the fancy-pants linguistics library
require 'rubygems'
require 'linguistics'
Linguistics::use( :en )
# Init constants
SecondsInWeek = 60 * 60 * 24 * 7
SecondsInDay = 60 * 60 * 24
Deadline = Time.gm(2006, "Dec", 15, 12, 00, 1)
Today = Time.now
TimeLeft = Deadline - Today
TimeLeftAdj = TimeLeft - SecondsInWeek
TotalPages = 403
unless ARGV[ 0 ]
puts 'What page are you on?'
current_page = gets.to_i
else
current_page = ARGV[ 0 ].to_i
end
pages_left = TotalPages - current_page
puts 'PAGES LEFT: ' + pages_left.en.numwords
# Could just print the results of evaluation, but
# that would be harder to write I mean read.
ppday = pages_left / (TimeLeft / SecondsInDay)
ppweek = pages_left / (TimeLeft / SecondsInWeek)
ppweekadj = pages_left / (TimeLeftAdj / SecondsInWeek)
puts 'AVERAGE PAGES PER DAY: at least ' + ppday.to_i.en.numwords
puts 'AVERAGE PAGES PER WEEK: at least ' + ppweek.to_i.en.numwords
puts 'ADJUSTED PAGES PER WEEK: ideally, ' + ppweekadj.to_i.en.numwords
puts '-------> G O ! ! ! ! ! ! ! <--------'
I’m painfully aware that this is incredibly trivial, but it’s a big deal for me, so you hacker types can keep your derision to yourselves.
October 11th, 2006 at 1:57 pm
That there linguistics library is pretty goddanged fancy.
October 11th, 2006 at 10:31 pm
I wrote this mostly as an excuse to generate some numbers and thus have an excuse to use the linguistics module.
October 12th, 2006 at 12:14 am
A nice way to make computers more personal.