Archive for November, 2007
passing parameters to XMLHttpRequest’s onreadystatechange function
I’ve been smashing my head against this all day - but I finally got something working consistently and reliable, so I better damn well document it. This is as good a place as any, and hopefully it will be useful to others.
I needed to make an Ajax call, so I turned to my good friend XMLHttpRequest. One wrinkle was that I needed to pass in a parameter to it… so I tried:
var test = "bar";
req = new XMLHttpRequest();
req.open("GET", myURL, true);
req.foo = test;
req.onreadystatechange = function() {
if (this.readyState != 4)
return;
if (this.status == 200) {
alert(this.foo); // should print out "bar"
}
}
req.send(null);
For the most part this worked. Except every now and then… when it didn’t. Most annoyingly, it failed pretty consistently when I was trying to use it within a nested Ajax call (complicated code, don’t ask.. it’s not interesting).
I’m not sure why it doesn’t work to be honest. From my understanding, req.foo should just instantiate a new foo member variable of the XMLHttpRequest object I just created and set it to be referenced via ‘this.foo’ inside any member function. I’m guessing it’s something to do with the scoping of onreadystatechange being set to the reference of an anonymous function so the anonymous function isn’t actually part of the XMLHttpRequest object and thus doesn’t have access to its member variables. What’s frustrating is that it works most of the time. A consistent failure model would actually be more helpful here.
Anyway, enough blabbering, here’s what seemed to work for me:
var test = "bar";
req = new XMLHttpRequest();
req.open("GET", myURL, true);
req.onreadystatechange = function(foo) {
return function() {
if (this.readyState != 4)
return;
if (this.status == 200) {
alert(foo);
};
}(test);
}
req.send(null);
Now that works reliably for me 100% of the time.
6 comments November 27th, 2007
a dearth of packages
This Thanksgiving I give thanks for all the packaging work underway in OpenSolaris. I look forward to a day in the future where I don’t have to spend so much time building out packages for all the updated software I need.
I’m building out the new Grommit machine, and part of what Grommit hosts is a whole bunch of Zones. I like to try to keep everything clean with pkg installs, so I’ve spent a good part of the past two days building Solaris (snv_75a) packages for Dovecot, PHP5, and Postfix.
Yes, I realise that packages for these already exist on Blastwave and elsewhere, but I want ones that leverage the Apache2, MySQL, and OpenSSL that Solaris already ships with. Anyway, thankfully the software all built fairly straight-forward which made my life a lot easier.
About the only thing left that I need is SpamAssassin and I’m hoping to use Eric B’s package that he put together for the OpenSolaris mail server for that. Eric passed me the Postfix package they use but unfortunately I ended up needing to rebuild it anyway since I wanted it to have TLS + SASL and authenticate against the Dovecot SASL.
I’ve done migrations of all the ZFS data for the home and web directories (yay for zfs send | ssh zfs receive), and I’ve installed Mailman (which I didn’t bother putting in a package since it cleanly separates itself in its own directory). I did a test migration of the MySQL database (which seemed to barf only on a field named ‘key’, which fortunately was easily worked around by escaping it with backticks). I’m pretty happy with the general build out of the machine so far. When I built out grommit last time it was early on in my days of using Solaris, so in general I’d made a mess of installing software all over the place, some in Blastwave, some from source, and things poorly and sloppily done everywhere. I’m trying to do things properly this time to make it easier to quickly commission zones that don’t require a whole bunch of finangling to get running cleanly.
I wonder if I can get grommit migrated by Sunday. That’d be a nice Thanksgiving surprise.
5 comments November 23rd, 2007
note to self: read notes to self
Urgh. Just spent 45 minutes trying to debug why my Postfix + Dovecot SASL setup wasn’t working. Reading the (very concise & well written) HOWTO on how to test it, it still wasn’t working. I knew how to do it, so I totally ignored reading my ~/Documents/Grommit/POSTFIXREADTHIS_IDIOT doc I wrote to myself last time I did this.
Finally, after 45 minutes - I gave up, and read my note to self I wrote 3 years ago. A very important line at the bottom said:
“If you have Perl special characters ($, &) in your password, don’t forget to escape them or the password base64 encoding won’t work. You just wasted an hour on this, dumbass.”
Sigh. I just updated it to “You just wasted an hour and 45 minutes on this, dumbass.”
1 comment November 22nd, 2007
sadly moving up in the ranks
oakland #4! oakland #4! oakland #4!
yeah, sad i know.
on the one hand i’m annoyed by the report, sure. but on the other hand, i’m annoyed by the people who are annoyed by the report.
In Oakland, Police Chief Wayne Tucker said people might be misled by the report. “The department is always interested in how we’re being rated,” he said, “but I think a rating can be very deceptive and ultimately give a false impression.” He said being ranked fourth on the list of dangerous cities could easily lead people to believe the whole city is under siege from crime.
I don’t think people reading the report will honestly believe the city is under siege, but let’s be honest - Oakland has an absurd amount of crime. Deceptive impressions go both ways. Tucker’s quote saying “crime is concentrated in “two reasonably small areas” in East and West Oakland.” is bullshit. There is crime all over Oakland, and while the Oakland PD has noticeably and admirably stepped up its efforts to combat it (and it has be on the decline, to be sure), I think having the press to put some more pressure and resources on the issue is a good thing.
1 comment November 19th, 2007
new grommit online
yay, the new grommit machine is up and running…
[stevel@animalfarm:~] 507$ psrinfo -vp
The physical processor has 4 virtual processors (0-3)
x86 (GenuineIntel 6FB family 6 model 15 step 11 clock 2400 MHz)
Intel(r) Xeon(r) CPU X3220 @ 2.40GHz
[stevel@animalfarm:~] 508$ prtconf | grep "^Memory"
Memory size: 4095 Megabytes
[stevel@animalfarm:~] 509$ uname -a
SunOS animalfarm 5.11 snv_75 i86pc i386 i86pc
[stevel@animalfarm:~] 510$
3 comments November 17th, 2007
ISRAEL ROCKS!!!!
every England fan owes Omer Golan a beer.
holy crap, can it get any more amazing than an Israel goal in stoppage time over Russia!?!?!?
…. too bad Owen is out now from the friendly with Austria.
Will McClaren finally given Jermaine Defoe the run he deserves now?
2 comments November 17th, 2007
party time

yeah! party time!
Songbird is co-hosting a party with Get Satisfaction tomorrow night. read the deets at our blog, and come on by!
1 comment November 14th, 2007
nightingale is hatched
Project Nightingale has officially been hatched, and I’m psyched to be able to post this with both the Songbird AND OpenSolaris blog tags. Albert (aka Triskelios) has done some impressive work already in trying to get XULRunner and Songbird ported over to OpenSolaris. We’ve hit some speedbumps though, and thought that formalising it into a project and getting some more eyes and hands on things would help speed it along. We’ve been approved and are being graciously sponsored by the Desktop Community.
I’m really psyched and looking forward to having the most kickass media player (no bias whatsoever) ported to and running on the best operating system (again, no bias whatsoever). Being able to combine my two favourite open source projects rocks.
So if you’re a desktop hacker, a media player expert, a Mozilla whiz, or just someone looking for a fun project to hack on - please join the project, and help out. We’ll have Albert’s patches posted soon, and we’ll be having our discussion in the Desktop forum, or you can subscribe to the Desktop mailing list.
3 comments November 13th, 2007
Songbird going-on’s….
It’s been nice to see people talking more and more about adding supporting for Songbird or developing new sites and add-ons and translations to take advantage of Songbird’s APIs. The developer love is growing, can you feel it?
We also totally took out a huge amount of suck in the add-ons site so you can now filter, search, and sort on various variables making the site experience a whole lot better.
Anyone interested in digital media, and more specifically media on the web should drop by our office next Tuesday from 1-3pm. We’re starting to hold a series of talks (entitled “Media Web Meetups”) talking about the concept of the Media Web, and how open standards, protocols and formats will be utilised. Our first talk/discussion is going to be led by Mike Linksvayer, CTO of Creative Commons, and he’ll be talking about some of the recent upheaval in the media industry with Madonna, Trent Reznor, and Radiohead’s moves to publish music directly on the web. Should be a really interesting talk.
1 comment November 8th, 2007
Closed processes and development in an open source world
I just read an interesting article on Linux.com criticising two examples of poor showing in the open source world, one revolving around a KDE icon theme, and the other around GIMP’s UI team.
Certainly I see some parallels in any open source project, both OpenSolaris & Songbird included.
First: my opinions. You didn’t ask for them, but you’ll get them anyway. Blogs rule like that. For the two examples cited in the article, I actually have differing opinions.
For the icon example, I disagree with the Oxygen project and agree with the writer. The icon developers gave up any rights they had to restrict redistribution with their license they published under. The derivative theme was well within its rights to redistribute the Oxygen icons.
For the GIMP UI example, I actually agree with the GIMP UI team. I think they way in which they phrased it could have been better. Perhaps instead of “I am afraid that I do not have positions open at the moment.”, he could have expanded and invited the volunteer to submit his work for review and inclusion without necessarily being a part of the formal GIMP UI team. While some people may disagree with me, I think UI work benefits from having a core team of people with a shared set of goals and design aesthetic. Adding another team member could alter that dynamic and/or add more overhead to the team.
Anyway - these are pertinent issues to both communities in which I participate in. OpenSolaris perhaps more than Songbird - since Songbird has no internal/closed repositories of source. But one prime example of a project people complain about is installation, or packaging - and I know I’ll probably get heat for this, but I think doing closed development is not that bad. The packaging project took some heat for doing its initial prototyping and development (I know I had at least one debate with sch about it ;-)) between its team members before opening up and publishing its work. But given the conflict that can arise between people deriving work prematurely (e.g. the Oxygen case), or even just the issue of it being a design-in-progress (let alone a work-in-progress) means its often easier to be more agile and develop the core of the project between team members (whether that’s internal to Sun or involving external members).
Open source your work when you are ready - not when people ask you to
When you are ready for people to hack on your code, make derived works, and submit features and bugs - then you are ready for open source development. If you aren’t ready for those, then don’t. Open sourcing code isn’t free (assuming you care about your open source community - throwing code over the wall, as always, is cheap and easy - and you get what you pay for). If you want a thriving community then you have to be ready to spend time to cultivate it. If you’d rather be hacking on code to get something initially out - then you shouldn’t publish it initially.
1 comment November 4th, 2007









