Skip to content

Instantly share code, notes, and snippets.

@coreyhaines
Created February 4, 2012 09:14
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save coreyhaines/1736615 to your computer and use it in GitHub Desktop.
Timer for coderetreat session
#!/usr/bin/env ruby
# Usage ruby 2-minute-timer.rb "message to say when time is up"
# or just chmod +x timer.rb and ./timer.rb
# for more info, see http://coderetreat.org/profiles/blogs/new-session-idea-baby-steps
message = ARGV[0] || "times up"
minutes = 2
seconds = minutes*60
while(true)
STDOUT.puts "Starting #{minutes}-minute timer"
seconds.times do |index|
STDOUT.print "."
sleep(1)
end
`say "#{message}"`
STDOUT.puts
STDOUT.puts "Hit return to start again"
STDIN.getc
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment