├── .gitignore ├── .ruby-version ├── .ruby-gemset ├── run-demo.sh ├── Gemfile ├── Gemfile.lock └── demo.rb /.gitignore: -------------------------------------------------------------------------------- 1 | priv/* 2 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-2.0.0 2 | -------------------------------------------------------------------------------- /.ruby-gemset: -------------------------------------------------------------------------------- 1 | preact-hackathon 2 | -------------------------------------------------------------------------------- /run-demo.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | time cat hackathon_dump.json | ruby demo.rb 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'riak' 4 | gem 'redis' 5 | gem 'json' 6 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | ethon (0.6.1) 5 | ffi (>= 1.3.0) 6 | mime-types (~> 1.18) 7 | ffi (1.9.0) 8 | json (1.8.0) 9 | mime-types (1.25) 10 | redis (3.0.4) 11 | riak (0.0.1.pre) 12 | typhoeus 13 | typhoeus (0.6.5) 14 | ethon (~> 0.6.1) 15 | 16 | PLATFORMS 17 | ruby 18 | 19 | DEPENDENCIES 20 | json 21 | redis 22 | riak 23 | -------------------------------------------------------------------------------- /demo.rb: -------------------------------------------------------------------------------- 1 | require 'json' 2 | require 'redis' 3 | 4 | def redis 5 | @redis_client ||= Redis.new(:host => "192.168.1.10", :database => 7) 6 | end 7 | 8 | def riak 9 | @riak_client ||= Riak::Client.new(:nodes => [ 10 | {:host => 'ec2-50-16-172-76.compute-1.amazonaws.com'}, 11 | {:host => 'ec2-54-243-23-98.compute-1.amazonaws.com'}, 12 | {:host => 'ec2-54-221-81-11.compute-1.amazonaws.com'}, 13 | {:host => 'ec2-54-226-94-108.compute-1.amazonaws.com'}, 14 | {:host => 'ec2-184-72-173-119.compute-1.amazonaws.com'} 15 | ]) 16 | end 17 | 18 | def process 19 | people = {} 20 | event_count = 0 21 | people_counts = Hash.new(0) 22 | 23 | while line = gets 24 | data = JSON.parse(line) 25 | p = data["person"] 26 | email = p["email"] 27 | people[email] = p 28 | people_counts[email] += 1 29 | event_count += 1 30 | end 31 | 32 | people_counts.sort_by{ |k,v| v * -1 }.each do |k,v| 33 | puts "#{v}\t#{k}" 34 | end 35 | 36 | puts "found #{people.count} total people" 37 | puts "found #{event_count} total events" 38 | end 39 | 40 | process 41 | --------------------------------------------------------------------------------