Skip to content

Instantly share code, notes, and snippets.

@macournoyer
Created December 12, 2008 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macournoyer/35253 to your computer and use it in GitHub Desktop.
Save macournoyer/35253 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# List tweets w/ links.
# require: sudo gem install jnunemaker-twitter --source http://gems.github.com
# usage: twitlinks [num]
require "rubygems"
require "twitter"
# EDIT THIS
EMAIL = 'ur@emailz.com'
PASSWORD = 'greenerpoop'
trap("INT") { puts; exit }
def link(text)
text[/http:\/\/.*?(\s|$)/, 0]
end
tweets = Twitter::Base.new(EMAIL, PASSWORD).timeline.select { |t| link(t.text) }
tweets.each_with_index do |t, i|
puts "[%i] %s: %s" % [i, t.user.name, t.text]
end
unless visit = ARGV.first
print "open? "
visit = STDIN.readline
end
exec "open #{link tweets[visit.to_i].text}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment