The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
People in Bangalore like to eat out on Sundays

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Premshree Pillai

Posts: 478
Nickname: premshree
Registered: Mar, 2004

Premshree Pillai is a Ruby evangelist, working with Yahoo!.
People in Bangalore like to eat out on Sundays Posted: May 4, 2006 8:12 AM
Reply to this message Reply

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
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Premshree Pillai
Latest Posts From Premshree's Personal Weblog

Advertisement

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

Enjoy!

Read: People in Bangalore like to eat out on Sundays

Topic: Protolize: Herramientas esenciales para la web en un solo sitio Previous Topic   Next Topic Topic: Thread local variables

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use