Skip navigation

Now that I’ve told you how cool AppJet is for hook scripts, allow me to obsolete it. This morning (as I try to avoid falling asleep as I type) I’m announcing Scriptlets, a tool for throwing online quick web scripts in any of several languages. It’s perfect for writing hook scripts. In fact, it’s what I’ve been dreaming of for web hooks for several years.

When I started thinking about web hooks I figured, as the early adopters, most advanced users would have access to some kind of cheap PHP web hosting for hook scripts. Only later did these cloud code runners appear like App Engine and AppJet. AppJet in particular is the closest to my ideal, as I mentioned before. But it was limited to a particular language and still felt slightly too heavyweight for simple hook scripts (by the name alone it was obviously intended for apps, not scripts).

The ideal I envisioned was a site like a paste bin (I’m keen on Pastie). You know, where you paste some code, pick a language, and you’d get a nicely syntax highlighted, numbered row display of the code with a simple, disposable URL you could use to show the kids in IRC your code that wasn’t working. I wanted that, but that also gave you a URL to run the code. This way I could use it for one-off web scripts that accepted request parameters and everything. No more random one-off PHP scripts on my server. And of course, it would be perfect for hook scripts.

Actually, when I started talking with friends about this, none of this cool cloud computing stuff was big yet. App Engine and AppJet weren’t even around. The closest thing was Ning, which used to host PHP code for you for free. One of my friends (actually, the one that coined “scriptlets”) was interning at Google and knew, but couldn’t tell me that App Engine was coming. Once it came out, he and I started a project like Scriptlets for just Python… but we ran into a wall when I misread the Python documentation and thought App Engine wasn’t letting us eval anything more than one line long. It turns out this was completely wrong, but we’re both pretty busy and we moved on to other things.

But when Google announced Java support on App Engine, even though I hate Java, I knew that the JVM meant they now supported a bunch of languages. I revisited our code, solved the stupid problem, and got several other languages working. And tonight I launched it… with support for 3 languages: JavaScript (uh oh, AppJet!), Python (uh oh, App Engine!), and PHP (uh oh.. uhh… commodity PHP hosting?). Ruby is on its way, and potentially others.

All Scriptlets languages provide an environment with access to the web request and response, and most of the features of that language. All the constraints of the App Engine environment are inherited, meaning no long running processes, no abitrary file system access and no socket connections. (I’m so glad I didn’t have to solve the sandboxing problem by myself!) But you do get to make web requests, and this is exposed with a custom function in JavaScript and PHP called fetch(). It’s a pretty limited environment and not even intended for state maintaining scripts (yet), but it should still prove useful.

Anyway, think of Scriptlets as another community service for the web hooks ecosystem. I have a bunch of these in mind that I’ll be building out. Like PostBin, Scriptlets is open source on GitHub and waiting for you to submit patches. Enjoy!

12 Comments

  1. Cool. I dont have to deploy script to show it to friends..

  2. This is awesome!
    I watched your video on web hooks. (the programmable world.)
    It was really cool.

    The scriptlets idea is great.

    It would be cool for future versions to allow users to modify their code. And see all the scriptlets they have made.

  3. If you prefer python, also check out http://utilitymill.com/

    You may find what you need is already written.

    Very nice to have js and php options with Scriptlets.

    Can’t count the number of times I’ve needed to pipe some date through a few lines of code. This kind of service is invaluable for the mashup ‘stack’.

  4. It’s not obvious from the site, but you can also run scriptlets on the engines just using HTTP to push them up. Good for debugging while hacking it out.

    stub function:
    http://pastie.org/582611

    Usage:
    t(“””
    import datetime
    print ‘hello %s’ % datetime.datetime.now()
    “””)

  5. so is their a scriptlet that will take the raw output from a pastie snippet and then execute it?
    eg scriptlets.org/foo?pastieURI=http://pastie.org/NNNN.txt
    that will then execute code in http://pastie.org/NNNN.txt ?

  6. Is there any limit on how many times can I call a scriptlet (like once a minute)? or how many scriptlets can I have and use? Great work, cheers

  7. been trying to use scriptlets the past couple of days, but have been getting lots of flakey behavior. specifically, i get the error message below quite often, even with the simplest of scripts. a few minutes later, it will be working again.

    script: http://www.scriptlets.org/run/lbdy90

    Traceback (most recent call last):
    File “/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py”, line 507, in __call__
    handler.get(*groups)
    File “/base/data/home/apps/scriptletsapp/1.333090254562219405/handlers.py”, line 48, in get
    self._run_script()
    File “/base/data/home/apps/scriptletsapp/1.333090254562219405/handlers.py”, line 67, in _run_script
    headers=headers).content)
    File “/base/python_lib/versions/1/google/appengine/api/urlfetch.py”, line 241, in fetch
    return rpc.get_result()
    File “/base/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py”, line 501, in get_result
    return self.__get_result_hook(self)
    File “/base/python_lib/versions/1/google/appengine/api/urlfetch.py”, line 331, in _get_fetch_result
    raise DownloadError(str(err))
    DownloadError: ApplicationError: 5

    • This is actually a known issue that it’s had for a while. Fortunately, I’ll be able to throw more cycles at this starting next month.

    • Okay, it should be better now. It might still happen, but it should happen much less often. Google adjusted the timeout limit and I had to explicitly set it to the max.


One Trackback/Pingback

  1. […] essential components for enabling and simplifying idempotent webhook processing. Jeff’s scriplets.org and Hookah are a great start. A worthwhile extension might be a webhook-based pubsub messaging […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: