Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
## twitter-drip.rb #!/usr/bin/env ruby # Make a file in $HOME called tweets and put one tweet per line. # in crontab # 1 * * * * cd /path/to/script_dir/ && ruby twitter-drip.rb > /dev/null 2>&1 # then ever hour, a tweet will be dripped to twitter require 'net/http' TWEET_FILE = File.join(ENV["HOME"], "tweets") TWITTER_USER = "" # your twitter username TWITTER_PASS = "" # twitter password # read all the pending tweets into an array tweets = open(TWEET_FILE).readlines # get the first one and remove it from the array tweet = tweets.shift open(TWEET_FILE, "w") do |file| file.write(tweets.join) end if tweet # post the tweet res = Net::HTTP.post_form(URI.parse("http://#{TWITTER_USER}:#{TWITTER_PASS}@twitter.com/statuses/update.json"), {'status' => tweet[0..140]} ) puts res.body end
From the Design Piracy series on my blog: