googlecharts gem URI::InvalidURIError fixed

Posted by crux on January 12, 2008

Yesterday i was wondering who is right about the URI and as it turns out the culprit is the googlecharts gem. The RFC defines ‘UNWISE’ characters, the ruby URI implementation seem to correctly fail on them and the Google API defines the just the URI, not how it has to be encoded/escaped.

I posted the scary URI regex from the ruby open-uri package which fails to grasp the Google Charts URIs. Debugging such thing is no fun so i went for a quick fix instead and actually could find it in the googlecharts gem. Just replace:

jstize(@@url + query_params.join('&'))
from ...ruby/gems/1.8/gems/googlecharts-0.2.0/lib/gchart.rb with:
unwise = []#%w({ } | \ ^ [ ] `)
query_params.each do |p|
   unwise.each { |c| p.gsub!(c, "%#{c[0].to_s(16).upcase}") }
end

jstize(@@url + query_params.join('&'))this escapes the ‘|’ (pipe) characters which were causing the exception, like this one:

/opt/local/lib/ruby/1.8/uri/common.rb:436:in `split': bad URI(is not URI?): http://chart.apis.google.com/chart?chdl=requests(cached)|requests&chd=s:Fb9JJfgZ,Fb9KJfgq&cht=lc&chs=300x200 (URI::InvalidURIError)

Technorati Tags: , , , ,

dirty hack: remove xing.com iframe ads with greasmonkey

Posted by crux on January 08, 2008

ok, after this very short twitteruption this afternoon of the premium xings i sat down tonight at home and thought, hmm? getting rid of advertising on xing.com isn’t really worth a premium membership. A short look onto the pagesource with firebug revealed the pretty simple html schema.

so even me personally was able to sketch a simplistic greasemonkey script to erase ad iframes from the xing page like follows:

UPDATE: fixed the script and updated pastie link(thx henrik)



eeeeasy, download from pastie download (old) (no guarantees, you know, script might eat your backups and such)

For those who don’t know, Greasemonkey is a firefox extension to add custom javascript to any website. And this means, you can do whatever you want with the content. There are greasemonkey scripts which are adding links to the amazon site linking to sites with better prices for example. not fair, but thats life. in the web20 world.

have fun

p.s.: they paypal/aws/whatever payment sponsor button to fork 1 euro from your saved premium account money i will  code next week - hope to welcome you back on payday.





Technorati Tags: , , ,