Skip to content

Instantly share code, notes, and snippets.

@softr8
Created October 2, 2012 02:12
Show Gist options
  • Save softr8/3815777 to your computer and use it in GitHub Desktop.
Save softr8/3815777 to your computer and use it in GitHub Desktop.
SG 1 oct
# Como usarlo:
# ruby sleep.rb "6:15 AM"
# ruby sleep.rb
require 'date'
require 'time'
desired_hour = ARGV.first || "7 AM"
wakeup_at = Time.parse("#{Date.today} #{desired_hour}")
SLEEP_INTERVAL = 90 * 60 # in seconds
MIN_SLEEP = 90 * 3 * 60 # in seconds
intervals = []
4.times do |index|
intervals << (wakeup_at - MIN_SLEEP - SLEEP_INTERVAL * index).strftime("%I:%M %p")
end
last_chance = intervals.reverse!.pop
puts "#{intervals.join(', ')} or #{last_chance}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment