Created
May 23, 2013 17:47
-
-
Save k9ert/5637969 to your computer and use it in GitHub Desktop.
Tweets per day in ruby
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
#!/usr/bin/env ruby | |
# This snippet can be used to feed a megabitmeter | |
# with the number of tweets on a feed | |
# see also http://megabitmeter.de/ | |
# Twitter-API: https://dev.twitter.com/apps | |
require 'rubygems' | |
require 'twitter' | |
Twitter.configure do |config| | |
config.consumer_key = "someConsumerKey" | |
config.consumer_secret = "TheConsumerSecret" | |
config.oauth_token = "anOauth-Token" | |
config.oauth_token_secret = "The secret" | |
end | |
while (true) | |
timeline = Twitter.home_timeline | |
ts_20th_tweet = timeline[-1].created_at.to_i | |
#print "seconds difference: #{Time.now.to_i - ts_20th_tweet}\n" | |
seconds_per_tweet = (Time.now.to_i - ts_20th_tweet ) / 20 | |
#print "seconds per tweet #{seconds_per_tweet}\n" | |
tweets_per_second = 1 / seconds_per_tweet.to_f | |
#print "tweets per second #{tweets_per_second}\n" | |
tweets_per_week = tweets_per_second * 60 * 60 * 24 * 7 | |
print "tweets_per_week #{tweets_per_week}\n" | |
#print "#{tweets_per_week.to_i}\n" | |
`echo #{tweets_per_week.to_i} > /dev/ttyUSB0` | |
`sleep 90` | |
print "and again .." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment