Skip to content

Instantly share code, notes, and snippets.

@darrinholst
Created May 23, 2014 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrinholst/3a46a509c3f112e0ddd3 to your computer and use it in GitHub Desktop.
Save darrinholst/3a46a509c3f112e0ddd3 to your computer and use it in GitHub Desktop.
require 'csv'
require 'time'
drunk_tweets = []
CSV.new(File.new('tweets.csv'), headers: true, header_converters: :symbol).to_a.map(&:to_hash).each do |row|
tweet_hour = Time.parse(row[:timestamp]).hour
drunk_tweets << row if tweet_hour > 22 || tweet_hour < 5
end
drunk_tweets.reverse.each {|t| puts "#{Time.parse(t[:timestamp])}: #{t[:text]} (https://twitter.com/darrinholst/status/#{t[:tweet_id]})\n---\n"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment