What's wrong with the British and US forces?

After watching this sickening video of a team of British soldiers dragging begging Iraqi kids into a backyard to kick the shit out of them while their commander-in-chief is watching, laughing and encouraging them – I just have to ask; what’s wrong with the British and US forces?

I mean, we don’t see Danish forces behaving this way. We don’t see the Polish behaving this way. They are there, but they’re not performing despicable and stupid acts that will encourage a new generation of suicide bombers. Whay do they think – that these kids just go home and forget about the incident?

Also, it seems like they’re proud of the act – they film it, so they can show it to others. I mean, I know that the Brits and the Americans mostly get their soldies from the lower class of society, many of them criminals – but how stupid can you get?

Let’s hope that Mr. Blair is able to find these people, and punish them. All of them.

How to get the AJAX In Place Editor to use ISO-8859-1

When implementing script.aculo.us’ AJAX In Place Editor for a project I’m currently working on, I ran into some character encoding problems. My PHP framework uses ISO-8859-1, while the ajax script was submitting UTF-8 to my server. Reading the wiki documentation, I discovered that this was a ‘known feature’:

The form data is sent encoded in UTF-8 regardless of the page encoding.

I was recommended to use iconv to convert back to ISO-8859-1 on the server. Unfortunately this was not an option for me, as it wasn’t available on the production server. Of course, there is PHP’s utf8_decode(), but anyone who has used it will tell you it is totally unreliable.

So, here’s how to get it to use the encoding of your page (e.g. ISO-8859-1) instead of UTF-8. This is based on the info I found in this bug report.

  • Open prototype.js and replace all calls to encodeURIComponent() with escape(). There should be three instances.
  • On the server side, make sure you send all output wrapped with htmlentities(), or else you may experience that the editor ‘hangs’ when updating.

That’s it!

Debugging JavaScript with MS Visual Studio

There’s an ancient fable that tells of a frog that falls into a pail of milk. Unable to scramble out, the creature trashes around, seemingly drowning. Eventually however, his frantic struggles turn the milk into butter – and he hops away.

Until now, that fable has been a good metaphor of my struggle with the seven headed beast called JavaScript. I’ve written my lines of code, gotten inane script errors from IE, tried, failed and tried again. Also known, and forever hated, as trial and error programming.

Of course, jolly, happy and cheerful memories from BW2 (before Web 2.0) – when I coded Java all day and all night, with the best tools of the trade – didn’t help much either.

So, I felt like the frog. But that was until I discovered that I could debug javascript with Visual Studio. Yes, that’s right – actual debugging in javascript.

I’m not saying this is news, I’m just saying it’s news to me (and probably to a couple of others as well – those weird looking geeks in the corner, there. See them?). And, yes, I am aware of Venkman.

If you’re not a .net developer, it isn’t in-your-face obvious how you do this, so often you rely on someone just showing it to you. I’ve done some screenshots for you guys and gals.

How to do it!

Just visit the webpage you want to debug with IE. Then fire up Visual Studio, and select Tools -> Attach to Process…

Attach to process Then you find the iexplore.exe instance you want. Click “Attach”.

Attach to process And voilá! You’re in a full-featured debugger; a script explorer, code-view where you can set breakpoints etc. and a panel where you can add watches and view values of locals.

Click for larger version This is brilliant. Now this JavaScript programming should feel less like thrashing in a pail of milk, and more like enjoying a cup of hot chocolate.