Created
August 18, 2010 10:33
-
-
Save pauldruziak/534280 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
source "http://rubygems.org" | |
gem "twitter", "~>1.2.2" | |
gem "gchartrb", "~>0.8" |
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
# encoding: utf-8 | |
require 'rubygems' | |
require 'twitter' | |
require 'google_chart' | |
twit_at = Array.new(24, 0) | |
username = 'paveldruzyak' | |
options = {:count => 200, :trim_user => false, :include_rts => true, :include_entities => false} | |
twits = [] | |
twits_count = 0 | |
begin | |
puts 'полученно ' << twits_count.to_s << ' твитов' | |
puts 'последний полученный твит ' << twits.last[:id].to_s unless twits.empty? | |
options.merge!(:max_id => twits.last[:id]-1) unless twits.empty? | |
twits = Twitter.user_timeline(username, options) | |
twits.each do |twit| | |
twit_at[Time.parse(twit[:created_at]).hour] += 1 | |
end | |
twits_count += twits.count | |
sleep 2 | |
rescue Exception => msg | |
puts msg | |
sleep 5 | |
end until twits.empty? | |
# Bar Chart | |
GoogleChart::BarChart.new('800x200', "Twitter time", :vertical, false) do |bc| | |
bc.data "Количество твитов", twit_at, '0000ff' | |
bc.axis :top, :labels => twit_at | |
bc.axis :x, :labels => 24.times.collect { |i| i } | |
bc.axis :y, :labels => 11.times.collect { |i| i*50 } | |
puts "\n#{username}" | |
puts bc.to_url | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment