Skip to content

Instantly share code, notes, and snippets.

@ceilwoo
Created November 11, 2015 03:56
Show Gist options
  • Save ceilwoo/26fc8149b7689f5556cb to your computer and use it in GitHub Desktop.
Save ceilwoo/26fc8149b7689f5556cb to your computer and use it in GitHub Desktop.
terminal countdown timer
require 'time'
countdown_time = ARGV[0]
puts "-- Input Countdown time: XX:XX:XX ---" if !countdown_time
t = Time.parse(countdown_time)
seconds = (t.hour * 60 * 60 + t.min * 60 + t.sec).to_i
while (seconds!=0) do
print " " + Time.at(seconds).utc.strftime("%H:%M:%S")
print "\r"
sleep 1
seconds -= 1
end
puts "\n"
`say "Countdown End"` if /darwin/ =~ RUBY_PLATFORM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment