Skip to content

Instantly share code, notes, and snippets.

@shtaxxx
Created October 24, 2013 08:39
Show Gist options
  • Save shtaxxx/7133413 to your computer and use it in GitHub Desktop.
Save shtaxxx/7133413 to your computer and use it in GitHub Desktop.
Timer using say command
#!/usr/bin/env ruby
USAGE = "$ ruby timer.rb time time ..."
if ARGV.length == 0 then
puts USAGE
exit
end
tl = []
for arg in ARGV
tl << arg.to_i if arg.to_i > 0
end
i=0
while true
print "#{i} minutes.\n"
if tl.index(i) != nil then
system("say #{i} minutes.");
tl.delete(i)
end
break if tl.length == 0
sleep 60
i=i+1
end
puts "#{i} minutes. Finish!"
system("say #{i} minutes. Finish!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment