Skip to content

Instantly share code, notes, and snippets.

@koko1000ban
Created January 13, 2012 01:13
Show Gist options
  • Save koko1000ban/1604106 to your computer and use it in GitHub Desktop.
Save koko1000ban/1604106 to your computer and use it in GitHub Desktop.
sleepyti.me fake cui
#!/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