Created
January 13, 2012 01:13
-
-
Save koko1000ban/1604106 to your computer and use it in GitHub Desktop.
sleepyti.me fake cui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
#fake http://sleepyti.me/ | |
if ARGV.size == 0 | |
warn "usage: #{$0} <ex. 7:20am>" | |
exit | |
end | |
require 'time' | |
begin | |
specified_time = Time.parse(ARGV.first) | |
rescue ArgumentError | |
warn "error: wrong time(#{ARGV.first})" | |
exit | |
end | |
INTERVAL = 90 | |
PRE_SLEEP_TIME = 20 | |
puts "You should try to fall asleep at one of the following times:" | |
times = (3..6).map do |n| | |
specified_time - INTERVAL*60*n | |
end.inject(""){|accum, t| accum << t.strftime("%H:%M") + "(#{(t-(PRE_SLEEP_TIME*60)).strftime("%H:%M")})" + " "}.rstrip | |
puts times |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment