Twivie logo

 

It's for all of us a great honour to anounce Twivie.com, one of the first attempts to create a community around Twitter on movies!

Well, what is Twivie? Think about this, people are used to tweet about pretty much everything, including movies, and there is a lot of information on movies circulating on Twitter, but no one catches it and presents it in a website where you can easily keep track of the movies being talked about that matter. Twivie attempts to solve this problem by catching all the tweets with a certain syntax, and presents some nice statistics on them.

 See, Twitter is, at the moment, the greatest web forum ever, but very few people are using it to pull out the information being shared there. Twivie is our attempt on movies and will be nice to follow the growth of this application.

I hope you enjoy it and take a moment to check the website.

Start twiving! 




If you're a heavy user of twitter you probably already experienced this: you cannot miss a bit of what is happening on twitter so you always have your Twitter client fired up getting you the updates with a high frequency check (my Twitterific is on a 3min check), and although you have all of your RSS subscriptions safely managed by GoogleReader or your client of choice, you end up knowing the news first on Twitter, by your followers conversations than by deliberately accessing GoogleReader, which itself has an unknown frequency check. Also, if on GoogleReader you have content that's highly important to you (data thats updated by RSS, not your regular blog post) constant accesses to GoogleReader may distract you from the job your doing locally, just to end up knowing nothing knew is there.

Of course you could just forget to check GoogleReader and be notified by a simple RSS Notifier, but why would you install another program if your twitter client already does that?

So I decided to create a Twitter account that gets fed by a simple Ruby script that checks my most important feeds in 3 minutes time loops and if there is any new content, the first 140 characters of it gets posted on twitter (you may edit it to post the entire post but be careful, twitter has a 100 connections per hour limit), because in the feed I'm talking about that is enough to know what happened. So let's get to the code.

require 'net/https'
require 'rexml/document'

begin
  f = File.new("data.txt", "r")
rescue Errno::ENOENT
  #File doesn't exists, fill it with sample data
  f = File.new("data.txt", "w")
  info = {
    "so" => "",
    "eo" => "",
    "aced" => "",
    "po" => "",
    "ges" => "",
    "ppi" => ""
  }
  Marshal.dump(info,f)
  f.close
  f = File.new("data.txt", "r")
end

info = Marshal.load(f)
f.close

urls = {
  "po" => "/external/announcementsRSS.do?announcementBoardId=243496",
  "so" => "/external/announcementsRSS.do?announcementBoardId=243523",
  "aced" => "/external/announcementsRSS.do?announcementBoardId=244762",
  "ges" => "/external/announcementsRSS.do?announcementBoardId=243508",
  "ppi" => "/external/announcementsRSS.do?announcementBoardId=243511",
  "eo" => "/external/announcementsRSS.do?announcementBoardId=243514"
}

actual_info = ""
urls.each { |id,url|
  begin
    http = Net::HTTP.new('fenix.ist.utl.pt', '443')
    http.use_ssl = true
    http.start do |http|
      request = Net::HTTP::Get.new(url)
      response = http.request(request)
      response.value
      actual_info = response.body
    end

  rescue Net::HTTPExceptions
    next #do nothing if couldn't get feed, it'll in the near future
  end

  if info[id] != actual_info  
    info[id] = actual_info

    doc = REXML::Document.new(info[id])
    root = doc.root
    title = String.new(doc.elements["*/channel/item/title"].text)
    desc = String.new(doc.elements["*/channel/item/description"].text)
    desc = desc.gsub(/<[^>]*>/,'')

    begin
      http = Net::HTTP.new('twitter.com', '443')
      http.use_ssl = true
      http.start do |http|
        limit = 140 - (2 + 2 + 2 + title.length)
        request = Net::HTTP::Post.new('/statuses/update.xml')
        request.basic_auth 'username', 'password'
        request.set_form_data({"status"=>id.upcase+"::"+title+"::"+desc.slice(0,limit)})
        response = http.request(request)
        response.value
      end
    rescue Net::HTTPExceptions
      #The submission to twitter failed, forget it! (critical)
    end
  end
}

f = File.new("data.txt", "w")
Marshal.dump(info,f)
f.close

 

 The script is intended to be run by crontab, there you may specify the time interval in which you want the script to be run. The script itself stores the feeds info in a string which for itself is stored in a hashtable that contains all the feed strings indexed by an id that you must provide and be equal in both hash tables, the one for the info, and the one with the URL's of the feeds. In my script all the feeds were located under the same host, so the connection was always and opened with 'fenix.ist.utl.pt' (and SSL). If that is different with you, store the host in another hashtable indexed by the same id's. At last you may want (have) to change the items selected in the XML file returned by the call to be posted on the twitter post. In my example all the feeds started by:

<channel>
    <item>
        <tittle>
        <description>
        <...>
        <...>
    </item>
</channel>

So I select the title and split the description in a way to not fill more than 140 chars total. At last you will have to create a TwitterAccount and provide its username and password in the last connection that is done, the one to Twitter.

I hope this may be useful to you. The result of mine is at @istalert.




A week ago, I suddently got curious about a recent drop in my followers count on Twitter which, I didn't know about, had been because of a bot removal action. Anyway, I came to thought about how many of my contacts were following me back. Althought there are plenty of sites that tell you that, I could name none by the time (check Lessfriends.com or FriendOrFollow), so I thought it would be just faster to write my own thing to do it.

Here's the result, just feed username and password with yours and it should work.

Note: if you've over 100 followers the script might not work due to Twitter's API restriction of 100 requests per hour. If that is the case, just use the web alternatives, this is mostly educational.

 

require 'net/https'
require "rexml/document"

username = ""
password = ""
friendsxml = ""

friends = Array.new
friendlist = Array.new
nonlist = Array.new

http = Net::HTTP.new('twitter.com', 443)
http.use_ssl = true
http.start do |http|
    request = Net::HTTP::Get.new('/statuses/friends/' + username + '.xml')
    request.basic_auth username, password
    response = http.request(request)
    response.value
    friendsxml = response.body
end

doc = REXML::Document.new(friendsxml)
doc.elements.each("*/user/screen_name") {
  |element| friends << element.text
}

friends.each do |f|
  isfriend = ""
  http.start do |http|
      request = Net::HTTP::Get.new("/friendships/exists.xml?user_a=" + f + "&user_b="+ username)
      request.basic_auth username, password
      response = http.request(request)
      response.value
      isfriend = response.body
  end
 
  if isfriend == "<friends>true</friends>"
    friendlist << f
  else
    nonlist << f
  end
end


puts ":::::::Your true friends:::::::"
friendlist.each do |f|
  puts f
end
puts "Total: "
puts friendlist.size

puts "::::::::::Non friends::::::::::"
nonlist.each do |f|
  puts f
end
puts "Total: "
puts nonlist.size




So, lately I haven't been posting much, but hey, that's not an exception, it's the rule of this blog: better be quiet than saying crap. This may be understood by a lot of people has an exception, an odd behavior, since the most of blogs around tries too hard seem active by posting a lot to keep a steady readers base. The problem begins when those bloggers start posting stuff that is just either a copy of other major sites, news, or simply, in the most fairest of the words, crap. And this is something that really bothers me.
 
So, what does this have to do with Twitter? Simple, did you discover some great thing that will do for the post of the day in your blog but is unimportant enough for being there? Go register on twitter, and free your blog of chewing gum. Do the mental work of thinking in something else if you actually want to do a post, meanwhile twitter will filter for you all the minor things that otherwise you would be tempted to post about (I agree with Pedro Cavaco on this).
 
This may eventually put you post's-per-day rate at risk, but isn't content above regularity in a quality scale? Or do you post about everything that happens in your life, which you know it's irrelevant to the readers out there, but still do it because you enjoy to?

That's related to a question that was brought to me a few days ago, wether a blog aggregator for a programming/technology community should filter content by technology or just allow everything that comes from the user. And I though about that for a while and decided that without very well defined blogs, in the way that the author will self-restrict the kind of contents that he talks about or the way in which he talks about them, a blog aggregator like that would turn out to be a salad in which the technology would appear just as the temper, and not the lettuce. And the more a blog aggregator makes the reader filter information the less will be its quality.



Go to Blog