Last active
August 24, 2016 20:18
-
-
Save pawelniewie/eeec1d0ed9b289985e623a20cc9ce71b to your computer and use it in GitHub Desktop.
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
#!/bin/env ruby | |
require 'json' | |
require 'time' | |
cutoff = Time.parse('2016-08-10') | |
log = JSON.load(ARGF) | |
entries_per_day = Hash.new{ |hash, key| hash[key] = [] } | |
(log['entries']. | |
select { |e| Time.parse(e['creationDate']) > cutoff }. | |
reverse. | |
reduce (entries_per_day) { |memo, e| memo[Time.parse(e['creationDate']).strftime('%F')] << e; memo }). | |
each_pair { |date, entries| | |
puts | |
puts date | |
entries. | |
sort { |x, y| Time.parse(x['creationDate']) <=> Time.parse(y['creationDate']) }. | |
each { |e| puts Time.parse(e['creationDate']).strftime('%R') + ' ' + e['text']} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple script that will print out entries from Day One JSON dump.
Sample output: