This post originated from an RSS feed registered with Ruby Buzz
by Premshree Pillai.
Original Post: People in Bangalore like to eat out on Sundays
Feed Title: Premshree's Personal Weblog
Feed URL: http://premshree.livejournal.com/data/rss
Feed Description: Premshree's Weblog
Interestingly, folks in Bombay seem to like eating out on Tuesdays:
Notes:
1. Most people seem to end up using the tag hotel when they really mean to use restaurant, so I’ve gone with the former. 2. I rely on Flickr photo data and my program. You don’t have to take the graphs seriously.
Here’s the script I wrote to draw that graph (requires flickr.rb and rgplot):
#!/usr/local/bin/ruby18
require "../flickr"
require "gnuplot"
API_KEY = '1f01852f7641ab8d12a2eccd1d7f0b19'
SECRET = '091a8141470efa6c'
flickrObj = Flickr::Flickr.new(API_KEY, SECRET)
photosObj = Flickr::Photos.new
days = Hash.new { |h,k| h[k] = 0 }
photosObj.search(["bangalore","hotel"], "all", 0, 1000).each { |ele|
if /([0-9]+)\-([0-9]+)\-([0-9]+)/.match(photosObj.get_info(ele)["date_taken"])
t = Time.mktime($1, $2, $3)
days[t.strftime("%a")] += 1
end
}
Gnuplot.open do |gp|
Gnuplot::Plot.new(gp) do |plot|
plot.title "Photos taken in restaurants in Bangalore"
plot.ylabel "No. of Photos"
plot.xlabel "Days"
i = 0
plot.xtics("("+days.keys.map{|ele| "'#{ele}' #{i;i+=1}"}.join(",")+")")
plot.data << Gnuplot::DataSet.new([(1..7).to_a, days.values]) do |ds|
ds.with = "linespoints"
ds.notitle
end
end
end