growing a rest json/xml api

2013-04-24 Thread Jorge Urdaneta
Hi, can you point me out best practices/libraries to make a rest api with ring with json/xml output depending on "Accepts" request header? -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.c

Re: Performance of calling primitive type hinted functions passed as arguments

2013-04-24 Thread Mikera
The second one is slower because the (cb l) call is going via (fn [Object]) which then delegates to (fn [long]) rather than using (fn [Object]) directly. I believe it may be doing an extra cast as well, which would explain the extra 3ns of overhead. In general, I've found primitive functions ar

Re: New CSS library - Garden

2013-04-24 Thread Murtaza Husain
Joel, Thanks for the lib. Its great and I plan to use it in my projects. How does Garden compare to other pre processors such as sass and less ? Also can I use it in my clojurescript projects ? I mean does it have any java lib dependencies that would prevent it? What is the workflow when using

Re: Any help on starting Android with clojure?

2013-04-24 Thread John Gabriele
Erlis, here's a few more links: * * * ---John -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Performance of calling primitive type hinted functions passed as arguments

2013-04-24 Thread Jason Wolfe
^clojure.lang.IFn$LO should work, although my guess is that this is considered an implementation detail and subject to change with new versions of Clojure. On Wednesday, April 24, 2013 10:15:49 AM UTC-7, Alice wrote: > > So, is there a way to type hint on cb that it has a function accepting > a

Ring Xss library

2013-04-24 Thread mike
I'm trying to create a library to help with XSS (escaping input) in ring based projects. I've looked at some solutions so far and I haven't seen anything where you set it and forget it, or don't have to worry about it at all. Most solutions require manually escaping. I want to create somethin

Re: Customize clojure-mode (emacs) question

2013-04-24 Thread Hoàng Minh Thắng
On Wed, 24 Apr 2013 12:03:29 +0200 Tassilo Horn wrote: > You could create an clj-.el. Thank you so much Tassilo. signature.asc Description: PGP signature

Re: Question about code style

2013-04-24 Thread Alex Baranosky
You shouldn't use the second unless you have a multi-arity function definition. On Wed, Apr 24, 2013 at 9:39 AM, Plínio Balduino wrote: > Hi there > > Which one is preferred when adding doc-string in a function? > > This: > > (defn bubbles > "Here I put some description" > [] > (code)) > >

Re: Performance of calling primitive type hinted functions passed as arguments

2013-04-24 Thread Alice
So, is there a way to type hint on cb that it has a function accepting a long argument? On Apr 25, 12:55 am, Stuart Sierra wrote: > I'm taking a guess here: The compiler doesn't know the type signature of > `cb` when compiling `foo`, so it's going to use the IFn.invoke(Object) > signature. Clojur

[tools.logging] Adding Null Logger Impl and Forcing It For Testing

2013-04-24 Thread Alyssa Kwan
Hi, I Midje test functions that log. I want to disable logging during testing. What's the easiest way to do that? I saw a message by Sean Corfield from a year and a half ago about altering the *logger-factory* root to ensure a particular logger implementation is chosen project wide. Obvious

ANN Money 1.3 is released

2013-04-24 Thread Michael Klishin
ClojureWerkz Money [1] is a Clojure library that deals with monetary amounts. Release notes for 1.3: http://blog.clojurewerkz.org/blog/2013/04/24/money-1-dot-3-0-is-released/ 1. https://github.com/clojurewerkz/money -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -

Question about code style

2013-04-24 Thread Plínio Balduino
Hi there Which one is preferred when adding doc-string in a function? This: (defn bubbles "Here I put some description" [] (code)) Or this: (defn bubbles "Here I put some description" ([] (code))) Thank you in advance Plínio -- -- You received this message because you are su

Re: Any help on starting Android with clojure?

2013-04-24 Thread Erlis Vidal
Hi Bill, Thanks for the link! On Wed, Apr 24, 2013 at 8:05 AM, Bill Liao wrote: > Hi, >Take a look at http://alexander-yakushev.github.com/lein-droid/. > > regards > > wliao > > > > > On Tue, Apr 23, 2013 at 7:55 PM, Erlis Vidal wrote: > >> Hi guys, >> >> I want to start Android developm

Re: Performance of calling primitive type hinted functions passed as arguments

2013-04-24 Thread Alice
I'm writing some low-level byte manipulation library and want it to be as efficient as possible, so I just want to know the cost of trivial things like this before designing the API. It can be negligible as you said, but I wanted to know why it is slow and what's happening under the hood anyway. O

Re: Performance of calling primitive type hinted functions passed as arguments

2013-04-24 Thread Softaddicts
I am not convinced that this test is representative. If you are not using l but still hinting it's type, you may have extra code generated in the function body to handle the type hint. 4 milliseconds divided by a million is a very low overhead IMHO. I would hardly qualify this as being inefficient

Re: Performance of calling primitive type hinted functions passed as arguments

2013-04-24 Thread Stuart Sierra
I'm taking a guess here: The compiler doesn't know the type signature of `cb` when compiling `foo`, so it's going to use the IFn.invoke(Object) signature. Clojure's type inference is only local, and it won't assume that a primitive-type signature is available for an arbitrary function. So there

Re: Performance of calling primitive type hinted functions passed as arguments

2013-04-24 Thread Alice
I tested several times, but the latter is always slower. On Apr 25, 12:38 am, Jim wrote: > On 24/04/13 16:35, Alice wrote: > > > > > > > > > (defn foo [^long l cb] (cb l)) > > > (time > >    (dotimes [n 100] > >      (foo n (fn [l] nil > > > (time > >    (dotimes [n 100] > >      (foo

Re: Performance of calling primitive type hinted functions passed as arguments

2013-04-24 Thread Jim
On 24/04/13 16:35, Alice wrote: (defn foo [^long l cb] (cb l)) (time (dotimes [n 100] (foo n (fn [l] nil (time (dotimes [n 100] (foo n (fn [^long l] nil "Elapsed time: 7.861 msecs" "Elapsed time: 11.770973 msecs" Why is the latter slower? You should be gettin

Performance of calling primitive type hinted functions passed as arguments

2013-04-24 Thread Alice
(defn foo [^long l cb] (cb l)) (time (dotimes [n 100] (foo n (fn [l] nil (time (dotimes [n 100] (foo n (fn [^long l] nil "Elapsed time: 7.861 msecs" "Elapsed time: 11.770973 msecs" Why is the latter slower? -- -- You received this message because you are subscrib

Re: [GSoC 2013] core.logic CLP(Prob)

2013-04-24 Thread David Nolen
This is great, thanks for the thoughts, gist & links! On Wed, Apr 24, 2013 at 5:34 AM, Zack Maril wrote: > Lately, I've been on a bit of a jag into probabilistic programming with > Clojure, specifically embedding Church inside of Clojure. The results so > far are promising from a syntactic leve

Re: Any help on starting Android with clojure?

2013-04-24 Thread Bill Liao
Hi, Take a look at http://alexander-yakushev.github.com/lein-droid/. regards wliao On Tue, Apr 23, 2013 at 7:55 PM, Erlis Vidal wrote: > Hi guys, > > I want to start Android development and I was following the tutorial found > here http://developer.android.com/training/basics/firstapp/i

Re: Multiple replacements in string using a map

2013-04-24 Thread shinmuro
if map is following: {:_ACCT-ID_ 9876 :_ACCT-TYP_ "B"} then: (defn sql-map-replace [sql m] (letfn [(quote-if-str [s] (if (string? s) (str "'" s "'") s))] (reduce-kv (fn [ret k v] (clojure.string/replace ret (re-pattern (str "(.*)" (name k) "(.*)"

Re: How to import classes from a runtime-defined ClassLoader?

2013-04-24 Thread Laurent PETIT
2013/4/24 Jim : > I've also had problems passing classes that reside to memory to apache UIMA > or instantiation. What worked for me is this: > > (def dynamic-classloader (. (Thread/currentThread) getContextClassLoader)) > (Class/forName "mypackage.myclass" true dynamic-classloader) Yes, sometime

Re: How to import classes from a runtime-defined ClassLoader?

2013-04-24 Thread Jim
I've also had problems passing classes that reside to memory to apache UIMA or instantiation. What worked for me is this: (def dynamic-classloader (. (Thread/currentThread) getContextClassLoader)) (Class/forName "mypackage.myclass" true dynamic-classloader) Jim On 24/04/13 13:39, Gary Trak

Re: How to import classes from a runtime-defined ClassLoader?

2013-04-24 Thread Gary Trakhman
There's a lib for this, we've used it in anger, and it seems to work: https://github.com/flatland/classlojure/blob/master/src/classlojure/core.clj On Wed, Apr 24, 2013 at 12:01 AM, tbatchelli wrote: > This worked for me: > > (with-bindings {clojure.lang.Compiler/LOADER dcl} ...) > > (from: > h

Re: Clojure on top of ObjC?

2013-04-24 Thread Steven Degutis
I'm sure it can be done, but lately the auto-completion integration, the Interface Builder integration, and all sorts of other things I can't remember right now, are all so tightly integrated into Xcode that I'm confident I would code at least half as quickly if I was in emacs. -Steven On Wed, Ap

Re: nREPL middleware for external repl.

2013-04-24 Thread Andrew Voron
Thanks for reply, Michael. Take a look at Piggieback by Chas Emerick: > https://github.com/cemerick/piggieback > Yes I saw it, but if I underestand it correctly, this middeware doesn't connect to any external repl, it passes in to inner ClojureScript evaluator, which outputs plain JavaScript w

Re: Customize clojure-mode (emacs) question

2013-04-24 Thread Tassilo Horn
Tassilo Horn writes: > You could create an clj-.el. > > (require 'clojure-mode) > > (define-clojure-indent > (look-like-case 1) > ...) > > ;; more stuff > > (provide 'clojure-) ^^^ Of course, this should have been "clj" instead of "clojure" to match the file name. Bye, Tassi

Re: Customize clojure-mode (emacs) question

2013-04-24 Thread Tassilo Horn
Hoàng Minh Thắng writes: > I have a macro, let's say `look-like-case`. When trying to indent with > Emacs, the result is: > ``` > (look-like-case a > b > c) > ``` > which is not what I want. How can I make Emacs to indent it like this: (define-clojure-indent (l

Re: [GSoC 2013] core.logic CLP(Prob)

2013-04-24 Thread Zack Maril
Lately, I've been on a bit of a jag into probabilistic programming with Clojure, specifically embedding Church inside of Clojure. The results so far are promising from a syntactic level, but, like David said, getting it to actually work is another matter entirely. I wanted to share what I've be

Re: nREPL middleware for external repl.

2013-04-24 Thread Michael Klishin
Andrew Voron: > My question is: can this be achieved via some combination > of nrepl middlware and transport? So nrepl here is just a middleman > between nrepl.el(emacs) and actual repl that executes inside > flashplayer. > > Or a custom socket server for such a goal will be a better choice? > An

nREPL middleware for external repl.

2013-04-24 Thread Andrew Voron
Hello. I need a suggetion about one thing: las3r - is a subset of Clujure language, hosted inside flash runtime. The idea is to use emacs + nrepl (I want to use all it's sweet features) to talk with flash repl. My question is: can this be achieved via some c

Re: Customize clojure-mode (emacs) question

2013-04-24 Thread Stefan Kamphausen
Take a look at the bottom of jason.clj: https://github.com/clojure/data.json/blob/master/src/main/clojure/clojure/data/json.clj -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note th

Re: Clojure on top of ObjC?

2013-04-24 Thread Brian Marick
On Apr 24, 2013, at 12:02 AM, Steven Degutis wrote: > Unfortunately, it's impractical to write the majority of a Mac or iOS app > using anything other than Xcode + ObjC, especially the UI. So the goal of > this endeavor would mainly be to write command line utilities in Clojure or > embed scr