Skip to content

Instantly share code, notes, and snippets.

@reddavis
Created April 2, 2009 11:06
Show Gist options
  • Save reddavis/89139 to your computer and use it in GitHub Desktop.
Save reddavis/89139 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'twitter' # sudo gem install twitter --#-- http://twitter.rubyforge.org/
require 'open-uri'
require 'eeml' # sudo gem install Floppy-eeml --#-- http://github.com/Floppy/eeml-ruby/tree/master
loop do
# Pull in feed from pachube
data = REXML::Document.new(open("http://www.pachube.com/api/YOUR_FEED.xml?key=YOUR_SECRET_KEY")).to_s
# Parse the data
amount = EEML::Environment.from_eeml(data)[1].value
# Post to Twitter
Twitter::Base.new('dothegreenthing', 'PASSWORD').update("Twitterplug reading #{message} watts")
# Repeat every 5 mins
sleep(300)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment