-
-
Save stephenmckinney/2973805 to your computer and use it in GitHub Desktop.
DanTimer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./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! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment