Bloggitation

Enlightment via blog-kata

Archive for February 2009

links for 2009-02-27

leave a comment »

Written by zhesto

28-Feb-2009 at 16:04 UTC

Posted in Links

links for 2009-02-26

leave a comment »

Written by zhesto

27-Feb-2009 at 16:02 UTC

Posted in Links

links for 2009-02-25

leave a comment »

Written by zhesto

26-Feb-2009 at 16:02 UTC

Posted in Links

links for 2009-02-23

leave a comment »

Written by zhesto

24-Feb-2009 at 16:02 UTC

Posted in Links

links for 2009-02-22

leave a comment »

Written by zhesto

23-Feb-2009 at 16:01 UTC

Posted in Links

WebHooks on AppJet

leave a comment »

Hi everybody,
I created a small lib-webhook library and a small companion hooks application for easy working with webhooks on AppJet. Like maybe you know, webhooks are one of the current hot topics. They are a very easy way to implement a real-time communications between remote applications.

What you can use it for:

  1. Notify your AppJet based application about changes (commits etc.) in your GitHub repository – have for example ChangeLog + user notifications to some ML:

    Just go to GitHub Admin|Hooks page and if the already defined hooks are not enough put http://youhooks.appjet.net/github/SomeSecret/ there.

  2. Post to your AppJet based application by Jabber (XMPP) or from an iPhone:

    go to https://ping.fm/custom/ and enter http://youhooks.appjet/pingfm/SomeSecret/ . ping.fm have a XMPP bot and an iPhone application which you can use.

  3. Post to your AppJet application by email:

    http://www.smtp2web.com/ , define some email address and point the URL to http://youhooks.appjet.net/something/SomeSecret/. In fact I’m first pointing it to one small application on GAE itself, because parsing multipart/rfc-822 coded message parameter will be difficult on AppJet. So I’m parsing it with message.get_payload() and repacking it in JSON payload. After this it can be send to AppJet.

  4. Posting to XMPP from AppJet – it still missing on AppJet, so I have a small Heroku-hosted Sinatra application to implement this feature. So http://youhooks.appjet.net/xmpp/SomeSecret/ will in turn call that Sinatra application. If you do not trust me with your XMPP information, just create your own application somewhere, where XMPP is possible and call it with a webhooks API (your_url, JSON(payload),JSON(data)).

How to use lib-webhook and hooks application:

  1. Clone the hooks application to (for example) http://youhooks.appjet.net/
  2. Set your secret token – it will be added to the end of the URLs:
      // from the shell
      import ("storage", "lib-webhook");
      storage.token = "SomeSecret";
    
  3. Define users for the hooks, that needed them. I need for example user/password for the XMPP hook and user/key for the http://bit.ly/ URL shortening service. In this way they will be not visible in your application sources.
    // from the shell
    HOOK.addUser("xmpp", {user:"...", password:"..."});
    

    In the moment my hooks application just inserting the user’s data with the same name as the hook, if such user exists:

    data = HOOK.addUserData(data, hook);
    

The library itself provide two main functions:

// universal caller - remote or local hooks:
string callH(url, JSON(payload), JSON(data));
// call local hooks by name
string callLocalH(name, payload, data);

The rest are just some small helpers for user’s data management.

I’ll be very happy to see clones of hooks application with some interesting webhooks (http://pbwiki.com/ for example also supporting webhooks. and by the way PayPal also wink ). And about lib-webhook – will add twitter, identi.ca and maybe some others local hooks ASAP.

Let’s the source be with you.

Written by zhesto

23-Feb-2009 at 12:03 UTC

links for 2009-02-19

leave a comment »

Written by zhesto

20-Feb-2009 at 16:02 UTC

Posted in Links

URL Validation in Rails

leave a comment »

URL validation in Rails. The secret is a little-known method of the URI class, regexp. It lets you generate a regular expression for matching URLs based on an array of accepted protocols. What’s even better, it can be plugged directly into Rails’s validates_format_of. It’s this easy:

class User
    validates_format_of :website, :with => URI::regexp(%w(http https))
end

This will match anything that URI.parse will recognize, meaning that it’s a pretty accurate and powerful URL matcher.

via Intridea – Company Blog.

Written by zhesto

20-Feb-2009 at 12:23 UTC

Posted in Microblog, Texts

Tagged with ,

links for 2009-02-18

leave a comment »

Written by zhesto

19-Feb-2009 at 16:02 UTC

Posted in Links

links for 2009-02-17

leave a comment »

Written by zhesto

18-Feb-2009 at 16:02 UTC

Posted in Links

Follow

Get every new post delivered to your Inbox.