Going to spare you the obligatory 5 paragraph ‘I haven’t posted in months’ intro. So, my new project has been figuring out how to condense this business of twitter into something people can understand and find useful.
So I bought http://twitplot.com yesterday, grabbed the pretty well done twitter gem http://github.com/jnunemaker/twitter/ and started playing with the public search api.
What I’ve gotten out of it is a way to see what people are saying about any keyword (or idea really) anywhere in the world (or at least anywhere that I can geocode using a hacked version of GeoKit http://geokit.rubyforge.org/).
Some useful things I’ve done in the app that I’d like to share are how I’ve captured urls and user names in a “tweet” and added the markup so you can click on them. The regex was pretty easy, check it out:
def add_url_markup(text)
urls = []
users =[]
# find urls
text.split.each{|a| a=~/(http\:\/\/\S+)/; urls << $1}
# find twitter usernames (@someusername)
text.split.each{|a| a=~/(\@\S+)/; users << $1}
# add markup
users.compact.each{|user| text.gsub!(user, "#{user}")}
urls.compact.each{|url| text.gsub!(url, "#{url}")}
return text
end
view this code at gist.github.com
So check twitplot.com out play with it let me know what you think.