public
Created — forked from davetron5000/dantimer.rb

DanTimer

  • Download Gist
dantimer.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/ruby
 
require 'time'
 
def format_time(seconds)
hours = (seconds / 3600).to_i
minutes = ((seconds % 3600) / 60).to_i
seconds = (seconds % 60).to_i
minutes = "0#{minutes}" if minutes < 10
seconds = "0#{seconds}" if seconds < 10
"#{hours}:#{minutes}:#{seconds}"
end
start = Time.now
ARGF.each do |line|
time = Time.now
puts "#{format_time(time - start)}: #{line}"
end
puts "#{format_time(Time.now - start)}: DONE!"
usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
$ ./dantimer.rb > notes.txt
Start of show
Merlin talks about agency
Construction at Marco's house
Some cool new mac thing
Siracusa insists he hasn't listend to Build & Analyze
Merlin still talking about agency
^D
$ cat notes.txt
0:00:02: Start of show
0:00:10: Merlin talks about agency
0:00:18: Construction at Marco's house
0:00:27: Some cool new mac thing
0:00:40: Siracusa insists he hasn't listend to Build & Analyze
0:00:50: Merlin still talking about agency
0:00:51: DONE!

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.