Archive for May, 2006

Injustice

Friday, May 26th, 2006

I put it to you that it is when our sense of ‘right’ and ‘wrong’ is overidden by our sense of ‘us’ and ‘them’ that injustice prevails in our society.

This is the essence of wedge politics, and the grease in the gears of John Howard’s success.

Live Boy, Dead Girl

Thursday, May 18th, 2006

I used to believe that George Bush’s approval rating couldn’t drop below 40 unless there was an unprecedented scandal. According to Pollkatz it’s now spent a month below 35.

How low can he go?

Firefox plugin and cookies

Monday, May 15th, 2006

Crossposted from blog.collectik.net

If you’re a firefox user, I hope you’ve already discovered that we have a ‘Collectik This’ plugin. Once you’ve installed this plugin, wherever you are on the internet, if you find a feed you would like to collect, or an audio or video file you’d like to add to your playlist, just right click on the link, select ‘Collectik This’ from the menu, and we’ll do the rest.

When I was developing this (hat-tip to the excellent roachfiend tutorial) I found I needed one trick which was hard to find documentation on. Since it took a while to figure it out, I thought I’d share it. If you aren’t interested in developing firefox plugins, now is probably a good place to stop…

The problem: if you open a popup window in a firefox plugin (using window.open and specifying the URL), firefox doesn’t (as far as I can work out) send any cookies with the http request. This makes it a bit hard to do any sort of session management. The work around for this came in two parts. Firstly, since we use the Ruby cgi/session session management, there is no need to send a cookie if you can extract the session id and pass it as a parameter in the URL (&_session_id=xxxxx). Secondly (and this is the bit that took some finding), you have access to the firefox cookiemanager. So we have a method like this…

function getCookie() {
	cookiemanager = Components.classes["@mozilla.org/cookiemanager;1"].getService();
	cookiemanager = cookiemanager.QueryInterface(
                                  Components.interfaces.nsICookieManager);  

	var enumerator = cookiemanager.enumerator;
	while (enumerator.hasMoreElements())
	{
		var nextCookie = enumerator.getNext();
		if (!nextCookie) break;
		nextCookie = nextCookie.QueryInterface(Components.interfaces.nsICookie);
		if (nextCookie.host=='collectik.net' && nextCookie.name=='_session_id')
		{
			return nextCookie.value;
		}
	}
	return false;
}

Maybe that will help someone… and if there is a better way, I’d love to hear it.