Executing your javascript in the cloud, yes! YQL rules!

noviembre 18th, 2010 § 3 comments

First of all, I'm  not going to start talking about nodejs, that's another post I have pending. This time I'm talking again about YQL, yes, that awesome tool that will save you a lot of time.

Most of you should be familiar with it, do you remember 'select * from internet' ? You could pick data from different sources, mashup it, mix, filter, etc. But also create new content sources, this makes you the ability to turn ANY (yes in capital case) digital resource (an api, html, csv, what ever!!) into a YQL content source.

But, today I want to talk about another super cool feature YQL has, is the ability of executing javascript in the tables that you create. This is perfectly documented in YDN , it's call the 'execute' block, it let's you transform the data, doing really granular parsing and filtering, basically, transforming the data in any way your mind can image.

So, with this tools in my hands, a dirty idea started to grew in my head: ... can I use YQL to execute javascript in a fancy way?

And after some lines of table definition, 5 minutes :P , a new table was born, the 'execute' table, it's included in the community open tables, so once you are in the console, click on 'Show Community Tables' and you will be ready to use it.

How can you execute your javascript code using this table? Easy, if you use the query builder, you could see the following fields available for the table:

  • code: With this parameter you directly write inline the code to be executed.
  • file: You specify a url or a YQL internal storage key where your code resides.

You can use both parameters as well, first will be executed the code in the 'file' parameter and after that the 'code' one.

How queries look like:

CODE:
  1.  
  2. select * from execute where code="response.object=<hello><world/></hello>;"
  3.  
  4. select * from execute where file="http://myserver/myfile.js"
  5.  

And now why use this?

  • I want to replace html5 Web Workers, no way, I'm joking, but is another option to relay the execution of the javascript not in the client, maybe could be useful for really old phones.
  • YQL prototyping. This is really helpful for people that use extremely YQL, and deal with the infamous and loved 'execute' block. Will reduce considerably your development time. In conjunction with Sam's Pullara yql storage editor, is the definitive tool to work with YQL.

Hope you liked it, happy hacking!!

Tagged , , ,

§ 3 Responses to Executing your javascript in the cloud, yes! YQL rules!"

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos necesarios están marcados *

*

Puedes usar las siguientes etiquetas y atributos HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the answer to the math equation shown in the picture. Click on the picture to hear an audio file of the equation.
Click to hear an audio file of the anti-spam equation

What's this?

You are currently reading Executing your javascript in the cloud, yes! YQL rules! at arde en el infierno.

meta