Skip to content

Instantly share code, notes, and snippets.

@k9ert
Created May 23, 2013 17:47
Show Gist options
  • Save k9ert/5637969 to your computer and use it in GitHub Desktop.
Save k9ert/5637969 to your computer and use it in GitHub Desktop.
Tweets per day in ruby
#!/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