Re: Good choices for a NoSQL database with Clojure?
On Sat, Mar 26, 2011 at 09:56, Base basselh...@gmail.com wrote: hi All - Any recommendations on a NoSQL database to use with clojure? I am experimenting if it will fit my project better than a SQL db and have no real experience with them. I've replaced my rdbms with Riak (www.basho.com). Strong clojure support is obviously important for this. The only one I know of is MongoDb... It doesn't have the best clojure interface into it unfortunately, so if you're looking for 0-60 in the shortest time choose something else. It is a medium term plan of mine to build a clojure implementation. Thoughts?? Were I making the decisions again, i'd definitely look into Redis. Not least because every page of their documentation has a live redis connection on it, so you can play with the function which you're reading about: http://redis.io/commands/expire Thanks Base -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Good choices for a NoSQL database with Clojure?
On Sat, Mar 26, 2011 at 12:15, Michael Ossareh ossa...@gmail.com wrote: On Sat, Mar 26, 2011 at 09:56, Base basselh...@gmail.com wrote: hi All - Any recommendations on a NoSQL database to use with clojure? I am experimenting if it will fit my project better than a SQL db and have no real experience with them. I've replaced my rdbms with Riak (www.basho.com). Strong clojure support is obviously important for this. The only one I know of is MongoDb... It doesn't have the best clojure interface into it unfortunately, so if you're looking for 0-60 in the shortest time choose something else. It is a medium term plan of mine to build a clojure implementation. a clojure implementation of the interface into riak. Thoughts?? Were I making the decisions again, i'd definitely look into Redis. Not least because every page of their documentation has a live redis connection on it, so you can play with the function which you're reading about: http://redis.io/commands/expire Thanks Base -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Good choices for a NoSQL database with Clojure?
On Sat, Mar 26, 2011 at 13:12, Base basselh...@gmail.com wrote: Thanks All! I guess I didnt even realize that they were so different (though that certainly makes sense). Basically I want to design a system that will have maybe 30M (eventually) complex graphs of data that need to be searchable through either pattern matching or unification or ?... The pattern s could conceivably become very complicated. My thought was that this would need to scale out horizontally and allow for a map-reduce like process to burn through these searches (though at this point i am still planning this part out and currently have my data in an RDBMS (using H2 in development - great little database). That helps, so you need: - key:value store - support for graph structures. - mapreduce My experience is with Riak, and none of the others, which can certainly help you here (in the same order as above): - You store your objects, - You can define links between objects, - You can walk these links during map reduce jobs This is very new territory for me, as i am very much used to working with traditional databases so I kind of dont know where to start... http://mmcgrana.github.com/2010/08/riak-clojure.html does a decent job of giving you a low down on riak with clojure. I've accentuated the api to permit storing links against your objects: https://github.com/ossareh/clj-riak - this hasn't been pulled into Mark's main branch yet. A high level run through (tested): (ns riak-test (:require [clj-riak.client :as riak] [clojure.contrib.json :as json])) (def rc (riak/init {:host 127.0.0.1 :port 8087})) (defn fetch [type key] (try (let [bucket (name type) val (riak/get rc bucket key) links (:links val) val (- val :value String. json/read-json)] (with-meta val {:links links})) (catch Exception e nil))) (defn put [bucket key data] (let [bucket (name bucket) links (or (:links (meta data)) '()) data {:value (.getBytes (json/json-str data)) :content-type application/json :links links}] (riak/put rc bucket key data))) (defn link [obj to-type to-id type] (let [links (:links (meta obj)) links (conj links {:bucket (name to-type) :key to-id :tag (name type)})] (with-meta obj {:links links}))) ;; now you can store objects with links. (put :test foo {:some data :about {:your domain}}) (put :test bar (link {:more data} :test foo :example)) ;; The following is from the repl riak-test (fetch :test foo) {:some data, :about {:your domain}} riak-test (fetch :test bar) {:more data} riak-test (:links (meta (fetch :test bar))) ({:bucket test, :key foo, :tag example}) Now you'd have two independent objects in riak, which during map reduce could be used in a graph like manner. In this case the bar object points to the foo object. A point worth making is that Riak is a dynamo based kv store. Which, most notably to a RDBMS user, means you don't have the concept of updating in place. That is, if I wanted to change the bar object to have a key of :name with a value of bob you have to do this: riak-test (put :test bar (assoc (fetch :test bar) :name bob)) nil riak-test (fetch :test bar) {:name bob, :more data} i.e. fetch bar, assoc bar :name bob put result. HTH On Mar 26, 2:55 pm, Michael Ossareh ossa...@gmail.com wrote: On Sat, Mar 26, 2011 at 12:15, Michael Ossareh ossa...@gmail.com wrote: On Sat, Mar 26, 2011 at 09:56, Base basselh...@gmail.com wrote: hi All - Any recommendations on a NoSQL database to use with clojure? I am experimenting if it will fit my project better than a SQL db and have no real experience with them. I've replaced my rdbms with Riak (www.basho.com). Strong clojure support is obviously important for this. The only one I know of is MongoDb... It doesn't have the best clojure interface into it unfortunately, so if you're looking for 0-60 in the shortest time choose something else. It is a medium term plan of mine to build a clojure implementation. a clojure implementation of the interface into riak. Thoughts?? Were I making the decisions again, i'd definitely look into Redis. Not least because every page of their documentation has a live redis connection on it, so you can play with the function which you're reading about: http://redis.io/commands/expire Thanks Base -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com
Re: Tracking Clojure 1.3/2.0 progress
On Wed, Mar 9, 2011 at 13:23, Aaron Bedra aaron.be...@gmail.com wrote: On 03/09/2011 02:18 PM, Fogus wrote: Hi all, I've put together a Jira dashboard to display a distillation of the current progress toward the 1.3/2.0 release. I believe that anyone can view it, so pass the link far and wide. http://dev.clojure.org/jira/secure/Dashboard.jspa?selectPageId=10014 There is additional information displayed if you log in. Enjoy. :f Very nice! +1 -- Cheers, Aaron Bedra -- Clojure/core http://clojure.com -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Issue with lein-ring...
On Tue, Mar 8, 2011 at 11:31, John Szakmeister j...@szakmeister.net wrote: I've been working on a web app, and it was using leiningen-war. The author of that suggest moving to the lein-ring plugin on his github site... so, I did that. However, when I run lein ring server I get a traceback, which I show below. Two lines stand out to me: at ring.util.tracker$eval688$loading__4292__auto689.invoke(tracker.clj:1) at ring.util.tracker$eval688.invoke(tracker.clj:1) So I went to look at ring.util.tracker... but there is no ring.util.tracker. :-( So I have no idea what's happening here. I'm hoping someone here can shed some light on this. 90% of the time I find that: lein clean rm -rf lib lein deps solves this type of issue. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java.lang.Exception: transaction rolled back: java.lang.InterruptedException
On Thu, Feb 24, 2011 at 14:36, clj123 ariela2...@gmail.com wrote: That didn't solve the problem. I've tried smaller row numbers and it still throws the same error: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.InterruptedException at clojure.lang.LazySeq.sval(LazySeq.java:47) at clojure.lang.LazySeq.seq(LazySeq.java:56) at clojure.lang.Cons.next(Cons.java:39) at clojure.lang.RT.next(RT.java:560) at clojure.core$next.invoke(core.clj:61) What is the DB saying in its logs? -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defrecord/deftype ...
One place it has mattered is in using compojure with ring. I'm building a few middlewares that permit my applications to have a good sense of structure (somewhat MVC ish) in that process I discovered that to be compojure compatible you must return a supported type or extend the Renderable protocol. To your point a map could have been returned, however in this case I wanted to ensure I could pass a rich datastructure around that didn't run the risk of being considered a ring response; thus I created my own. Having used this for a bit now, I'm certainty craving the simplicity of maps. Though the fact errors take place in my code versus further down the stack is a nice benefit in this setup. On Feb 16, 2011 2:34 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Thanks Michael. yea true .. but I don't think I will miss them much .. :) Sunil. On Wed, Feb 16, 2011 at 12:32 PM, Michael Ossareh ossa...@gmail.com wrote: Am I missing something? types. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defrecord/deftype ...
Do you have more details of this - it sounds interesting... A very rough answer: https://github.com/ossareh/clj-boilerplate I've some local changes that will go up in a few days that make this better - they're based off me actually using the framework where as what is there right now is mostly theory. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: defrecord/deftype ...
Am I missing something? types. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: [ANN] emacs-nexus (Emacs client for Nexus Maven repository servers)
On Mon, Feb 14, 2011 at 16:50, Scott Jaderholm jaderh...@gmail.com wrote: On Mon, Feb 14, 2011 at 7:21 PM, Jürgen Hötzel juer...@hoetzel.infowrote: Hi, Although Emacs is a great environment for writing Clojure code and Leiningen/Cake makes Maven builds less painful, you still had to switch from your Emacs environment to your web browser to search for Maven artifacts. emacs-nexus is a minimal (elisp-only) Nexus client to search for artifacts and display Leiningen/Maven dependencies: https://github.com/juergenhoetzel/emacs-nexus Any feedback/contribution is appreciated. Cool, maybe search clojars by default also? Along with anything that is listed in :repositories in your project.clj ? Scott -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure xmpp
On Thu, Feb 10, 2011 at 08:21, Bruce Durling b...@otfrom.com wrote: Mark, Smack looks delightfully straightforward. I think I'll give it a shot thanks! Smack has a bunch of oddities once you start wanting to do anything past simple message processing. The predominate issue (this as of smack 3.0 I believe) was that each XMPP connection fires up 4 threads, since we (heysan) were using this in a service setting (consider something similar to meebo) this really impacted our scalability. If you're not creating a chat site for teens - you're good to go! XMPP itself is a relatively simple protocol (primarily since it is so well documented). If someone were game to build a pure clj implementation on top of something like aleph I'd definitely donate 15hours a week to help. The world needs a better JVM XMPP stack, imho. cheers, Bruce On Thu, Feb 10, 2011 at 15:58, Mark Rathwell mark.rathw...@gmail.com wrote: I just created my own clojure wrappers around the jive (igniterealtime) java libraries. Created an xmpp client library with their Smack library, and a server component library with Tinder (you will need to build from source with this one). They are fairly solid java xmpp libraries. igniterealtime site: http://www.igniterealtime.org/ I don't have them in any public repositories, but if you have any interest in using them as a starting point for your own work, let me know, I can post them somewhere or email them to you. - Mark On Thu, Feb 10, 2011 at 7:06 AM, Bruce Durling b...@otfrom.com wrote: Hi, We're going to be doing a dojo in the future that will create an XMPP bot. I've found a couple of clojure xmpp projects out there, but I was wondering if anyone on the list could recommend a particular project in clojure or failing that a good Java library to base our work on. I've seen xmpp-clj https://github.com/zkim/xmpp-clj and it appears to be the furthest along so far. cheers, Bruce -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.contrib.condition
https://github.com/technomancy/leiningen/blob/master/sample.project.clj try adding :aot [clojure.contrib.condition] to your project.clj ? On Mon, Feb 7, 2011 at 17:56, Brian Marick mar...@exampler.com wrote: The header documentation for clojure.contrib.condition says: Note: requires AOT compilation. What do I therefore do differently? How should my program text change? Conditions seem to work in the REPL, but not in my program. I don't know if that's due to the mysteries of AOT compiling or something else I'm doing wrong. Please enlighten. - Brian Marick, Artisanal Labrador Contract programming in Ruby and Clojure Author of /Ring/ (forthcoming; sample: http://exampler.com/tmp/ring.pdf) www.exampler.com, www.exampler.com/blog, www.twitter.com/marick -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: searching for a good name thread-let, thread-with, thread-thru
On Fri, Feb 4, 2011 at 12:05, B Smith-Mannschott bsmith.o...@gmail.comwrote: I came up with this macro, but I'm unsure what to call it: (defmacro thread-let [[varname init-expression :as binding] expressions] {:pre [(symbol? varname) (not (namespace varname)) (vector? binding) (= 2 (count binding))]} `(let [~@(interleave (repeat varname) (cons init-expression expressions))] ~varname)) Hah, you have been working on one of my frustrations! Thanks! I like (thread-with sym forms) -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
extend-protocol with defrecord
Hi All, I've found extending-protocol to hold on to a references to records when they're redefined. example (defprotocol ToExtend (foo [this])) ToExtend example (defrecord Extender1 []) example.Extender1 example (extend-protocol ToExtend Extender1 (foo [this] extender1)) nil example ToExtend {:impls {example.Extender1 {:foo #example$eval3465$fn__3466 example$eval3465$fn__3466@5549f0e}}, :on-interface example.ToExtend, :on example.ToExtend, :sigs {:foo {:doc nil, :arglists ([this]), :name foo}}, :var #'example/ToExtend, :method-map {:foo :foo}, :method-builders {#'example/foo #example$eval3417$fn__3418 example$eval3417$fn__3418@71a67fe }} example (count (:impls ToExtend)) 1 example (defrecord Extender1 [a]) example.Extender1 example (foo (Extender1. a)) No implementation of method: :foo of protocol: #'example/ToExtend found for class: example.Extender1 [Thrown class java.lang.IllegalArgumentException] example (extend-protocol ToExtend Extender1 (foo [this] extender1a)) nil example (foo (Extender1. a)) extender1a example ToExtend {:impls {example.Extender1 {:foo #example$eval3519$fn__3520 example$eval3519$fn__3520@4d86d315}, example.Extender1 {:foo #example$eval3465$fn__3466 example$eval3465$fn__3466@5549f0e}}, :on-interface example.ToExtend, :on example.ToExtend, :sigs {:foo {:doc nil, :arglists ([this]), :name foo}}, :var #'example/ToExtend, :method-map {:foo :foo}, :method-builders {#'example/foo #example$eval3417$fn__3418 example$eval3417$fn__3418@71a67fe}} example (count (:impls ToExtend)) 2 You'll notice in the map returned after the second (extend-protocol) that :impls has example.Extender1 listed twice. I assume this is because they're different records, though the fact that they share the same name is confusing (hence the example of the exception being thrown). A few questions: - Is this expected behaviour? - If so, why? It feels odd to have two classes of the same name (type even?) act differently In the other examples of extend-protocol being used (compojure.response/Renderable) types far less likely to be redefined are being used, so perhaps this is only to be used with types that change less? If that is the case then how does one achieve what I'm trying to do; extend Renderable to support my own types being passed to it without Renderable acting on my previous types? Cheers, mike -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: extend-protocol with defrecord
On Wed, Feb 2, 2011 at 18:49, Alex Osborne a...@meshy.org wrote: Michael Ossareh ossa...@gmail.com writes: You'll notice in the map returned after the second (extend-protocol) that :impls has example.Extender1 listed twice. I assume this is because they're different records, though the fact that they share the same name is confusing (hence the example of the exception being thrown). A few questions: - Is this expected behaviour? - If so, why? It feels odd to have two classes of the same name (type even?) act differently This has to be the case as you might have instances of the old version of the class hanging around, which you could call protocol functions on. The JVM doesn't let you modify existing classes in place (for obvious reasons: what is it supposed to do if you changed the primitive type of a field). All you can do is load a new one (possibly with the same name) and then create some new instances with that new class. Ahh, as proven here: example (defprotocol Extended (foo [this])) Extended example (defrecord Extender []) example.Extender example (extend-protocol Extended Extender (foo [this] first)) nil example (def x (Extender.)) #'example/x example (foo x) first example (defrecord Extender [a]) example.Extender example (extend-protocol Extended Extender (foo [this] (:a this))) nil example (foo x) first example (foo (Extender. second)) second This is clearly quite cool and I'm now interested in more! In the other examples of extend-protocol being used (compojure.response/Renderable) types far less likely to be redefined are being used, so perhaps this is only to be used with types that change less? If that is the case then how does one achieve what I'm trying to do; extend Renderable to support my own types being passed to it without Renderable acting on my previous types? Could you rephrase this? I'm not sure I understand what you're trying to achieve. The dynamic redefinition features are supposed to be used for solely as handy hack for interactive development. So if your environment gets messed up too much you can just reload everything in a fresh JVM. In a finished program redefinition should never occur. Thanks for asking me to step back and think about it - you're right - it is clear to me now - this caught me out as a result of repl based work and stray references. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Getting http-agent to throw an exception if url doesn't exist?
On Sat, Jan 29, 2011 at 01:58, Max Weber weber.maximil...@googlemail.comwrote: Give clj-http a try (https://github.com/getwoven/clj-http). It has an architecture similar to the one of Ring. Especially the Ring-style middleware helps a lot, if you want to add custom behaviour like error handling to clj-http. Looks great! cheers for this. On 27 Jan., 02:21, Michael Ossareh ossa...@gmail.com wrote: On Wed, Jan 26, 2011 at 14:57, Stuart Sierra the.stuart.sie...@gmail.comwrote: clojure.contrib.http-agent (which I wrote) is deprecated in 1.2 and gone in 1.3. Which lib is recommended to replace it? -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Getting http-agent to throw an exception if url doesn't exist?
On Wed, Jan 26, 2011 at 14:57, Stuart Sierra the.stuart.sie...@gmail.comwrote: clojure.contrib.http-agent (which I wrote) is deprecated in 1.2 and gone in 1.3. Which lib is recommended to replace it? -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: slow mysql inserts
On Wed, Jan 19, 2011 at 09:15, rygorr ryg...@gmail.com wrote: This was it. The overhead was in creating the handle. I can't remember who told me this: Always blame the network. In finer detail, the conversation was about things that use the network and are so very much slower than you anticipate. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Create a map from two seqs
On Mon, Jan 17, 2011 at 10:14, Sam Aaron samaa...@gmail.com wrote: There are a lot of handy functions like this in core but you really need to know they exist before you can use them. Discovering new ones is always exciting! I've found lurking in #clojure on irc to be a great way to find out about the functions in core. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Notice: c.c.json parser and clojure.lang.Ratio
On Sat, Jan 8, 2011 at 23:38, Stuart Sierra the.stuart.sie...@gmail.comwrote: Ratios aren't valid JSON. If the recipient is Clojure, you don't need JSON at all, just pr-str and read-string. Of course! Thanks, mike -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Notice: c.c.json parser and clojure.lang.Ratio
On Sat, Jan 8, 2011 at 13:49, Stuart Sierra the.stuart.sie...@gmail.comwrote: There's no solution here that will be perfect for all cases. But I've made the decision that c.c.json will always downgrade Clojure types to the nearest equivalent JSON types. It does not promise round-trip preservation of types not specified by JSON, such as sets. In this case, that means Ratios should become doubles. I've pushed this change to master. I'd spent some time considering supplying a patch similar to this - two things stopped me and instead had me write the multi-methods supplied later: (a) my CA is sat at home un-mailed. (b) I kinda like I can send ratio's to and from clojure end points Is it a terrible idea to provide an optional flag to the parser that says whether this coercion should take place or not - defaulting to the interop version, but still preserving the accuracy of numbers if the recipient is clojure? -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: #clojure in 2010
On Thu, Jan 6, 2011 at 08:50, Miki miki.teb...@gmail.com wrote: If someone is interested in some other statistics, please let me know and I'll try to make it happen. The most talkative person per session would be interesting :) though perhaps session time is a PITA to establish particularly across days boundaries. Define session (a day? a subject? ...) login to logout. So the stat would be number of messages / hours logged in. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Notice: c.c.json parser and clojure.lang.Ratio
Hi, It turns out that c.c.json/json-str will spit out Ratio's in a manner which is not json compliant. (json-str [3/4]) = [3/4] This parses correctly in the reverse situation: (read-json (json-str [3/4])) = [3/4] When being read [1] we switch over to using the clojure form reader so this problem is masked, however this is not the case for other parsers [2] such as mozilla's spider monkey as well as V8/Chrome [3]. I'm unclear on what the correct course of action in this case should be. Cheers, mike [1] https://github.com/clojure/clojure-contrib/blob/master/modules/json/src/main/clojure/clojure/contrib/json.clj#L124 [2] https://gist.github.com/766992 [3] http://picasaweb.google.com/lh/photo/8Rj_vqDMviL4WsUjP6JIVcATd3TVUBzXoXciG6VLJdU -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: #clojure in 2010
On Tue, Jan 4, 2011 at 19:06, Miki miki.teb...@gmail.com wrote: If someone is interested in some other statistics, please let me know and I'll try to make it happen. The most talkative person per session would be interesting :) though perhaps session time is a PITA to establish particularly across days boundaries. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Notice: c.c.json parser and clojure.lang.Ratio
I'm unclear on what the correct course of action in this case should be. However this can be solved by transforming the ratios before and after to the jsonification: https://gist.github.com/767204 (clojure.walk/postwalk transform-ratio {:a [3/4] :b {:foo {:bar 3/4} :bar {:a 1}}}) = {:a [{:n 3, :d 4, :t ratio}], :b {:foo {:bar {:n 3, :d 4, :t ratio}}, :bar {:a 1}}} (clojure.walk/postwalk transform-ratio (clojure.walk/postwalk transform-ratio {:a [3/4] :b {:foo {:bar 3/4} :bar {:a 1}}})) = {:a [3/4], :b {:foo {:bar 3/4}, :bar {:a 1}}} ... and now with json: (clojure.walk/postwalk transform-ratio (json/read-json (json/json-str (clojure.walk/postwalk transform-ratio {:a [3/4] :b {:foo {:bar 3/4} :bar {:a 1}}} = {:a [3/4], :b {:foo {:bar 3/4}, :bar {:a 1}}} Thanks to benreesman, amalloy and fliebel in #clojure for guiding me this way. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: pods?
On Fri, Dec 24, 2010 at 01:20, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 24.12.2010 um 09:56 schrieb Meikel Brandmeyer: Am 24.12.2010 um 09:44 schrieb Sunil S Nandihalli: what are PODS? And as a side note: I'm sad that people on conferences know more about pods than people on this list. :( Is there a go to place for a roadmap? http://dev.clojure.org/ perhaps? Sincerely Meikel -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Automatically unmapping unit tests from namespaces
On Tue, Dec 21, 2010 at 16:16, Phil Hagelberg p...@hagelb.org wrote: It also highlights failures in the test buffer for better feedback. when there is a failure where are the details of the failure printed out to? I love that the highlight shows me which test have errors, but since I've moved over to the emacs starter kit (thanks!!) I've lost the error output and have to switch to a terminal to run lein test. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Automatically unmapping unit tests from namespaces
On Tue, Dec 21, 2010 at 21:36, Michael Ossareh ossa...@gmail.com wrote: On Tue, Dec 21, 2010 at 16:16, Phil Hagelberg p...@hagelb.org wrote: It also highlights failures in the test buffer for better feedback. when there is a failure where are the details of the failure printed out to? I love that the highlight shows me which test have errors, but since I've moved over to the emacs starter kit (thanks!!) I've lost the error output and have to switch to a terminal to run lein test. The answer: the repl buffer. I've no idea why they weren't - but they are now. I'll take it :) -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Erlang-esque bit syntax in Clojure?
I was wondering if anyone has been working on implementing a bit syntax for Clojure in the rough conceptual style of Erlang's bit syntax. I'm not an erlang-pro, just dabbled enough to know I like the pattern matching, which is what you're talking about here, I believe. I'm looking for a Clojure adaptation of the core concept and tool as it exists in Erlang So, as I understand it, in erlang you have a function and each implementation of that function is guarded by a pattern, in the case of the bit syntax you're able to look at arbitrary binary data. I think compojure provides an interesting template for this; instead of defining `routes` you define patterns (expressed however you want, you just need to create the macros for it), when those patterns match you execute the accompanying forms. The major issue I see here is performance, you would probably have to copy everything off the buffer to actually run it through the pattern matching function. I suppose the copying could be limited to just when you have a full packet, so you'd need another set of logic for defining what a full packet is, IRC erlang does this too when you define your socket options. To that point... I've also seen Zach Tellman's Gloss[2], but I'm not sure it's what I want. It is highly likely I've missed something I was at Zach's gloss talk two weeks ago and I think it is definitely what you want, at least to start: https://github.com/ztellman/gloss/wiki -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Java out of memory problem
On Thu, Dec 16, 2010 at 09:19, clj123 ariela2...@gmail.com wrote: Hello, I'm trying to insert in a database large number of records, however it's not scaling correctly. For 100 records it takes 10 seconds, for 100 records it takes 2 min to save. But for 250 records it throws Java Heap out of memory exception. I've tried separting the records processing and the actual batch save. Just processing the 250 records in memory it take 30 seconds. With batch insert it throws the above exception. I don't understand why saving to a database it creates more Java Heap space. Any ideas would be appreciated. What indexes are on the table that you're inserting into? To me the increase in time suggests your index is being rebuilt after each insert. As for the memory, I concur with zeph, you're either holding onto the head of a seq or you're accessing some portion of a string which is holding the data structures around and you're OOMing as a result. Code please :) -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: post your feedback on the conj
On Wed, Dec 8, 2010 at 02:16, Sam Aaron samaa...@gmail.com wrote: The rollout of videos has already started: http://twitter.com/clojure_conj/status/10324356836102144 Fogus' talk: http://clojure.blip.tv/file/4501296/ The synopsis says 30 minutes but it seems there may have been an issue in the upload / transcode because it throws up an error at 18m 36s (which the player also considers the end of the video). -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: OOM with Agents
This was the first issue, the second issue is that I'm queueing up lots of data for the thread pools and as a result I'm able to completely exhaust the available memory. the clj-sys/work framework seems to be what I need to ensure there is a fixed number of threads. I wrote this up: http://ossareh.posterous.com/batch-consumption-of-crunchbase-with-clojure -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure on java me vms?
On Sun, Dec 12, 2010 at 19:45, Kevin Downey redc...@gmail.com wrote: no, the runtime you get with every j2me implementation I've seen ia a stipped down java 1.3 or 1.4. Clojure requires 1.5 at least. Basically there are no phones with a real, up to date, jre. Out of interest, and with no time to find this out myself, at a glance what makes clojure require 1.5? I feel like autoboxing, the threading libraries, and java.util.concurrent ? -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: OOM with Agents
On Fri, Dec 10, 2010 at 23:36, Alex Osborne a...@meshy.org wrote: Michael Ossareh ossa...@gmail.com writes: There are 54874 companies in the companies var. The OOM tends to take place when there are 1000 or so companies to process. What is likely to be causing this issue? I replied on IRC but just recapping here. Yes, and you nailed the issue. Thanks so much! I think you've probably been bitten by the way Java strings share data. The gotcha is described here better than I can: http://fishbowl.pastiche.org/2005/04/27/the_string_memory_gotcha/ One thing you can do to try to debug this sort of thing is to add -XX:+HeapDumpOnOutOfMemoryError to the JVM command-line. Then when you run into an OOM this will happen: java.lang.OutOfMemoryError: GC overhead limit exceeded Dumping heap to java_pid8706.hprof ... Heap dump file created [14429104 bytes in 0.154 secs] This was the first issue, the second issue is that I'm queueing up lots of data for the thread pools and as a result I'm able to completely exhaust the available memory. the clj-sys/work framework seems to be what I need to ensure there is a fixed number of threads. You can then load that .hprof file into jvisualvm (shipped with the JDK) to show what objects are using up the heap. It'll let you drill right down and even inspect individual objects. I kinda want to make it break just so that I can use jvisualvm - it looks like fun. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
OOM with Agents
Hi, I've cobbled together some grungy code to attempt to work out the number of employees in different ranges - the code is a horrible mess of side effects: https://gist.github.com/737179 (pmap process-company (take 1500 companies)) results in: Exception in thread pool-2-thread-3905 java.lang.OutOfMemoryError: Java heap space Exception in thread pool-2-thread-4458 java.lang.IllegalStateException: Pop without matching push at clojure.lang.Var.popThreadBindings(Var.java:297) at clojure.lang.Agent$Action.doRun(Agent.java:145) at clojure.lang.Agent$Action.run(Agent.java:150) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680) Exception in thread pool-2-thread-4549 java.lang.OutOfMemoryError: Java heap space Exception in thread pool-2-thread-3723 java.lang.OutOfMemoryError: Java heap space There are 54874 companies in the companies var. The OOM tends to take place when there are 1000 or so companies to process. What is likely to be causing this issue? Cheers, mike -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: easiest way to make a map out of a list?
On Mon, Dec 6, 2010 at 21:01, Alex Baranosky alexander.barano...@gmail.comwrote: Way I have [:a 1:b 2] and I want to convert it to {:a 1 :b 2} Minor quibble - [] is a Vector not a list. List is (). -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: functional thinking
On Wed, Dec 1, 2010 at 05:29, Laurent PETIT laurent.pe...@gmail.com wrote: Hi, 2010/12/1 Michael Ossareh ossa...@gmail.com Hi All, In the course of putting together my latest piece of work I decided to really embrace TDD. This is run of the mill for me in Java: - create some object that models your flow - create some object which contains your storage logic - create tests - dependency inject the correct storage logic depending on which scenario you're running in (prod / test / etc). Hum, this process does not seem to be eligible to be named TDD. In TDD, the tests are written first and shape the interface of your solution. Here what to do is more traditional: you write your domain objects, your logic, and you add tests. Not a critic of the methodology (I'm not advocating any methodology over another here, to be clear), but rather a thought on how things are named. Fair point. I do use TDD, I have no idea why I listed these steps incorrectly! /me slaps his wrists. Some more thoughts (not sure they will help, but who knows ?) : I've not been able to think about how to correctly achieve this same functionality in clojure. So far everything is pretty much pure functions, the storage functions being the only place where data is changed. Currently the storage is implemented with atomic maps. The production storage will be in Riak. Hmm, if by storage functions being the only place where data is changed you mean that in storage functions you do 2 things: change the value and store them, then IMHO you could split them in 2. Storage functions here mean taking the data given to them and storing them - they do not change the data that they receive. I'm getting ready to build the Riak backend and now I'm faced with how to choose the correct backing implementation. I've a namespace, rah.test-storage, which implements the in-memory storage and I anticipate putting riak storage in rah.riak-storage - however I'm not sure what the best way to select the correct implementation at runtime or test time is. One solution I've come up with is to use defprotocol to define the functions for the storage layer (as you would an interface in java) and then have a defrecord for each implementation. Assume these to be in the namespace rah.storage, which would also house the functions which call the correct defrecord functions based on a property given at start time. This solution, however, feels like me trying to write Java in clojure - and I'm wondering how the lispers of the world would solve this same issue. Another solution would be to write the same set of functions in the rah.storage namespace which then look at the same property and then decide whether to call rah.riak-storage/store-user! or rah.test-storage/store-user!. The solution, as every solution, will have to be a trade-of. Here one axis for the tradeoff can be seen as how powerful you want your backend connectivity to be (singleton backend per app ? possibly several different backends at the same time ? pluggable backends during runtime ?) versus the ease of writing the app (the more probability you want power, the more probability there will be to have a backend object to be passed around : no backend object in case of a singleton backend for the app, several singleton backend objects). Note that if you know that each singleton backend will be of a different kind than the others, then simply a keyword for representing each backend may be sufficient. This keyword for different backend concept is amazing. Thank you! It reminds me a little of how pallet https://github.com/pallet/pallet achieves it's shiz. I'll ensure to read up on it does what it does. From what I can infer from what you described, if you would write the application without caring about programmatic testing, you would be fine by just having top level functions, and probably a top level configuration map with key/values for backend location, credentials, etc. If so, then it may be sufficient to leverage the possibility, in your testing framework (clojure.test ? anything else ...) to redefine the functions of the backend before the tests run. I'm pretty sure there are already such features allowing to temporarily redef (and restore at the end) the root value of global vars. Laurent, thanks so much. This is really great. Cheers, mike HTH, -- Laurent -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post
Re: functional thinking
On Wed, Dec 1, 2010 at 10:51, Alyssa Kwan alyssa.c.k...@gmail.com wrote: Hi Mike, TDD as if you meant it - http://gojko.net/2009/02/27/thought-provoking-tdd-exercise-at-the-software-craftsmanship-conference/ What you want is mocking and stubbing (these are different things!). http://s-expressions.com/2010/01/24/conjure-simple-mocking-and-stubbing-for-clojure-unit-tests/ Great links - thanks Alyssa. Remember that unit testing is NOT integration testing... Thanks, Alyssa On Dec 1, 8:29 am, Laurent PETIT laurent.pe...@gmail.com wrote: Hi, 2010/12/1 Michael Ossareh ossa...@gmail.com Hi All, In the course of putting together my latest piece of work I decided to really embrace TDD. This is run of the mill for me in Java: - create some object that models your flow - create some object which contains your storage logic - create tests - dependency inject the correct storage logic depending on which scenario you're running in (prod / test / etc). Hum, this process does not seem to be eligible to be named TDD. In TDD, the tests are written first and shape the interface of your solution. Here what to do is more traditional: you write your domain objects, your logic, and you add tests. Not a critic of the methodology (I'm not advocating any methodology over another here, to be clear), but rather a thought on how things are named. Some more thoughts (not sure they will help, but who knows ?) : I've not been able to think about how to correctly achieve this same functionality in clojure. So far everything is pretty much pure functions, the storage functions being the only place where data is changed. Currently the storage is implemented with atomic maps. The production storage will be in Riak. Hmm, if by storage functions being the only place where data is changed you mean that in storage functions you do 2 things: change the value and store them, then IMHO you could split them in 2. I'm getting ready to build the Riak backend and now I'm faced with how to choose the correct backing implementation. I've a namespace, rah.test-storage, which implements the in-memory storage and I anticipate putting riak storage in rah.riak-storage - however I'm not sure what the best way to select the correct implementation at runtime or test time is. One solution I've come up with is to use defprotocol to define the functions for the storage layer (as you would an interface in java) and then have a defrecord for each implementation. Assume these to be in the namespace rah.storage, which would also house the functions which call the correct defrecord functions based on a property given at start time. This solution, however, feels like me trying to write Java in clojure - and I'm wondering how the lispers of the world would solve this same issue. Another solution would be to write the same set of functions in the rah.storage namespace which then look at the same property and then decide whether to call rah.riak-storage/store-user! or rah.test-storage/store-user!. The solution, as every solution, will have to be a trade-of. Here one axis for the tradeoff can be seen as how powerful you want your backend connectivity to be (singleton backend per app ? possibly several different backends at the same time ? pluggable backends during runtime ?) versus the ease of writing the app (the more probability you want power, the more probability there will be to have a backend object to be passed around : no backend object in case of a singleton backend for the app, several singleton backend objects). Note that if you know that each singleton backend will be of a different kind than the others, then simply a keyword for representing each backend may be sufficient. From what I can infer from what you described, if you would write the application without caring about programmatic testing, you would be fine by just having top level functions, and probably a top level configuration map with key/values for backend location, credentials, etc. If so, then it may be sufficient to leverage the possibility, in your testing framework (clojure.test ? anything else ...) to redefine the functions of the backend before the tests run. I'm pretty sure there are already such features allowing to temporarily redef (and restore at the end) the root value of global vars. HTH, -- Laurent- Hide quoted text - - Show quoted text - -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group
functional thinking
Hi All, In the course of putting together my latest piece of work I decided to really embrace TDD. This is run of the mill for me in Java: - create some object that models your flow - create some object which contains your storage logic - create tests - dependency inject the correct storage logic depending on which scenario you're running in (prod / test / etc). I've not been able to think about how to correctly achieve this same functionality in clojure. So far everything is pretty much pure functions, the storage functions being the only place where data is changed. Currently the storage is implemented with atomic maps. The production storage will be in Riak. I'm getting ready to build the Riak backend and now I'm faced with how to choose the correct backing implementation. I've a namespace, rah.test-storage, which implements the in-memory storage and I anticipate putting riak storage in rah.riak-storage - however I'm not sure what the best way to select the correct implementation at runtime or test time is. One solution I've come up with is to use defprotocol to define the functions for the storage layer (as you would an interface in java) and then have a defrecord for each implementation. Assume these to be in the namespace rah.storage, which would also house the functions which call the correct defrecord functions based on a property given at start time. This solution, however, feels like me trying to write Java in clojure - and I'm wondering how the lispers of the world would solve this same issue. Another solution would be to write the same set of functions in the rah.storage namespace which then look at the same property and then decide whether to call rah.riak-storage/store-user! or rah.test-storage/store-user!. Any thoughts much appreciated. Cheers, mike -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure 1.3 alpha3 and swank
On Sun, Nov 28, 2010 at 00:15, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: what repository did you get it from? I don't seem to fine 1.3.0 anywhere.. http://clojars.org/swank-clojure I forgot the -SNAPSHOT in my previous message. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure 1.3 alpha3 and swank
I had no issues with swank-clojure 1.3.0: in project.clj [swank-clojure 1.3.0] I had plenty of issues using other libraries as there are some breaking changes in 1.3. YMMV. On Thu, Nov 25, 2010 at 05:52, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello Everybody, I would like to have a go at 1.3 alpha3 .. but having a lot of trouble with the swank.. can somebody suggest me a version of swank-clojure that has worked for them along with 1.3 alpha3 Thanks, Sunil. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure-contrib 1.3.0-alpha3 deployed to build.clojure.org
On Mon, Nov 22, 2010 at 14:56, Benny Tsai benny.t...@gmail.com wrote: My guess is that they're being deprecated in favor of their counterparts in clojure.core: string - clojure.string io - clojure.java.io Ah right, I think I remember that now. Thanks! -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: From jetty to war?
On Wed, Nov 3, 2010 at 20:51, Mike Meyer mwm-keyword-googlegroups.620...@mired.org wrote: Finding good people is hard enough that wanting them to be good in three or four languages is enough to break the camels back. If you've got time to cross-train them - then you don't need I've regularly found that the multi-disciplinarian programmer is far more adept at solving issues in a creative manner than the I've a skilled hammer and I'll wield it in the direction of any nail-mono-linguistic programmer. Perhaps that is just an artifact of working in startups though. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Development vs Production resource files
On Mon, Nov 1, 2010 at 21:09, Sean Corfield seancorfi...@gmail.com wrote: This Q came up on the Leiningen list but I wanted to share my answer on the larger Clojure group to get feedback from a bigger pool... On Mon, Nov 1, 2010 at 8:40 PM, Shantanu Kumar kumar.shant...@gmail.com wrote: There are some resource files (e.g. dbconfig.properties) I need to include in code so that they are on the classpath. However, they need to vary during dev/testing and production -- I will have different versions of dbconfig.properties during dev/testing and production. I want to know what is the recommended way to include/specify them so that they are on the classpath based on he profile (dev, testing, production, staging etc.) I am referring to. My solution to this is ghetto in just the right ways for my needs. I have a config.clj that sits next to my uberjar. In my main gen-class clj namespace I (load-file './config.clj'). config.clj has all the configs pertinent to that running config. The not so great part of this is that every time I need to reference a configed parameter I have to @(ns-resolve config (symbol param)). -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure on Javascript
On Fri, Oct 29, 2010 at 21:32, Michael Gardner gardne...@gmail.com wrote: Agreed. What is the point of Javascript on the server side? Familiarity? Consistency with client-side code? I guess what Java was meant to be, to some degree? Write once run anywhere. I for one am still hankering for a great way to write code that can run in both the JVM and the client-side JS-vm; this code must understand the DOM which is often not the case on the server side. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Getting this error regarding duck-streams/spit ...
On Mon, Oct 25, 2010 at 19:09, Victor Olteanu bluestar...@gmail.com wrote: java.lang.IllegalStateException: spit already refers to: #'clojure.contrib.duck-streams/spit in namespace: datatool.api (api.clj:1) Hi Victor, I solved this issue by using (require) instead of (use). i.e. (ns myapp (require [other-ns :as ns])) Then whenever you access a function in the other-ns you prefix it with ns/function. There may be other ways to solve this though. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Let usage question
On Wed, Oct 20, 2010 at 09:52, Alan a...@malloys.org wrote: I agree with Tom (and with Stuart). I tend to like using - when it's convenient, since all you're really doing is performing a list of transformations on a single object. However, the let is better documentation if that's ever going to matter. Not because it makes it easier to understand what operations are being performed - - is just as good at that - but because you assign names to the intermediate results. Then someone reading your code can see what the purpose of each transformation is, without having to look at the definition of other functions. I also find that the let form permits you to drop print statements in to see what the outcome of various functions are; (defn [x] (let [_ (prn x) x (transform-somehow x) _ (prn x)] x)) -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: SQLAlchemy in Clojure?
On Mon, Oct 18, 2010 at 11:18 AM, Sean Devlin francoisdev...@gmail.com wrote: Okay, I just finished a Python app for work. Using SQLAlchemy was a joy. Has anyone ported this yet? Having never used SQLAlchemy, and rarely python, what are the benefits of SQLAlchemy? My only experience with ORM was hibernate and it was a pretty bad experience, the whole time left thinking Why use this over SQL? - the only answer I came up with was not having to write the table/column to object/property mapping stuff, which alone was not worth the concision lost to not writing my own queries. Also ... that whole lazy loading situation is a real PITA in my experience. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Conj arrivals and Thursday night...
Eric Lavigne lavigne.e...@gmail.com wrote .. What's this about an after party? jealous :( /me darns this startup life that doesn't permit travel -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Newbie : Java Interop question
On Fri, Oct 15, 2010 at 09:32, oak ismail.oka...@gmail.com wrote: Hi All, This is how i see the package in package explorer. IEssbase.class (I) IEssbase (C, s f) Home (M, s) create(String) IEssbase (M, c) Home() (P, s f) JAPI_VERSION Out of interest what is this format? Are my guesses at the letters accurate? I == Interface C == Class M == Method P == ? s == static f == final c = class -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: RFE: modify description of assoc
On Thu, Oct 14, 2010 at 08:02, Ralph grkunt...@gmail.com wrote: First, how do I submit a request for enhancement? I believe the process is: a) register on assembla, b) submit ticket ( http://www.assembla.com/spaces/clojure/tickets/custom_report/2729 ) If you intend to provide the change via a pull request on github you need to provide the contributor agreement (CA) paperwork http://clojure.org/contributing Second, the documentation for assoc in clojure.core should probably include (assoc vector index val) and (assoc vector index val ivs) in the usage line. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: funkyweb 0.1.0 - The clojure webframework with route inference
2010/10/6 Cédric Pineau cedric.pin...@gmail.com One thing : I'm new to clojure and gathering information about the whole ecosystem, including web frameworks, but find it hard to figure what to choose. This has been raised quite a few times recently. Is this a sign of some critical mass starting to form? It would help to have clues of funkyweb's positioning regarding other frameworks such as compojure, compojure-rest, fleet, or even ring. Are they supposed to be used together and how, if not is funkyweb just a matter of taste or does it really provide the-tomorrow-approach-you-don't-want-to-miss, is it a hobby/learning/personnal/short-lived project or do you intend to make it stay and shine for long ? As far as I understand, and I'm very far from an expert on this as I'm only 2 (solid) months into it, Ring is the common layer which many of the routing solutions operate on top of. Ring abstracts a lot of the grungy turn a HTTPServletRequest/Response into a map work that we'd have to do otherwise. And also, I didn't get what was the scope of Flash set.get ? Is this a per thread/request cache ? -- Cédric -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: lispy ways of handling dev mode
On Sat, Oct 2, 2010 at 22:46, Scott Jaderholm jaderh...@gmail.com wrote: On Sat, Oct 2, 2010 at 6:36 PM, Michael Ossareh ossa...@gmail.com wrote: What is the recommended manner in which to let your application know its on a dev machine? I use an environment variable that determines which config (dev, production, test) gets loaded. APPNAME_CONFIG=development lein swank I don't know if it has issues in war deployments or such, I haven't done them. If someone knows of problems with this approach I'd be curious to hear them. I ended up using (load-script) - it's the grungy solution in just the right way :) It gives me a config namespace, is read from arbitrary locations (provided by a command line argument) and it contains clojure forms. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
lispy ways of handling dev mode
What is the recommended manner in which to let your application know its on a dev machine? I'm building an app that sends emails based on certain events, however when I'm developing locally I'd rather it print the email to my log file. I have a variable in that namespace: *send* which is def'ed to true in the file and when in dev mode I set it to false and that results in it printing to the file. However sometimes I have to restart my app or recompile the entire namespace and as a result emails start getting sent out again. In java I'd normally have a conf file somewhere, and that had a range of issues so I'm wondering if there is something more lispy, or perhaps something that makes use of our infrastructure - perhaps the user.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 that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Screencast of the Emacs front end to the Clojure Debugging Toolkit:
On Fri, Oct 1, 2010 at 13:32, George Jahad cloj...@blackbirdsystems.netwrote: For your delectation: http://www.vimeo.com/15462015 This is sick! In the good sense! -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: relational data aggregation language
On Fri, Oct 1, 2010 at 17:55, Ross Gayler r.gay...@gmail.com wrote: Hi, This is probably an abuse of the Clojure forum, but it is a bit Clojure-related and strikes me as the sort of thing that a bright, eclectic bunch of Clojure users might know about. (Plus I'm not really a software person, so I need all the help I can get.) I am looking at the possibility of finding/building a declarative data aggregation language operating on a small relational representation. Each query identifies a set of rows satisfying some relational predicate and calculates some aggregate function of a set of values (e.g. min, max, sum). There might be ~20 input tables of up to ~1k rows. The data is immutable - it gets loaded and never changed. The results of the queries get loaded as new rows in other tables and are eventually used as input to other computations. There might be ~1k queries. There is no requirement for transaction management or any inherent concurrency (there is only one consumer of the results). There is no requirement for persistent storage - the aggregation is the only thing of interest. I would like the query language to map as directly as possible to the task (SQL is powerful enough, but can get very contorted and opaque for some of the queries). There is considerable scope for optimisation of the calculations over the total set of queries as partial results are common across many of the queries. I would like to be able to do this in Clojure (which I have not yet used), partly for some very practical reasons to do with Java interop and partly because Clojure looks very cool. * Is there any existing Clojure functionality which looks like a good fit to this problem? I have looked at Clojure-Datalog. It looks like a pretty good fit except that it lacks the aggregation operators. Apart from that the deductive power is probably greater than I need (although that doesn't necessarily cost me anything). I know that there are other (non- Clojure) Datalog implementations that have been extended with aggregation operators (e.g. DLV http://www.mat.unical.it/dlv-complex/dlv-complex). Tutorial D (what SQL should have been http://en.wikipedia.org/wiki/D_%28data_language_specification%29#Tutorial_D ) might be a good fit, although once again, there is probably a lot of conceptual and implementation baggage (e.g. Rel http://dbappbuilder.sourceforge.net/Rel.php) that I don't need. * Is there a Clojure implementation of something like Tutorial D? If there is no implementation of anything that meets my requirements then I would be willing to look at the possibility of creating a Domain Specific language. However, I am wary of launching straight into that because of the probability that anything I dreamed up would be an ad hoc kludge rather than a semantically complete and consistent language. Optimised execution would be a whole other can of worms. * Does anyone know of any DSLs/formalisms for declaratively specifying relational data aggregations? Thanks Ross This sounds very similar to NoSQL and Map/Reduce? http://www.basho.com/Riak.html Where your predicate is a reduce fn? -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
functions left over in the vm
How are other people handling the process of reducing code in their projects? Situation: We've built a product, very rapidly thanks to being able to produce stuff very quickly in clojure. However now that it is somewhat settled I'm in the process of paring down the code, removing defunct fn's, etc. Problem: You compile your code, you test it, you pare down some functions or rename a function and push that into the VM - hit refresh, everything works. However there is a chance you are actually using a function which you have removed from the source code. i.e. you missed a reference in another file or something similar. Most recently I removed a pointless wrapper fn around another fn, however the wrapped fn was declared private. Everything seemed to be working until I compiled the source and found out that my fn's were calling the wrappee which was still in scope within the VM . I've now started to use lein uberjar to point out cases that I'm doing this - and it's fine for now, however it is a bit of a throwback to the pains of Java development. Another solution I've been using is to regularly restart my running clojure instance, however this has the annoyance of me losing all my locally defined vars during dev. Thanks for any suggestions on 'dev best practices' in this space. Cheers, mike -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: thinking in clojure
On Thu, Sep 16, 2010 at 07:53, Laurent PETIT laurent.pe...@gmail.com wrote: 2010/9/16 Meikel Brandmeyer m...@kotka.de Hi Laurent, On 16 Sep., 15:54, Laurent PETIT laurent.pe...@gmail.com wrote: you don't like my one-liner ? :-) I saw your message only after I sent mine. :) (update-in coll [k] (fnil update-in *default-value*) [:meetings] (comp vec concat) data) Hmm... (comp vec concat) == into? Yep. so this is the killer one : :-) (update-in coll [k] (fnil update-in *default-value*) [:meetings] into data) Awesome, thank you for returning concision to my code! I'd certainly missed the update-in, and related, functions. Cheers Laurent! -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: thinking in clojure
(loop [data (sorted-map) collection newData meeting (first collection)] (def key ( )) As a general rule, def should only be used at the top level. You probably want (let [key ...] (if ...) here. Hey, thanks for pointing this out - I was actually just trying to avoid passing these values in the loop signature. Your point is very well taken and I've now replaced those (def)'s with a let inside the loop. (if (not (nil? (next collection) Minor nit: (not (nil? X)) is better spelled (seq? X)) Right! That's actually a standard idiom, except you missed the assoc-in and get-in functions: (assoc-in data key :meetings (conj (get-in data key :meetings) meeting) Thanks for the advice. I've taken Laurent's feedback and ended up with: (update-in data [week-difference] (fnil update-in (struct week title [])) [meetings] into [decorated]) Which certainly reads far better than what I had. Thanks for pointing out get-in, another *key* fn I've missed. The standard library is rather large, I guess this'll take a while. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: thinking in clojure
Meikel, (recur (cond (not (nil? (data key))) (true? true) *ieeck* Please do (cond ... :else default-clause). Not true, or (true? true) or other stuff. Wow, I somehow missed the :else option in cond? I've got that (true? true) stuff scattered all over my code - going to change that right now. Thanks for showing me this. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: thinking in clojure
On Fri, Sep 17, 2010 at 08:58, Michael Wood esiot...@gmail.com wrote: On 17 September 2010 00:56, Michael Ossareh ossa...@gmail.com wrote: Meikel, (recur (cond (not (nil? (data key))) (true? true) *ieeck* Please do (cond ... :else default-clause). Not true, or (true? true) or other stuff. Wow, I somehow missed the :else option in cond? I've got that (true? true) stuff scattered all over my code - going to change that right now. Thanks for showing me this. It's not actually an :else option in cond. Anything that is not false or nil can work there, so :any-arb-keyword would work just as well as :else. But by convention, Clojure programmers tend to use :else. Thanks for confirming my thoughts, Michael. Indeed I immediately checked the docs and couldn't find :else referenced. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
thinking in clojure
Hi Guys, One of the things that has struck me about clojure, by virtue of being a lisp, is the concision of the code - I really find it very attractive. However yesterday I found something that I couldn't work out how to do in a concise manner. Clearly commenting the code was a priority once I got it working, however I'd like to ensure I'm doing this correctly. Much of my functional experience comes from JS and dealing with the immutability of our data structures is a very interesting learning process. I have a map (a sorted map) which maps an int to a map. The inner map contains a vector of data to which I want to conj elements into. { 0 {:title some str :meetings [{ ... meeting data ... } { ... meeting data ... } { ... meeting data ...}]} 1 {:title some other str :meetings [{ ... meeting data ... } { ... meeting data ... } { ... meeting data ...}]} . n {:title some n str :meetings [{ ... meeting data ... } { ... meeting data ... } { ... meeting data ...}]}} In JS I'd have a loop which looks somewhat like this (assume the data above is called storedData and that newData has the data which I wish to insert into storedData); newData.forEach(function(data) { var key = ; if (!storedData[key]) storedData[key] = {title: title}, meetings:[]} storedData[key].meetings.push(data) ; }) In clj, I've ended up with something along the lines of the following (edited from what I have in my code base to match the JS example above): (loop [data (sorted-map) collection newData meeting (first collection)] (def key ( )) (if (not (nil? (next collection) (recur (cond (not (nil? (data key))) (assoc data key (assoc (data key) :meetings (conj ((data key) :meetings) meeting))) (true? true) (conj data [key {:title some str :meetings [meeting]}]))) data)) The middle section, with the assoc(es) and conj, just doesn't read as nicely as the rest of my clojure. Is this a symptom of my data structure or is there a more concise way to conj my data into these inner vectors? Also, as a secondary concern, I read on here a while ago that when you find yourself typing (( it's a sign of an issue - how, given the data structure I've to work with, woud you access the title of a value if not using that (( syntax, i.e. ((data key) :title)? Cheers, mike -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
var args
Hi, I don't fully understand how to make real use of varargs and destructuring. c.c.sql/create-table is defined as follows: (create-table name specs) Called as follows: (c.c.sql/create-table :tblname [:cola :text NOT NULL PRIMARY KEY] [:colb :number NOT NULL] [:colc :blob NOT NULL)] I want to store my table definitions in a data structure (I'm open to which one) such that I can get access to table names later on. However if I store the definitions in a vector which each element is a vector of arguments to create-table I'm not able to pass the correct arguments to create-table. An example of the data structure: (def schema [[:users [:id :text PRIMARY KEY NOT NULL] [:domain :text NOT NULL] [:email :text :unique NOT NULL] [:password :text NOT NULL] [:name :text NOT NULL] [:created :bigint NOT NULL] [:last_login :bigint]] [:user_token [:token :text :unique PRIMARY KEY NOT NULL] [:user_id :text NOT NULL REFERENCES users(id) ON DELETE CASCADE] [:client :text NOT NULL] [:created :bigint NOT NULL] [:last_used :bigint]]]) (defn x [a b] (prn (str a: a)) (prn (str b: b))) (map (fn [y] (x (first y) (rest y))) schema) results in: (a: :users b: (([:id :text \PRIMARY KEY\ \NOT NULL\] [:domain :text \NOT NULL\] [:email :text :unique \NOT NULL\] [:password :text \NOT NULL\] [:name :text \NOT NULL\] [:created :bigint \NOT NULL\] [:last_login :bigint])) a: :user_token b: (([:token :text :unique \PRIMARY KEY\ \NOT NULL\] [:user_id :text \NOT NULL\ \REFERENCES users(id) ON DELETE CASCADE\] [:client :text \NOT NULL\] [:created :bigint \NOT NULL\] [:last_used :bigint]))) if I call create-table instead of `x` it gets two arguments, (first y) and a vector containing the elements in (rest y) instead of (first y) and each of the elements in (rest y). How is it possible for me to flatten b such that when passed to c.c.sql/create-table its fn arguments are satisfied? I feel like partial need to be used, however I haven't been able to figure it out. Any help much appreciated! Cheers, mike -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: var args
Alan and Patrick, thank you so much! I've come across apply in JS and it really should have clicked for me! So I have the following, and it works very well: (defn make-tables [connection schema] (sql/with-connection connection (doseq [[name specs] schema] (try (apply sql/create-table name specs) (catch Exception e (prn e)) Cheers! mike p.s. I love this community! -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: A difficult Metaphor for Macros (especially for Java people)
On Wed, Sep 8, 2010 at 08:17, CuppoJava patrickli_2...@hotmail.com wrote: Ah I see. Yes, motivation is hard. I don't have any good tips for that. I'm still a noob at the evangelising part of Lisp! However, when it comes to clojure, I tell Java people it's a better way of writing Java than Java; it gives you all the things experienced Java programmers wish Java had: + try the cast, compiler, just trust me on this one + must I really declare that to be thrown? When I don't please just treat it like a RuntimeException! + no write, save, compile loop - REPL's are amazing + concise object literals for the common data structures, list, maps, etc. are amongst a few of my favoured lines. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: JSON lib of choice?
On Mon, Sep 6, 2010 at 19:50, Wilson MacGyver wmacgy...@gmail.com wrote: I figure enough time has passed that I want to bring this up again. For JSON, are you using clojure.contrib.json or clj-json? Why? We use org.danlarkin.json, because it encodes and decodes (contrib.json didn't when we made our decision) and it was the first hit in the google listings for clojure json. If anyone gets around to doing some real world perf analysis and there is a significant winner then we may switch. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Thinking in Clojure
On Thu, Sep 2, 2010 at 21:05, Miki miki.teb...@gmail.com wrote: I'd go over SICP, though it not in Clojure but in Scheme - it will show you how to think functional. +1 on this. http://mitpress.mit.edu/sicp/ -- !new number! 415-400-6772 -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Web Development - templating?
I highly recommend using Google Closure Templates. Clojure's java interop lets you script up creating a page from the soy files very efficiently and quickly (yay clojure!!). Also the fact that you can run the templates on the server and client mean if your idea scales up you can XHR data to and from the browser and get exactly the same rendering results. (defn meetings Draws the header of our page [data] (let [sfsb (SoyFileSet$Builder.)] (.. sfsb (add (File. src/soy/header.soy)) (build) (compileToJavaObj) (render rah.dom.preamble data nil This builds an entire dom for us on each request which means development is super fast. On Wed, Sep 1, 2010 at 10:07, Greg g...@kinostudios.com wrote: You might be interested in this this project: http://github.com/brool/gulliver See this blog post for more info: http://www.brool.com/index.php/a-modest-proposal It's essentially PHP-ified web development for Clojure. - Greg On Sep 1, 2010, at 12:24 AM, Sean Corfield wrote: On Wed, Sep 1, 2010 at 12:16 AM, Meikel Brandmeyer m...@kotka.de wrote: I have good experiences with enlive[1]. There you write your templates in normal HTML files and modify them from Clojure via CSS-style selectors. That's pretty horrible. I guess I've been spoiled with CFML as a templating language :( Maybe I'll end up writing my own templating engine for Clojure... sigh... -- Sean A Corfield -- (904) 302-SEAN Railo Technologies, Inc. -- http://getrailo.com/ An Architect's View -- http://corfield.org/ If you're not annoying somebody, you're not really alive. -- Margaret Atwood -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- !new number! 415-400-6772 -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Installing Clojure on OS X
On Tue, Aug 17, 2010 at 07:59, HB hubaghd...@gmail.com wrote: Hey, How to install Clojure on Mac OS X? I wrote this pre 1.2: https://docs.google.com/Doc?docid=0AW2Ojyy-IGoHZGR0c256dmZfNTRjenBoYnBjaAhl=en There are likely a few changes needed but a cursory glance and it mostly looks right. In summary - use emacsformacosx.com and the elpa install and run your projects through lein swank and you're good to go. -- 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 post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en