Skip to content

Instantly share code, notes, and snippets.

@Jylanthas
Created December 13, 2015 05:01
Show Gist options
  • Save Jylanthas/2f6b3d699d101f4a66e9 to your computer and use it in GitHub Desktop.
Save Jylanthas/2f6b3d699d101f4a66e9 to your computer and use it in GitHub Desktop.
wake the hell up! (when you don't have your phone)
def forever
i = 0
while true
yield i
i = i + 1
end
end
def alarm!(msg)
forever { `say '#{msg}'` }
end
def wait(t)
puts "alarm at #{t}, now #{Time.now}"
sleep 1
end
def set_alarm(t, msg='wake up')
forever do
return alarm!(msg) if Time.now > t
wait(t)
end
end
t = 8.hours.from_now
set_alarm t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment