How to empty a Gmail label with FireWatir

When you have a huge label with thousands of messages, Gmail can’t handle deleting all of them at a time (it says it can, but for me it’s never worked). This solves the problem.

I wrote it more as a practice to get familiar with FireWatir, so it’s not very pretty or anything and it’s a bit slow. I think WWW::Mechanize would be faster at it (although you wouldn’t have the eye-candy of seeing the live action on the browser ;-). I’ll port it to Mechanize, once I have some time, as a bootstrap into learning that too. I’ll have to subscribe to a few more lists in order to have testing ammo for all that. ;-)

If you have doubts on how to use or suggestions on how to improve it please feel free to contact me. It assumes, by the way, that Gmail is in German. Replace that string with the one that comes up for your language.

P.S.: there’s also a syntax highlighted version. Does anyone know of a way to highlight the code here in WordPress?

def empty_label(label)
  # you need a Firefox instance already running with JSSh installed and listening
  ff = Firefox.new
  # Goes to Gmail in HTML
  ff.goto('http://mail.google.com/mail/h/x4odcwnm5f5v/?s=l&l=#{label}')
  a = []
  # doing 'c.set' didn't work for me here so I had to do this hack of getting the value
  # and then acquiring the element through ff.checkbox(:value,value)
  ff.checkboxes.each {|c| a << c.value}

  while a.length > 0 do
    c = []
    a.each {|v| c << ff.checkbox(:value,v)}
    # checks all checkboxes
    c.each {|e| e.set}
    # clicks the drop-down entry for deleting
    ff.select_list(:name,'tact').select('In den Papierkorb verschieben')
    ff.button(:name,'nvp_tbu_go').click
    a = []
    ff.checkboxes.each {|c| a << c.value}
  end
end
Posted in Uncategorized. Tags: , , , , , . Leave a Comment »

Summer of Code All-nighters

After about a week of digging up stuff on Free Software projects, subscribing to a dozen mailing lists, emailing developers, reading documentation, waiting for feedback, thinking up proposals, twisting and changing them, confronting them wih my own limitations and interests, I finally gave birth to two applications for the Google Summer of Code, one for Ruby Central and the other for Eclipse. Below are the abstracts:

The Ruby Central application:

This project aims at allowing users to record normal usage on a website and then have a script generated that can reproduce such actions.

This script is generated in Ruby and can be changed and mixed with existing Ruby code to extend its behaviour, using regular Ruby variables, loop constructs, etc.

A parser is going to be built for Firefox logs of user-activity (extracted by existing free software extensions) with the ability to generate code for the browser-driving tool FireWatir.

The Eclipse application:

Ruby has a fast-growing community which has not yet settled for one particular
editor/IDE and still has ongoing debates on that topic. It has not found a home
yet.

The ability to change one’s surroundings and make it more confortable for daily
usage by implementing helpers appropriate to one’s specific needs is crucial in
having this feeling of acquaintance and familiarity with a tool.

Unfortunately, the barrier of entry into Eclipse plug-in development for Ruby
users is still pretty high, as few are as skilled in Java as they are in Ruby.

This project aims to bridge that gap by allowing Eclipse plug-ins (or a subset
of the possible ones) to be develop entirely in Ruby.

This last one was written on a rush and with almost no previous research so it’s not very well-finished. I’m open to any ideas and suggestions on either one.