Fuzzy date and normalize

You can now get fuzzy date times such as 2 hours or 10 minutes (from Trac) in JSONP by hitting clearwind-labs. For example: http://clearwind-labs.appspot.com/fuzzydate?start=2008-10-06%2012:32:52.

Normalize is the Plone code for normalizing id's available as JSONP too: http://clearwind-labs.appspot.com/normalize?text=Österreich%20has%20GREAT%20beer

These are over at http://clearwind-labs.appspot.com/.

I could keep going on this theme for ages, must stop and get some useful stuff done instead.

Detecting browser strings

One thing that I needed to do in Arecibo was detect user agent strings. I finally found a library to do that. This weekend I spent a few minutes wrapping it and adding it in to my clearwind-labs site, running on Google App Engine. Given a user agent string it returns a JSON or JSONP data structure containing hopefully useful information.

Example: http://clearwind-labs.appspot.com/useragent.

Speeding up JavaScript

Ajaxian Dion Almaer announces that Google will make available JavaScript libraries straight from Google.

Whenever I wrote an application that uses one of these frameworks, I would picture a user accessing my application, having 33 copies of prototype.js, and yet downloading yet another one from my site. It would make me squirm. What a waste!

Well done.

Accessible Google Charts

Good job here caring about accessiblity. A Google Chart is an image grabbed from the Google cloud, not very accessible if you can't see the chart. This converts the table into a URL the chart API likes. This is probably much easier for developers as well who can instantly get their head around a HTML table.

via Ajaxian

Ajax services again

I am doing some work in PHP at the moment, not a huge amount, connecting things up. I got back to how much I like doing simple things at the Ajax level. One example is I needed to normalise a string, from unicode to plain text, much like Plone currently does. For example turning:

Pòdi manjar de veire, me nafrariá pas

Into:

podi-manjar-de-veire-me-nafraria-pas

An English ASCII approximation. My first thought was "hey, that's what Plone does". So I grabbed my highly unsophisticated mod_python services framework and wrapped the Plone API from PloneTool.py (which means yes its under GPL) and threw together a quick file (about 20 lines) so that the above comes back as:

<?xml version="1.0" ?>
<response>
<info author="Andy McKay, ClearWind Consulting" 
     end="Tue Jul 31 14:28:53 2007"
     length="0.00110411643982" 
     start="Tue Jul 31 14:28:53 2007" version="1.0"/>
<result>podi-manjar-de-veire-me-nafraria-pas</result>
</response>

Weee, it's a simple manner of now writing Ajax to pull that out and bingo I can do that in Rails, Plone, mod_python and PHP. Assuming the server stays up. The pattern of doing lots of little bits at the browser level is something I really like, having the discipline of using lots of languages forces a different solution. Web services at last.

Service available at: http://www.clearwind.ca/software/normalize/

Relying on Ajax services

Broken There's been lots of chatter on Slashdot and digg about Ajax services. Mostly thanks to the questionable linking to COWS which has ganered press for some reason. One of the main responses went along the lines of "I wouldn't trust some external web site for that part of my site, what if it goes out etc...". That's a fair question, but it's focused on the wrong line of thinking... Yes, running your multi-million dollar website with a dependency on my ClearWind service is a mistake. I have no resources to monitor or maintain it and I might change it on a whim to start charging you for all your traffic. However I would say that services from Google, Yahoo, Flickr, Apple, eBay will all likely put more resources into keeping their site up and running than any site I will be rolling out over the next few years. So, pick a trusted server for your service. Bear in mind the Plone AjaxProxy does caching, another advantage of running through a local proxy. If the destination server goes out temporarily the cache might be catching that. The main use case for Ajax services harks back to a scenario I had at Enfold. In a scenario when you have 20 Plone sites with your software installed and you want to roll out a new service to them - you have a choice, install new software on every client or run a service and have all the servers consume it. Yes, the latter does involve installing software on each installed, but it's an easier install. Take the scenario for image manipulation, you normally have a library that can do a series of manipulations on an image. This then means installing PIL, ImageMagick or so on a server. It's also something that occurs rarely, you do a few manipulations and save it. With an Ajax service, you install the client part of the image manipulation, the Ajax onto the Plone site. You install the libraries on the server. That's a much easier install. You can then test and maintain the Image manipulation service on the server. The advantages are the usual one's you'll get from a service oriented architectures: - each service has a clear API and division from the rest of the software - each service is easily testable - each service is easily supportable and maintainable - each service is cross application - software is easier to install on the client The dependence is on your software and services, not on other people.

Flickr is an Ajax Service

As far as I can tell, Flickr is ready to roll as an Ajax service. It accepts requests using REST and then can respond in XML, using SOAP or XML-RPC. Once transformations are ready to roll on the server, we'll be able to insert the Flickr API key in the AjaxProxy as well. Go for it someone!

Ajax services... a spreading idea

This just got onto Slashdot, COWS Ajax. Spookily enough this is exactly what I was blogging about last week or so. Sometimes things hit all at once. A quick peek at COWS and it has:

  • A server side library written in PHP. I don't know much PHP so I can't comment on that.
  • A client side library written in JS that connects to the back end.
  • An example client side spell checker
To quote the site:
The trick is that the URL of the script is not pointing to a javascript file, but instead pointing to something like a PHP or other backend.
Looks like an implementation of Ajax Services to me. I would really like to see more implementations of AjaxProxy, so something in PHP would be really nice if anyone knows more than me it would be great to see.