Fergie Beanbags

In order to allow myself sufficient time to prepare inventory to sell at the IJA Juggling Festival in July and to fill the many mail orders that I already have in hand, I will not be accepting any new mail orders for Fergie Bags until August 1, 2005.

Brilliant. Just as I find out I’m actually able to afford these juggling balls I find I can’t order them. I guess that’s the cost of wanting hand-made props (aside from the monetary cost, of course, but that’s very reasonable). Fergie’s beanbags are easily the best juggling balls I’ve ever used; they practically juggle themselves, especially compared to my Beard DXes which look cool but are a nightmare to learn with. I’ll be first in line to get my order in on August 1st.

Incidentally, a search for "fergie beanbags" didn’t give me FergieProps.com in an anyway reasonable position so hopefully this post will get an appreciable position for that query and point people in the right direction.

Today

Today was long annd fruitful. I’ve been up for too long to want to write more than a few words, but the executive summary is this: I finished my exams. I got a summer internship in the computer science department, working on machine learning in Thunderbird for ten weeks. They’re actually going to pay me to do that. What kind of crazy world do we live in? I also learned to unicycle, which I gather isn’t something that’s generally learned in a day so I’m quite pleased with that. Also Revenge of the Sith is cool.

James Randi Video

Some semi-random browsing led me to this video of James Randi debunking Uri Geller’s claims of paranormal powers, with some other Tonight Show appearances. We definitely need more interviewers like Johnny Carson. He set up a controlled test for Geller’s "powers" and was rewarded with a refusal to perform.

I have to wonder why some magicians need to claim that they have real paranormal powers. Isn’t it far more impressive to be able to fake it, the way Randi and Derren Brown do?

Site Search

What’s that in the sidebar? Is it a search box? Why, yes it is. I wonder how that got there. Oh well, since it’s there now we may as well use it.

Update: Great googly moogly! What do you people expect to find here? You do not want to see these logs. Also, in case you think I’m talking about what you searched for you weren’t alone.

Rory++

Pppprrrrrrrrrrrrrrt! That’s the sound of one of those whistle-like party noise-maker dealies that stretch out when you blow them. Today is my twelveteenth birthday. While I don’t think that surviving for 22 years in this society is a particularly noteworthy achievement (unless you’re a dog, I guess) there do seem to be some people intent on congratulating me for it. If you are among them then, well, carry on. If you feel really generous, I have a wishlist.

Family Guy Season Four

I thought that the new season of Family Guy was still ages away from airing, but it seems it has already started on Fox in the US. Three episodes have aired so far. Since it hasn’t hit Irish TV yet I guess you’ll have to find another way to see it. I’ve seen the first two episodes and they are better than much of season three. The Passion of the Christ II is going to be my most quoted movie for a week or two.

Recursing HTML Frames in Javascript

Sometimes you want to apply a javascript function to an entire page. Maybe you want to replace all of the images with their alt text, maybe you want to open all of the links in new windows, maybe you want to remove the target attributes from links so they don’t open new windows. Bookmarklets usually do something like this, as do Greasemonkey scripts, and sometimes page authors want these functions. It’s as simple as using a couple of document.getElementsByTagName()s and similar functions.

Unfortunately this is singularly unhelpful when dealing with frames-based pages. If your page consists of, say, two frames each of which contains another page and you want to enumerate the links in the child pages you can’t do a simple document.getElementsByTagName("a"). That’ll give you back an empty array, since the frameset page itself (usually) contains no such elements. You need to recurse through the frames and apply the function to every document in the frameset.

function recurseFrames(doc, callback)
{
	if (typeof callback != 'function') return;
	// apply to the current document:
	callback(doc);
	// recurse over the child documents:
	var frames = doc.getElementsByTagName("frame");
	for (var i = 0; i < frames.length; i++)
	{
		var d = frames[i].contentDocument;
		recurseFrames(d, callback);
	}
}

The above function takes two arguments: a document to recurse, and a function to apply to the document and all of its child documents. If you're calling this from a bookmarklet you can just pass the document object as the first argument, since it will refer to the top document in the heirarchy. If you're calling it from a page within the heirarchy you need to use top.document. Of course you don't have to recurse the whole tree, so you could give it any document object.

The function makes sure that the second argument is a function before it tries to do anything. Then it applies that function (the callback function) to the document. If it's a simple document (ie. no frames) then that's all that happens, but if there are child frames then the function applies itself to their documents too, and so on down the heirarchy.

This is about the simplest implementation of this sort of recursion. A number of extensions immediately suggest themselves. What if you want to return some value(s) from the function? Say you want to enumerate the links in the entire compound document. You could always edit it like this:

function recurseFrames(doc, callback)
{
	if (typeof callback != 'function') return;
	var result = {};
	// apply to the current document:
	result.push(callback(doc));
	// recurse over the child documents:
	var frames = doc.getElementsByTagName("frame");
	for (var i = 0; i < frames.length; i++)
	{
		var d = frames[i].contentDocument;
		var res = recurseFrames(d, callback);
		for (var j = 0; j < res.length; j++)
		{
			result.push(res[j]);
		}
	}
	return result;
}

No doubt there's a cleaner way to accomplish this result, but the intention is clear. Each call to recurseFrames() returns an array of the results of applying the callback function to its children (and itself), which is combined with the parent's results array. The final return value is a flat one-dimensional array with a single element per document. If you knew the result of the callback function was an array you could modify the function further to sow these arrays together rather than returning an array of arrays.

Another reasonable extension is to extend this function to include iframes. This would require altering the definition of the frames variable. It's a trivial extension and I leave it as an exercise for the reader.

Getting My Bat On

It’s called a musical baton. What’s it for? Clubbing people.

Total volume of music files on my computer
8.2 Gigabytes, about 3 days 17 hours.
The last CD I bought
American Idiot by Green Day, and How to Dismantle an Atomic Bomb by U2.
Song playing right now
Ramones, Rockaway Beach
Five songs I listen to a lot, or that mean a lot to me
  • Paranoid Android – usually Radiohead, sometimes Brad Mehldau, The Section, or the University of Massachusetts Front Percussion Orchestra. You can’t have too many versions of one song. I have seven Karma Polices.
  • Evolution – Motörhead. The grand unifying theory of biology and (sometimes) Triple H’s entrance music. My iPod volume doesn’t quite go high enough for this one.
  • What Would Brian Boitano Do? – D.V.D.A. From South Park: Bigger, Longer and Uncut, the greatest musical ever made.
  • Everybody Hurts – R.E.M. Because I was sure I’d bore of this song quickly and years later I still haven’t.
  • The Power of Love– Huey Lewis and the News. Because it’s still 1985 in my heart. Alternatives for this spot were Real American (Hulk Hogan’s music), You’re the Best from Karate Kid, Danger Zone from Top Gun, and Axel F

To be fair on the songs I didn’t mention I should tell you that this list is basically random.

The five people I’m passing the baton onto

No-one. Given the unchecked pyramid nature of the baton’s distribution, and my embarrassingly low readership, and the fact that most of my readers don’t have blogs, I’m going to have to go ahead and declare myself a leaf node. Unless you want to jump on the meme-wagon, in which case drop a comment and I’ll pretend I passed the baton on to you. No-one will notice that I dropped it on the way.

Exams Start Tomorrow

So it turns out I’m getting that weird exam feeling again even though I don’t actually have to do anything for these ones other than turn up (if that). You know the feeling. You’ve got things you want to do but you don’t feel right doing them because you "should be preparing" for your exams. For some reason I have that paralysing feeling now, but without the associated need to prepare. It’s like having an itch in a missing limb. I have potential blog entries coming out my ears right now but no real motivation to sit down and finish one. Several of them will probably end up in a link dump sometime next week when they get too old to be useful.

Hammer Time

If Tontie isn’t already taking over your life I don’t know where you’ve been for the last few weeks. Or maybe you just don’t have a number pad on your keyboard. For those of you who are becoming consumed by this game, try the code 726 538 941. It appears to let you skip to any level you’ve already been to, but with a winged gold hammer and 1000 coins.