Check out my
new book!
HTML5 Games book
AppJet + Random.org = True JSON randomness Oi, I've been busy for the past week, mostly with doing nothing at all and just enjoying the tail end of the summer. Got some good ideas I need to put some work in now but for now here's another small app I made while messing around with AppJet a few weeks ago.

It's a simple JS gateway to the true random number generator at Random.org (created by Mads Haahr). It accesses the Random.org API, retrieves a number of random integers (maximum of 100 numbers), turns the response into JSON data and calls a callback function specified by you.

Example usage:


<script>
function randomcallback(res) {
alert( "A random number between 1 and 100: " + res.numbers[0] );
}
</script>

<script src="http://json-random.appjet.net/?num=1&min=1&max=100&callback=randomcallback" />


I'm not sure if I'll ever have a use case where a pseudo-random Math.random() call won't do, but usefulness is not really my game anyway..

Check out the application and source here: http://json-random.appjet.net/
Read more...
AppJet, Server-side JavaScript and YouTube Annotations Whenever I've needed something small done on the server-side, I've always ended up with PHP since I know it, there's no setup and it can do a whole bunch of stuff. I just don't enjoy writing PHP in any way and I just wish I could do stuff on the server with JavaScript as easily as with PHP. Last time I went looking (long time ago) there wasn't really any options that looked good enough but it seems that things have changed a bit. There are more than a few server-side JS solutions available today, but two of them struck me as interesting even if they were not exactly what I was looking for. One of them was AppJet which launched its service late last year. What it does is let you write your server-side JavaScript application in a simple online IDE and then host it at http://<appname>.appjet.com/ all with just a few clicks.

I wouldn't attempt to put the next Facebook or Twitter on AppJet, but for the purpose of writing small and simple applications on the server in JavaScript, I think it's just awesome. The small app I wrote (click the "source" link at the bottom to view the source) to test it out is a proxy of sorts for the YouTube annotation script I posted a few months ago, and it was quite a pleasant experience due to the very short path from idea to actually seeing something happen. AppJet has of course all the needed JavaScript functionality and also provides a few extra features like persistent storage and HTTP access. Nothing really impressive, but there's also a directory of user written JS libraries that you can import to add more functionality. Anyway, this YouTube annotation application simply retrieves the XML from Google's server, converts it to JSON data and either spits it out raw or calls a specified callback function. I've modified the proof-of-concept YouTube annotation player to use this instead of the PHP proxy it was using earlier, simplifying the client-side JS a lot.

The other SSJS solution I've been looking at is Aptana Jaxer which is something entirely different. I have only just gotten it up and running, but I hope to get time to take a deeper look at it when I return from a bit of vacationing in Paris next week. If you have any experience with any of the server-side JavaScript options, please leave a comment and share your thoughts!
Read more...