Tornado-like async (web) server framework?

2012-04-15 Thread Stefan Arentz
There is a lovely little web server for Python called Tornado. Tornado is an async server that also includes an async http client that plugs right in the server's event loop. This makes it really simple to build scalable web services that call other web services, which is what I mostly use it fo

Re: Using Compojure's defroutes in a macro

2009-11-08 Thread Stefan Arentz
On 2009-11-08, at 3:40 PM, Richard Newman wrote: > > Try > > (defmacro mydefroutes [] > `(defroutes my-routes > (GET "/api" > (my-code ~'request Brilliant! I learn something new every day :-) S. --~--~-~--~~~---~--~~ You received this message

Using Compojure's defroutes in a macro

2009-11-08 Thread Stefan Arentz
I have this Compojure code that works fine: (defroutes my-routes (GET "/api" (my-code request))) I want this code to be generated by a macro. My real code is more complex but the error is the same. (defmacro mydefroutes [] `(defroutes my-routes (GET "/api" (my-code req

Re: Functions and vars and meta-data

2009-11-08 Thread Stefan Arentz
Hi Alex, Wow! Thank you so much for this excellent explanation! It totally makes sense now :-) S. On 2009-11-07, at 9:46 PM, Alex Osborne wrote: > > Stefan Arentz wrote: > >> I must admin that I don't fully understand the difference between foo >> and #

Re: Functions and vars and meta-data

2009-11-07 Thread Stefan Arentz
On 2009-11-07, at 8:28 PM, John Harrop wrote: > On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz > wrote: > But I'm using this in a bigger macro that takes a bunch of functions > as a parameter. Is there a way to make this work or should I > 'translate' the func

Functions and vars and meta-data

2009-11-07 Thread Stefan Arentz
Another one related to my previous question about meta-data. user> (defn #^{ :xxx 1} foo [] "foo") #'user/foo user> (defn #^{ :xxx 2} bar [] "bar") #'user/bar I need to do something similar to this: user> (map #(:xxx (meta %)) [foo bar]) (nil nil) Basically accessing the meta data of a functio

Adding meta data to a function (from a macro)

2009-11-07 Thread Stefan Arentz
I'm trying to do this: (defmacro my-defn [name & body] `(defn- #^{ :foo-tag "blah" } ~name [] ~...@body)) The idea is that foo will be defined and that {:foo-tag "blah"} is added to its meta-data. But that does not seem to work: user> (my-defn foo (println "Hello")) #'user/foo use

Re: [ANN] clj-iter, an iteration macro for Clojure inspired by Common Lisp's Iterate

2009-11-05 Thread Stefan Arentz
On 2009-11-05, at 7:03 PM, Daniel Janus wrote: > > Dear all, > > I am happy to announce the public availability of clj-iter, an > Iterate- > like iteration macro. It is free (available under the terms of MIT > license) and can be found on GitHub: http://github.com/nathell/clj- > iter > > The

Syntax highlighting clojure code

2009-11-02 Thread Stefan Arentz
I want to post some Clojure code to my blog. Does anyone know of a simple, preferably online, code highlighter for Clojure or Lisp that turns code into simple html with either a stylesheet or just tags? S. --~--~-~--~~~---~--~~ You received this message be

Memoize improvement

2009-10-30 Thread Stefan Arentz
This is some of my first Clojure code so it might not be the greatest ... yet! Here is an improved memoize function that also takes a time-to-live argument. Useful when you want to expire results from the cache. I'm using it to cache query results from a database. This probably breaks som

Periodic tasks

2009-10-30 Thread Stefan Arentz
What is a good and simple way to run periodic tasks in Clojure? I need to run a simple function every couple of minutes. And make sure that if it throws an exception that it won't kill the periodic task. I come from a Spring world where XML, Timers, Jobs and Quartz rule the world, so am hop