Wednesday, May 31, 2006

...And Thanks For All The Fish

I've been a Senior Developer here at Headshift for a little over two years now, and over that time I've learned an awful lot about social software, met some very smart people, made some good friends, and grown as a person myself, too. (ick - cheesey, but you know what I mean, I hope)

However, I've been doing a lot of thinking lately about my future career direction, and where I want to be in X years time, etc.... and I've decided it's time to move on.

So, from next month, I'm going to be a hardcore Java bod at Trampoline Systems, a small startup with big plans, who are doing some very interesting things with email...

Of course, moving to full-time Java means that I won't be using CF in my day-to-day work, so I'll be less involved in the CF community here - *sniff*, and I'll probably have far fewer CF-relevant things to spout off about in this blog.

So I have a decision to make - do I start a new, exclusively Java-related blog to try and keep this one on-topic, or should I keep posting my random missives here and let you guys take me off your feed readers if you decide the increasingly Java-heavy content means it's no longer relevant?

Personally, I'm leaning towards the second option, but I'll throw it over to you guys - anyone have a strong opinion either way?

Anyway, to borrow a classic phrase from the dolphins, So Long, And Thanks For All The Fish. One of the things that "everybody knows" about CF is the dedication of the community, and their willingess to help with any problem, small or large. It's going to be a bit of a wrench to leave it behind. Hopefully I'll make it to the CFUG tomorrow night - if I do, the first pint is on me :)

Back from Jbel Toubkal with a new blog

Me on the summit of Toubkal
Originally uploaded by Dr Snooks.
Well, we've just about recovered from our ascent of Jbel Toubkal, and the associated combination of altitude sickness, heatstroke and what I'll politely refer to as "Marrakesh belly". But still, a damn fine time was had by all, and though it was only a week away, it felt more like a month.

I've decided that, to try and keep this blog vaguely on-topic, I should create a separate blog for my inexplicable exploits in search of altitude, so here it is :

Dynamove - "because it's there"

There's only one post in it at the moment, but I'll put all my climbing / mountaineering / trekking thoughts and reports on there and keep this blog for the techie stuff.

In the meantime, if you really want to see more, here's the photoset on Flickr.

I also have a significant announcement to make, but that deserves a separate post all of it's own. ;-)

Friday, May 19, 2006

OT: 'Aint No Mountain High Enough?

Well, my wanderlust is getting the better of me again, so I'm off to the High Atlas mountains of Morocco next week to climb Jbel Toubkal with Lise, maybe sneaking in an extra diversion to Lac D'Ifni on the way down, depending on how well we cope with the altitude.

Needless to say, there's not going to be much connectivity on the edge of the Sahara at 4000m high, so I'll be offline and thoroughly enjoying the free and easy nomadic existence for the week.

This is our first time above about 2000m altitude, so we chose a non-technical mountain to see how we get on with possible Altitude Sickness. I remember feeling distinctly dizzy in Slovenia as we approached the top of KomarĨe, and that's not even particularly high - mind you, I think that's more likely due to me giving my head an almighty crack on the roof of a cave. Note to self: next time you are running through a cave, looking where you are going is a good idea ! I'm dreading going bald - I've had that many bumps on the head, you'll be able to play Noughts and Crosses in the scar tissue on my scalp...

Thursday, May 18, 2006

java.lang.StackOverflowError with RegEx backreferences

Just got to the bottom of an issue that I thought I'd share: one particular page on a clients' site was bombing out, saying

Stack Trace: java.lang.StackOverflowError

...with no further debug info about line number, template, or anything useful.

It's a CMS / database driven site, so we downloaded a copy of the live DB to try and replicate the issue locally - no luck, it worked fine.

So straight away, we suspected the code - if it's not the data, it's got to be the code, right? And if it works on local dev boxes, but not live, logically you suspect that the code on live is *shudder* .....not the same as the code on dev....

( Cue lightning flashes, howling wolves, dramatically tense organ music, women fainting with the back of their hand to their forehead, etc etc )

But no - the relevant code was exactly the same on live as in our SVN repository. In fact, neither copy had changed since April *last year*.

So when all else failed, we resorted to the good old-fashioned, tried-and-tested, never-fails method of advanced debugging - *ahem* commenting stuff out until it works, and putting it back in line-by-line until it breaks again, at which point, you should have identified the offending line of code.

We narrowed it down to one particular dsp_ file in the offending fuseaction, but there was still bizarreness aplenty - if I cut out a cfloop around a query, it still died, but if I cut out the surrounding pure html <table> and </table> tags, it worked.

Now how weird is that?

To cut a long story short, after much to-ing and fro-ing and "**** me, that's weird"-ing with three of us round the screen, I eventually realised that it wasn't anything in the dsp_ file at all, the problem was actually due to a Regular Expression we use in the lay_default.cfm layout file, for post-processing of content.

It's a site that uses slash-separated parameter lists for Search-Engine-Safe URLs, but it does this by post-filtering the rendered HTML in fusebox.layout with some reg-ex, looking for href="..." and replacing it.

While it's at it, it also takes the opportunity to strip out any unnecessary whitespace from between tags, like this :

sString = REReplaceNoCase(arguments.sString, ">([[:space:]]){1,}<", "> <", "ALL");

Now, hands up who sees the problem with that? Took me a couple of looks...

The problem is with the placing of the brackets. Let's parse that reg-ex into english:

">([[:space:]]){1,}<" == look for a closing tag followed by at least one whitespace character, and capture it.

Capture what?

This was actually creating one separate back-reference for EACH whitespace character. So if you have 1000 whitespace characters, it creates 1000 backreferences. Evidently someone must have put just enough whitespace into that particular content that on a busy server, the stack was just pushed over the edge.

What it should have done, of course, is put the {1,} (which means "at least once") inside the capturing bracket, like this:


...thus creating one backreference for the whole string of whitespace. In fact, as the replace-with string was just a hard-coded single-space character ( "> <" ) there was no need for the backreference to be captured at all.

So are Regular Expressions evil? No, but they are extremely powerful, and as anyone who has seen Spiderman will know, "with great power comes great responsibility". They can also be a real pain to debug :)

Friday, May 05, 2006

Substitute Friday Joke - apologies to Andy!

As Andy Jarrett is away sunning it up in Mexico this week, the CF Community is left without its regular Friday Joke. Obviously this situation can't be allowed - so I humbly proffer this one I heard from an old college friend the other day:

A Jelly Baby walks into a bar and starts talking to a Smartie. After a few beers the Smartie says
"Ere, a bunch of us are heading to that new club, fancy tagging along?"

The Jelly Baby says
"No mate, I'm a softie, I always end up getting my head kicked in."

So Smartie says,
"Don't worry about it, I'm a bit of hard case I'll look after you."

Jelly Baby thinks about it for a minute and says
"Fair enough, as long as you'll look after me",

and off they go.

After a few more beers in the club, three Lockets walk in. As soon as he sees them, Smartie hides under the table.

The Lockets take one look at Jelly Baby and start kicking him, breaking bottles over his little jelly head, lamping him with little sugary chairs, and generally having a laugh.

After a while they get bored and walk out.

Jelly Baby pulls his battered Jelly Baby body over to the table and
wipes up his Jelly Baby blood and turns to Smartie and says
"I thought you were going to look after me."
"I was!"
says Smartie,
"But those Lockets are f*ing menthol"

I'll get me coat....