javascript in the shell

Different languages are good for different things. But unix shell style trumps all. An example: bin/urlencode #!/usr/bin/js   function urlEncode(str){ str=escape(str); str=str.replace(new RegExp(’\+’,‘g’),’%2B’); return str.replace(new RegExp(’%20’,‘g’),’‘); }     if(arguments && arguments.length > 0) { for(var i = 0; i < arguments.length; i+) { r = urlEncode(arguments[i]); print(r); } } else { importPackage(; importPackage(java.lang); S […]

a new browser spying technique

Today’s Blog sensation. One of those things I’d never have thought of, but is easy to understand how it works once you’ve seen it. Scary. I’ve been trying to think if there’s a way for a user to defend against this.

canvas table overlay

One of the (many) problems with Javascript Canvas is that it doesn’t have a way of rendering text. Some people have tried to work around this using absolute positioned DIVs, but since I want to display tabular data for an app I am working on, I have been trying it by overlaying a table instead. […]

canvas gotcha

I was learning to use Javascript Canvas recently, but was almost stumped by a little issue with sizing the thing. In Firefox 2 at least it looks like the canvas size needs to be set on the canvas tag. When I applied a width and height with CSS, it just resulted in the whole canvas […]

some javascript hacking

My Currency Graph page now features javascript rendering of the graph, largely thanks to the excellent flot library. (I’m using the SVN version to get time scale handling). In theory the page will degrade gracefully to use server-side images if the browser doesn’t support <canvas>, but I don’t have a browser which does javascript without […]

javascript property dump

I’ve found it quite useful sometimes to do a dump of properties of a javascript object. Here’s an example for an event: var alerttext = ""; for(p in myEvent) { if(p.toUpperCase() != p && (typeof(myEvent[p]) ‘string’ || typeof(myEvent[p]) ‘number’)) { alerttext += p + " = " + myEvent[p] + "\n"; } } […]


On Saturday I went along to JQueryCamp, since it was in Boston. It was the first conference specifically about this JavaScript library. I don’t do very much Javascript work, but I pick up what there is in my company because I find it interesting, and I have started using JQuery because it makes it so […]

jquery and java .properties files

I recently had a need to parse a Java .properties format file in Javascript, and couldn’t find a suitable library for it, so I hacked out this (actually I copied the regular expressions from a Perl implementation): /** * parse a string containing text in Java .properties file format, and convert it into a map […]

currency graphing

Over the weekend I did some long-awaited work on my exchange rate graph application. The most obvious change is that you can now choose a range of dates rather than always getting all the data. I decided to have just a fixed set of ranges to choose from, since it does what most people should […]

RailsConf – Unobtrusive Javascript

An extra session was added during Friday lunchtime, since Dan Webb’s Unobtrusive AJAX talk had been so popular on Thursday that not everyone who wanted to see it could get in. Dan started off with some history of Javascript and how it got its bad name – but we think it is much better now. […]