pubsub via webhooks

3 views
Skip to first unread message

John Nunemaker

unread,
Jun 9, 2009, 2:41:36 PM6/9/09
to south...@googlegroups.com
Came across this today:
http://github.com/jcapote/watercoolr/tree/master

Since we chatted so much about web hooks not too long ago thought I
would post it. Looks interesting.

Daniel Parker

unread,
Jun 9, 2009, 3:01:35 PM6/9/09
to south...@googlegroups.com
What do you guys think of adding rubyhooks.com to the mix? I just bought the domain.

The plan is to look a bit like gist.github.com, except that you write a ruby script that gets bound to a specific url. When that url is requested, a certain method name is called in your script with a request object. (Basically you write a single controller action without models or views.) This would be perfect for private urls that need to translate an xml or json object coming from a webhook to send off to another API. But there are many more use cases as well...

The aim is to make the ruby API for using it so simple that non-programmers will end up creating middle-man scripts for themselves too. There are numerous strategies available for future monetization if it becomes at all popular -- anybody want to help create it (& share ownership)?

- daniel parker -

Jonathan Hoyt

unread,
Jun 9, 2009, 3:18:51 PM6/9/09
to south...@googlegroups.com
Can you give me a use case that I can grok?

Jon Hoyt

Daniel Parker

unread,
Jun 9, 2009, 4:29:12 PM6/9/09
to south...@googlegroups.com
Use case A: Github photo album -> picasaweb
1) Create a github repository, where you plan each commit to contain a photo and accompanying meta data.
2) Add a post-commit hook that points to your rubyhooks.com url.
3) Create a rubyhook that receives the post-commit payload, retrieves the commit data, and posts your photo into picasaweb (or other photo site).

In this case rubyhook comes in really handy because you get a simple no-maintenance ruby script that does one simple thing: translates and re-transmits data from one service to another.

Use case B: IM-ified remote control
2) Create a rubyhook that receives the IM messages from imified and acts on those messages. Anything you can do in ruby, considering you're running "in the cloud." Send HTTP requests; perform some SSH commands on your server; send an email.

Think: "Single hook, Simple action."

This use case also loves rubyhooks because you get a simple no-maintenance ruby script to perform a few, defined, simple actions.

Use case C: Image transformer
1) Create a rubyhook that performs certain transformations on images -- using a single url: upload (POST) an image, and the response will be that same image transformed. Use a query string to specify what transformation you need done.

There may be sites out there who do this already, but this shows that you could use rubyhooks to post data and receive a translated version in response. Rubyhooks is helpful because it provides an isolated, no-maintenance blackbox processor for your data. (I'd probably limit requests to 60 seconds of processing time.)

- - - - -

Typically you'll end up using this to write scripts (some could turn out to be commonly-needed scripts) that take a webhook input from one source, and translate it to send off to another source in the appropriate language or medium; or as in case C, to respond with translated data.

- - - - -

Several meetings ago at RedPost, I and Jon Nunemaker talked a bit about the whole idea of webhooks. Part of the discussion that came up was that in order to connect many specific APIs on the web, you'll often need a middle-man to translate data, because there will never be standard formats for everything. Rubyhooks.com wouldn't provide a direct solution to that, but would offer an easy tool to accomplish many of these middleman needs. Besides, we all have ideas for custom technology connectors every so often, right? Here's where you can just go online and code away in a pre-deployed environment.

Ruby means you have a world of possibilities at your fingertips; Hooks means you're connected directly to live data events on the web.

- daniel parker -

"You have granted me life and steadfast love, and your care has preserved my spirit." Job 10:12
"The LORD is my chosen portion and my cup . . . indeed, I have a beautiful inheritance." Psalm 16:5-6
"Give what you can ... take nothing back!"

Daniel Parker

unread,
Jun 9, 2009, 4:41:43 PM6/9/09
to south...@googlegroups.com
... And totally forgot to mention the looming giant: Google Wave.

If you haven't watched the video(s) on Google Wave yet, go do it. It'll blow you away. (Sorry, Jon Hoyt doesn't think so, but you'll change your mind sometime in the next 6 months, Jon.)

Google Wave uses webhooks. If you want to write a robot that participates on a wave (which could be called an email, IM, or document), you create it to respond to specific webhooks. You could write robots for google wave in ruby on rubyhooks.com.

Another note: http://twitter.com/tdo was built completely using webhooks. I believe twitter sends an email to mailhook, which sends a webhook (post) request to a script that runs the whole thing. Tdo is a twitter Direct Message bot that basically performs webhooks for you from twitter Direct Messages. You could build tdo yourself as a little script on rubyhooks.com.

Anybody interested in creating it with me?

- daniel parker -

"You have granted me life and steadfast love, and your care has preserved my spirit." Job 10:12
"The LORD is my chosen portion and my cup . . . indeed, I have a beautiful inheritance." Psalm 16:5-6
"Give what you can ... take nothing back!"


John Nunemaker

unread,
Jun 9, 2009, 6:24:54 PM6/9/09
to south...@googlegroups.com
Conceptually interesting but seems like security would be a big issue. Also not sure that anyone would actually pay for this.

Daniel Parker

unread,
Jun 9, 2009, 7:06:09 PM6/9/09
to south...@googlegroups.com
It would be free except for certain abilities such as SSL, emailing, longer-running processes, more bandwidth, etc (very small fees).

Security - I'm working on that, experimenting with $SAFE, which seems to be created specifically for this type of thing. It seems to restrict too much, actually. This is the trick at the moment:
Thread.new {
  $SAFE = 2
  load("scripts/#{user}/#{script_name}-wrapper.rb", true)
}
Inside the thread is safe-level 2, which restricts a whole lot of things -- just about any potentially unsafe things. It only changes that thread's safe level. 'load' with the extra 'true' argument wraps the user script in its own anonymous module. The net result here is that the user script inherits an environment but can't modify that environment, and it can't put anything into that environment's global namespace. The wrapper sets up any per-script environment, loads the script, then calls a method defined in the script with an argument encapsulating the request.

If anybody knows of security holes in using $SAFE, let me know. :)

- daniel parker -
Reply all
Reply to author
Forward
0 new messages