Re: Literate Programming in org-babel (ob-clojure.el) is broken under nrepl.el

2012-09-12 Thread Denis Labaye
On Tue, Sep 11, 2012 at 10:13 PM, Gary Johnson wrote: > I just put together a simple example repo on GitHub, containing a literate > programming solution to the Potter Kata ( > http://codingdojo.org/cgi-bin/wiki.pl?KataPotter) using Emacs' org-babel > mode. You can check it out here: > > https

Re: Question about sets

2012-09-12 Thread Rich Hickey
On Sep 8, 2012, at 7:38 PM, Andy Fingerhut wrote: > Rich: > > I'm not sure what you mean by the not-fastest-path possible that exists in > today's Clojure code, so if you get a chance, see if the below is what you > mean. > > As far as I can tell (i.e. putting debug println's in the Java code

Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread the80srobot
Hello, So I've been working on a project at work, that required me to code a simple web interface. I considered going with Noir, and while reading the code, I noticed a pattern that seems to repeat throughout most of the code that Chris Granger has published in Clojure. This is what I'm referri

ANN: 25 September London Clojure Dojo at Thoughtworks

2012-09-12 Thread Bruce Durling
Roll up! Roll up! After being hosted by Forward in Camden Town our lovely friends at Thoughtworks are going to host us at the end of the month for our next London Clojure Dojo. It will start at 7PM at Thoughtworks London. Details and sign up are here: http://late-september-2012-ldnclj-dojo.even

Re: Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread Jim foo.bar
defonce simply means "do not bind the var if it already has a root value"... I think it only applies when reloading your namespace...to be honest, I'm not sure why Chris has coded it like that (creating an atom is not really expensive), but i find it hard to believe that you can' t have 2 Noir

Re: Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread the80srobot
Sorry I wasn't more clear - I'm not talking about defonce, but about having refs (atoms) defined at the top level. When they're defined like this, they basically become global variables, don't they? Having two Noir apps would then mean they share the same routes, among other things. Or am I miss

Re: Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread Jim foo.bar
aaa ok I see what you mean...well, yes everything starting with def can be considered a 'global' var or even better a namespaced var (not really a variable in the traditional sense)...In Noir's case most of the atoms are maps so it could be that each Noir app registers its specific routes on a

Re: ClojureDocs and Clojure 1.4

2012-09-12 Thread cej38
I am interested in updating the clojure.contrib section. -- 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 that posts from new members are moderated - please be patient with your first

Re: Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread gaz jones
I find myself having to make similar choices quite often in my own Clojure code - do I create perhaps a map of things that represent some kind of 'state' and pass that around to each function that needs it, or do I do what has been done above and create some vars in a ns where most (all?) the funct

Re: Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread the80srobot
What I usually do when I want to avoid passing these implicit parameters is just use thread-local bindings with ^:dynamic vars. From the point to rebind them using (bindings), every function called from within the binding block sees the same value; you can combine them with atoms/agents/refs for

Re: Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread Jim - FooBar();
On 12/09/12 16:29, the80srobot wrote: What I usually do when I want to avoid passing these implicit parameters is just use thread-local bindings with ^:dynamic vars. From the point to rebind them using (bindings), every function called from within the binding block sees the same value; you can

Re: Question: Looking at Noir code - hey, are those singletons?

2012-09-12 Thread Jim - FooBar();
On 12/09/12 16:23, gaz jones wrote: I find myself having to make similar choices quite often in my own Clojure code - do I create perhaps a map of things that represent some kind of 'state' and pass that around to each function that needs it, or do I do what has been done above and create some va

How do I get the total memory used by the app?

2012-09-12 Thread larry google groups
I need to know how much memory my app is using (it is a long running service). I see that some people have asked about how to measue memory use. Robert McIntyre asked, "get the total memory used by a data structure?" Some of the answers imply that it is easy to get the total memory use of the a

Re: How do I get the total memory used by the app?

2012-09-12 Thread Sean Corfield
Here's some code we use to get memory and CPU usage in a displayable form: (defn- as-megabytes "Given a sequence of byte amounts, return megabyte amounts as string, with an M suffix." [memory] (map #(str (int (/ % 1024 1024)) "M") memory)) (defn- as-percentage "Given a pair of values,

Re: How do I get the total memory used by the app?

2012-09-12 Thread Dave Ray
You can connect jconsole or visualvm to your running app to monitor memory usage, GC, threads, etc, etc. On my machine, jconsole lives in $JAVA_HOME/bin/jconsole. Cheers, Dave On Wed, Sep 12, 2012 at 10:12 AM, larry google groups < lawrencecloj...@gmail.com> wrote: > I need to know how much mem

Re: How do I get the total memory used by the app?

2012-09-12 Thread larry google groups
Thank you much! On Wednesday, September 12, 2012 1:21:20 PM UTC-4, Sean Corfield wrote: > > Here's some code we use to get memory and CPU usage in a displayable form: > > (defn- as-megabytes > "Given a sequence of byte amounts, return megabyte amounts >as string, with an M suffix." > [

Re: How do I get the total memory used by the app?

2012-09-12 Thread Shantanu Kumar
Also look at java.lang.Runtime class methods maxMemory, freeMemory and totalMemory: http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html Shantanu On Sep 12, 10:45 pm, larry google groups wrote: > Thank you much! > > > > > > > > On Wednesday, September 12, 2012 1:21:20 PM UTC-4, Sean

Clojurescript/facebook JS-SDK

2012-09-12 Thread Mimmo Cosenza
Hi everyone, I'm pretty new with cljs and perhaps I'm asking something very stupid. I'd like to know if integrating facebook js-sdk with cljs could be a feaseable approach to be able to write fb app using clojure on both fe and be side. I don't know if fb js-sdk is google-closure compatible with

Re: Help - I am doing something wrong (lein cljsbuild fails)

2012-09-12 Thread Thomas
Found the problem. I needed to update to the latest version of Noir ("1.3.0-beta10") and that solved my problem. Thanks everyone Thomas -- 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 No

Re: Ideas for interactive tasks

2012-09-12 Thread Nikita Beloglazov
Zmitro: I'll definitely use 4clojure in teaching, but I'm looking for more interactive tasks so I can use graphics/sound/charts/something else to visualize them. Murtaza: It's a great idea, but I'm experienced enough to take such task :) Thank you, Nikita On Wed, Sep 12, 2012 at 8:43 AM, Murtaza

Using function that returns unique keys in map literals causes an

2012-09-12 Thread jarppe
I have a function that returns unique ID every time it is called. If I try to create a new map with two entries, both having a unique key generated by that function, I get IllegalArgumentException Duplicate key exception. For example: user=> *(def id (atom 0))* user=> *(defn generate-id [] (swap

Re: ClojureDocs and Clojure 1.4

2012-09-12 Thread Eric MacAdie
I am also interested in helping out with ClojureDocs. - Eric MacAdie On Wed, Sep 12, 2012 at 10:17 AM, cej38 wrote: > I am interested in updating the clojure.contrib section. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this

Map literal with keys generated by function cause "Duplicate key" exception

2012-09-12 Thread jarppe
I have a function that generatwed unique ID's, something like this: (def k (atom 0)) (defn generate-id [] (swap! k inc)) and I try to use it like this: {(generate-id) "foo" (generate-id) "bar"} How ever, I get IllegalArgumentException Duplicate key: (generate-id) clojure.lang.

Sort and Java 1.7

2012-09-12 Thread Canonical.Chris
Clojure's sort just trampolines down to the Java sort implementation. Between 1.6 and 1.7, the Java guys have really cracked down on the interface that people must satisfy with their comparators. LISP is much looser with its sorting requirements. I just wanted to know how people felt about thes

Lazy sequences to replace looping?

2012-09-12 Thread Geo
Hello, I am just getting started with Clojure and I had a question. I have to following code: (get-rss-entry (get-rss-feeds h-res) url) The call to get-rss-feeds returns a lazy sequence of URLs of feeds that I need to examine. The call to get-rss-entry looks for a particular entry (whose :li

Re: Using function that returns unique keys in map literals causes an

2012-09-12 Thread Jim - FooBar();
There is a long discussion about how maps and sets should behave (throw on dups or not) (see ''question about sets on the mailing list)for the moment try using the constructor fn hash-map rather than the map literal...so basically do this: (hash-map (generate-id) "foo" (gene

Re: Lazy sequences to replace looping?

2012-09-12 Thread gaz jones
You may find this useful: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/ loop-recur might be the best way to do it. On Tue, Sep 11, 2012 at 11:16 PM, Geo wrote: > Hello, > > I am just getting started with Clojure and I had a question. I have to > following code: > > (get-r

Re: Sort and Java 1.7

2012-09-12 Thread Alan Malloy
Vote to close as "not a real question". The signature of java.util.Collections/sort hasn't changed since 1.5, when generics were introduced, and it should still be basically compatible with what it was when it was introduced in 1.2. On Wednesday, September 12, 2012 5:54:22 AM UTC-7, Canonical.C

Re: Map literal with keys generated by function cause "Duplicate key" exception

2012-09-12 Thread Matthew O. Smith
On Wednesday, September 12, 2012 8:03:58 AM UTC-6, jarppe wrote: > > I have a function that generatwed unique ID's, something like this: > > (def k (atom 0)) > (defn generate-id [] (swap! k inc)) > > and I try to use it like this: > >{(generate-id) "foo" > (generate-id) "bar"} > > How

Re: Using function that returns unique keys in map literals causes an

2012-09-12 Thread Sean Corfield
On Wed, Sep 12, 2012 at 10:38 AM, jarppe wrote: > user=> {(generate-id) "foo" (generate-id) "bar"} > IllegalArgumentException Duplicate key: (generate-id) > clojure.lang.PersistentArrayMap.createWithCheck (PersistentArrayMap.java:70) This is treated as a literal so the reader sees (generate-id) i

Re: ClojureDocs and Clojure 1.4

2012-09-12 Thread Andy Fingerhut
Your offers of help are certainly welcome, but I think the kinds of changes desired require the help of the ClojureDocs site creators to make. That is, they do, unless you want to take a copy of their code from github and create another site with a different name running the same code, then mod

Is anyone relying on the js* special form?

2012-09-12 Thread Brandon Bloom
I'm exploring some changes to the ClojureScript compiler backend and am curious if anyone is using one particular implementation detail: The js* special form. Note that I'm not asking about the js/ pseudo-namespace, only the js* special form. Are you using it in your ClojureScript projects? If

Re: Is anyone relying on the js* special form?

2012-09-12 Thread Kevin Downey
I've used it to make ClojureScript functions in to javascript object constructors (defn Foo [] (js* "/*") (js* "*/")) results in the generated return being commented out, so (Foo.) works I use this in a macro for creating new types that are based on existing Google Closure types On Wed, Sep 12

Re: Is anyone relying on the js* special form?

2012-09-12 Thread Brandon Bloom
Interesting. Would that use case be covered by an implementation of the proxy macro, et al? Said implementation could produce proper Google Closure javadocs with @extends / @implements, as well as calls to goog.inherit On Wednesday, September 12, 2012 4:56:24 PM UTC-7, red...@gmail.com wrote: >

Re: Sort and Java 1.7

2012-09-12 Thread Armando Blancas
You must be referring to the detection of contract violations. It shouldn't be an issue; on the contrary, that seems useful info. And those who depend on legacy or third-party code can always stick to the old behavior. Area: API: Utilities Synopsis: Updated sort behavior for Arrays and Collectio

Re: How do I get the total memory used by the app?

2012-09-12 Thread larry google groups
Sean, Thank you much for this. I am curious about this: (defn cpu-usage "Return utilization (as a string) and number of CPUs and load average." [] (let [bean (operating-system-bean) data ((juxt cpus load-average) bean)] (cons (cpu-percentage data) data))) I n

Re: How do I get the total memory used by the app?

2012-09-12 Thread larry google groups
Shantanu, Thank you. That is great information. On Wednesday, September 12, 2012 1:50:32 PM UTC-4, Shantanu Kumar wrote: > > Also look at java.lang.Runtime class methods maxMemory, freeMemory and > totalMemory: > > http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html > > Shantanu

Re: How do I get the total memory used by the app?

2012-09-12 Thread Sean Corfield
On Wed, Sep 12, 2012 at 7:12 PM, larry google groups wrote: > I notice that on my server, if at the command line I simply run "top" I see > CPU load averages .5 or .6, but this function gives me numbers around 40. > Could you point me to some information about what the JVM is really > reporting wi

Re: Literate Programming in org-babel (ob-clojure.el) is broken under nrepl.el

2012-09-12 Thread Ben Mabey
Thanks for the great example Gary! I've been meaning to try org-babel out for a while but never got around to it. I just tried your example and when I run org-babel-tangle the code blocks are not expanded into the source file, but rather the code block names are just inserted into the source d

Re: Literate Programming in org-babel (ob-clojure.el) is broken under nrepl.el

2012-09-12 Thread Ben Mabey
On 9/12/12 9:29 PM, Ben Mabey wrote: Thanks for the great example Gary! I've been meaning to try org-babel out for a while but never got around to it. I just tried your example and when I run org-babel-tangle the code blocks are not expanded into the source file, but rather the code block nam

Re: [ANN] rubydoc 0.3.0

2012-09-12 Thread Gabriel Horner
On Monday, September 10, 2012 7:24:15 AM UTC-4, Denis Labaye wrote: > > > > On Mon, Sep 10, 2012 at 4:10 AM, Gabriel Horner > > > wrote: > >> rubydoc is a project aimed at >> helping rubyists find clojure equivalents. There are now over 200+ >> ruby-cloj

Re: Map literal with keys generated by function cause "Duplicate key" exception

2012-09-12 Thread Ben Smith-Mannschott
On Thu, Sep 13, 2012 at 12:02 AM, Matthew O. Smith wrote: > > On Wednesday, September 12, 2012 8:03:58 AM UTC-6, jarppe wrote: >> >> I have a function that generatwed unique ID's, something like this: >> >> (def k (atom 0)) >> (defn generate-id [] (swap! k inc)) >> >> and I try to use it lik

Re: Map literal with keys generated by function cause "Duplicate key" exception

2012-09-12 Thread Stefan Kamphausen
Hi, On Thursday, September 13, 2012 7:37:09 AM UTC+2, bsmith.occs wrote: > > > Consider a simpler example with a vector, which doesn't produce an > error since it's allowed to have duplicates: > > (def k (atom 0)) > (defn generate-id [] (swap! k inc)) > > Now when the reader reads this: > > [