Node.js Presentations

I gave two Node.js-related talks within the past week.

The first one was titled “From Java To Node.js”, at Shine Technologies‘ developers meeting on August 5th, 2011.

The second one was titled “JavaScript Everywhere From Nose To Tail”, at Melbourne JavaScript usergroup on August 10th, 2011, with Carl Husselbee from Sensis.

Happy with the positive feedback from the audience of both talks, thanks folks, much appreciated!

Update (08/09/2011):

And here’s the video from the second talk…

JavaScript Everywhere – From Nose To Tail from Benjamin Pearson on Vimeo.

JSGames Plugin – Play Mario Kart & Tetris On Hudson

Now you can play games on Hudson using JSGames Plugin, albeit only a cutdown version of Mario Kart and Tetris (credit goes to Jacob Seidelin of Nihilogic Games). This plugin is extensible enough, so it’s pretty easy to add new games. The winners of 10K Apart would be good additions given the right license.

I wrote this plugin as an experiment on using Hudson for non-continuous integration purposes, in this case, a very minimalistic ‘games delivery platform’. Games as plugins, each with a pluggable Hudson UI that automatically adds a game menu / navigation. To push this further, the dashboard can then be modified to look more like Steam or iTunes, but of course I didn’t do this part.

Hudson is quite flexible, eh?

SCode Image Reload

Sometimes the numbers on SCodePlugin-generated CAPTCHA image are not easy to read. And rather than refreshing the whole page, it would be nice to reload only the image and generate a new / more readable code.

In order to give this a go, I modified the comment form on Melbourne photoblog and added a short Javascript code to refresh the image source. You can try it yourself on this form, just click the text “Generate another code” and wait shortly for the image to be reloaded with a new code.

I have updated the Usage sample code on SCode Plugin wiki page with this improvement.

As a side note, I found a problem where modifying img.src value via anchor tag’s onclick attribute does not work on IE 6 and the image will just disappear, while it works just fine on Firefox 2 and Opera 8.5 .

function reloadSCode() {
  var scodeImage = document.getElementById("scodeImage");
  scodeImage.src="$BLOJSOM_BLOG.getBlogBaseURL()/captcha?flavor=kink&t=" + (new Date()).getMilliseconds();
<a href="javascript: void(0);" onclick="reloadSCode();">Generate another code</a>.

After some mucking around, I found out that the function call must be made from the href attribute. This works on the browsers mentioned above.

<a href="javascript: reloadSCode();">Generate another code</a>.

Them browsers better implement proper Javascript standard before doomsday comes.

Trailing Comma Within JSON’s Array

I was debugging an AJAXy app which uses JSON as the data format, and it was fine with Firefox but not with Internet Explorer. After further debugging, the culprit turned out to be trailing commas within the data.

{"foo": {
    "bar": [
        {"id": "1", "url": ""},
        {"id": "2", "url": ""},
] }} returns 2 in Firefox, but it returns 3 in Internet Explorer. The solution was obviously to remove the last comma.

I’m guessing the problem is more to Javascript array.length which is handled differently between browsers.

Update: HTML comments embedded within what’s supposed to be JSON’s data will be ignored by Firefox, while they will cause failure during eval in Internet Explorer.