Re: [ANN] cljzmq-0.1.1 - A Clojure binding for ØMQ
Here is a simple way to send and receive Clojure data over ØMQ: https://gist.github.com/trevorbernard/6118918 On Monday, July 29, 2013 10:00:13 AM UTC-3, Trevor Bernard wrote: Hello, I'd like to announce the immediate availability of cljzmq-0.1.1 on maven central. https://github.com/zeromq/cljzmq For sample usage, I've started porting the zguide examples here: https://github.com/trevorbernard/cljzmq-examples Pull requests welcome! Warmest regards, Trev -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[ANN] cljzmq-0.1.1 - A Clojure binding for ØMQ
Hello, I'd like to announce the immediate availability of cljzmq-0.1.1 on maven central. https://github.com/zeromq/cljzmq For sample usage, I've started porting the zguide examples here: https://github.com/trevorbernard/cljzmq-examples Pull requests welcome! Warmest regards, Trev -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Jenkins/leiningen trigger build when a snapshot gets updated
Hi, Does there exist a Hudson/Jenkins plugin for leiningen to trigger a build when a SNAPSHOT dependency gets updated? Warmest regards, Trevor -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Understanding boxing
If you want to be 100% sure, AOT-compile your code and look at the emitted Java classes with `javap`. Some observations I found about autoboxing and Clojure. If you typehint a deftype/defrecord with a primitive, the generated class will store it as it's primitive type but this is not the case with primitive arrays. It will store it as an Object. But do you own verification to be sure. -Trev -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[ANN] phaser-1.1.2 - A Clojure DSL for the LMAX Disruptor 3.0.1
I'd like to officially announce the immediate availability of Phaser, a Clojure DSL for the LMAX Disruptor 3.0.1. https://github.com/userevents/phaser Pull requests welcome! -Trev -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Clojurescript One and Websockets
Any updates Kushal Pisavadia on Websockets and Ring jiving? On Monday, March 19, 2012 9:40:20 AM UTC-3, Kushal Pisavadia wrote: I am in discussion with James, but it's very high-level at the moment and no work has been done on integration yet. I don't think it'll get into the next tagged release of Ring (1.1) in time, as that's likely to be released fairly soon once the current set of issues are cleared up. On 19 March 2012 12:19, Jay Fields j...@jayfields.com wrote: I'm not involved (much) with Webbit other than using it in prod for my web socket stuff. I believe Kushal Pisavadia (cc'd) James Reeves have been talking about webbit features that Ring could leverage, but I'm not familiar with the details. Cheers, Jay On Sat, Mar 17, 2012 at 7:23 PM, Brian Rowe bripr...@gmail.com wrote: Hey Jay, Are there any plans to make a ring adapter for webbit? On Friday, March 2, 2012 6:40:27 AM UTC-5, Jay Fields wrote: clojure + web sockets, not using aleph: http://blog.jayfields.com/2011/02/clojure-web-socket-introduction.html On Mar 1, 2012, at 10:51 PM, Brian Rowe wrote: Hi, I'm thinking about using clojurescript one a starting point for a web game. I would like to use websockets as the primary communication mechanism between the browser and the server. As far as I know Zack Tellman's Aleph is the only clojure web server that supports websockets. Is this true? If so, are there any guides showing how to modify clojurescript one to use Aleph? If there are no guides, how much work would it take to modify cljs one to use aleph? 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 -- 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
ClojureScript: Problem with - macro and many arguments
I'm not sure if this is a problem with Safari/WebKit or ClojureScript (or neither, maybe this is expected behavior). I implemented the game logic of my Tempest game by threading a game state structure through a long series of functions with the - macro. At some point during development, it stopped working in Safari. By stopped working, I mean loading it spikes memory usage up to insane levels, makes OS X unusable from all the swapfile thrashing, and makes Safari stop responding entirely. It also crashes MobileSafari on iOS, causing them to force-quit. I just did a little debugging to figure it out, and discovered it seems to be caused by having too many arguments to the - macro. Commenting out *any* 6 of my... many more than 6 functions made it start working again. I discovered that it runs just fine in Safari if I break the function list across multiple threading macros. See this diffhttps://github.com/mrmekon/tempest-cljs/commit/9a2ef9d57c2faa01f9d4d8883982231a7ffc90ea#diff-1for the fix. It now runs in Safari again, and in MobileSafari (miserably -- but that is expected.) Is there any reason to expect this behavior, or is this a bug? -- 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: I'm writing a Tempest clone in ClojureScript
That's in my TODO list... seems that the Google Closure keyboard handler just doesn't two keys at once, so key handling eventually has to be managed some other way. For now, playing makes a terrible racket :) On Saturday, April 7, 2012 7:45:32 PM UTC-4, David Nolen wrote: Fun! Would be nice if you could move and fire at the same time :) -- 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: I'm writing a Tempest clone in ClojureScript
Greetings! Tempest (in ClojureScript) has come a long way in the last couple of weeks. A playable demo is now up: Play Tempest-cljs http://mrmekon.github.com/tempest-cljs/level1.html Best results with Chrome. Left and Right to move, spacebar shoots. It's legitimately playable now, though there's not much polish to it yet. Only one kind of enemy so far, flippers, but they're functionally complete. You can get shot or captured, which restarts the current level, or you can kill all of the enemies and move forward a level. There are 7 levels right now, and if you beat the 7th, you are greeted with a friendly black screen. -Trevor On Thursday, March 22, 2012 8:14:25 PM UTC-4, Trevor Bentley wrote: I'm teaching myself Clojure/ClojureScript/HTML5 via an excessively complex first project: a clone of the arcade game Tempest. I thought it might be a handy resource to share since I've found surprisingly few ClojureScript examples. More certainly couldn't hurt. https://github.com/mrmekon/tempest-cljs The game is nowhere close to done, but there's some functional drawing and movement code. Collision detection is about the only thing left before it qualifies as a game, albeit a terrible, unfinished one. It isn't currently hosted anywhere, so you'll have to run it yourself, or make do with the screenshots. I have 6 levels, one kind of enemy, and the player ship moves and shoots. Level design is the most interesting part -- I wrote some level-generating code, so certain types of levels can be generated very easily. ClojureScript has been surprisingly solid and easy to work with. I was considering using it for a startup I'm working with, and this project has done nothing to dissuade me. -Trevor -- 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
I'm writing a Tempest clone in ClojureScript
I'm teaching myself Clojure/ClojureScript/HTML5 via an excessively complex first project: a clone of the arcade game Tempest. I thought it might be a handy resource to share since I've found surprisingly few ClojureScript examples. More certainly couldn't hurt. https://github.com/mrmekon/tempest-cljs The game is nowhere close to done, but there's some functional drawing and movement code. Collision detection is about the only thing left before it qualifies as a game, albeit a terrible, unfinished one. It isn't currently hosted anywhere, so you'll have to run it yourself, or make do with the screenshots. I have 6 levels, one kind of enemy, and the player ship moves and shoots. Level design is the most interesting part -- I wrote some level-generating code, so certain types of levels can be generated very easily. ClojureScript has been surprisingly solid and easy to work with. I was considering using it for a startup I'm working with, and this project has done nothing to dissuade me. -Trevor -- 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: macro question
That works - thanks. Still, it seems intuitive to build the code as I had originally done. It's too bad code has to get complicated so quickly :) Thank again for the help. On Jan 3, 9:19 pm, Robert Marianski r...@marianski.com wrote: On Tue, Jan 03, 2012 at 07:22:22PM -0800, Trevor wrote: hmmm macro question: ; here's a macro that assembles many puts. It serves no purpose to me (and doesn't even make sense in its current form). It's just something I hit playing around and learning macros. (defmacro doto-putter [x y xs] `(doto (java.util.HashMap.) (.put ~x ~y) ~@(for [[k v] xs]`(.put ~k ~v user= (doto-putter c 3 {a 1 b 2}) #HashMap {b=2, c=3, a=1} however: =(defn omg [x y xs](doto-putter x y xs)) CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:2) I'm thinking the issue seems to be that it's not resolving xs because this works: (defmacro doto-putter [x y] `(doto (java.util.HashMap.) (.put ~x ~y) ~@(for [[k v]{a 1 b 2}]`(.put ~k ~v user= (defn omg [x y](doto-putter x y)) #'user/omg user=(omg c 3) #HashMap {b=2, c=3, a=1} what am I missing? None of my other macros have this problem. Keep in mind that you are trying to iterate through xs at compile time. All you have at that point is a symbol, so effectively you are trying this: (for [[k v] 'xs] ...) That's why you are getting the error above; you are trying to iterate through a symbol. There isn't a way around this, because it's impossible to know the keys/values at compile time. What you need to do instead is generate the code to iterate through the map instead of actually iterating through at compile time. Something like this: (defmacro doto-putter [x y xs] `(let [h# (java.util.HashMap.)] (.put h# ~x ~y) (dorun (for [[k# v#] ~xs] (.put h# k# v#))) h#)) Hope that helps, Robert -- 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
macro question
hmmm macro question: ; here's a macro that assembles many puts. It serves no purpose to me (and doesn't even make sense in its current form). It's just something I hit playing around and learning macros. (defmacro doto-putter [x y xs] `(doto (java.util.HashMap.) (.put ~x ~y) ~@(for [[k v] xs]`(.put ~k ~v user= (doto-putter c 3 {a 1 b 2}) #HashMap {b=2, c=3, a=1} however: =(defn omg [x y xs](doto-putter x y xs)) CompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:2) I'm thinking the issue seems to be that it's not resolving xs because this works: (defmacro doto-putter [x y] `(doto (java.util.HashMap.) (.put ~x ~y) ~@(for [[k v]{a 1 b 2}]`(.put ~k ~v user= (defn omg [x y](doto-putter x y)) #'user/omg user=(omg c 3) #HashMap {b=2, c=3, a=1} what am I missing? None of my other macros have this problem. -- 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: How to: convert output stream into an input stream
This is great. Thanks for the help. On Dec 16, 2:55 am, Alan Malloy a...@malloys.org wrote: Edit: you should probably use with-open at some point, to make sure you close the output writer. I copied pretty badly from my own example :P. So more like: (let [pipe-in (PipedInputStream.)] (future ; new thread to prevent blocking deadlock (with-open [out (- pipe-in (PipedOutputStream.) (PrintWriter.))] (binding [*out* out] (do-whatever pipe-in) On Dec 16, 1:49 am, Alan Malloy a...@malloys.org wrote: You can't really do this in a single thread without risking blocking. But with another thread, it's fairly simple. For example, I do this in my gzip-middleware, copying an InputStream through a pipe with GZIP wrapping:https://github.com/amalloy/ring-gzip-middleware/blob/master/src/ring/... I'm turning an input stream into another input stream, but you can do something similar. It's a bit weird, because you're really *not* attempting to convert an outputstream to an inputstream in your example. You're calling a function that writes to stdout and returns nil, and hoping that somehow a stream gets created. Really using with- out-str is a reasonable approach here; just create a StringReader from the resulting string. But if you need asynchronicity, you can probably do something like (let [pipe-in (PipedInputStream.) pipe-out (PipedOutputStream. pipe-in)] (future ; new thread to prevent blocking deadlock (binding [*out* (PrintWriter. pipe-out)] (ofn var))) pipe-in) This lets ofn run in another thread, writing its output to *out*, which passes through the pipe and becomes an input stream for ring to use. On Dec 15, 1:01 pm, Trevor tcr1...@gmail.com wrote: I have created an output stream, which appears to work fine, however I get an error when trying to convert the output stream into an input stream for use in ring: ('use [clojure.java.io :only [input-stream]]) = (with-out-str (ofn var)) it works! Now when I use ring: {:body (input-stream (ofn var))} java.lang.IllegalArgumentException: No implementation of method: :make- input-stream of protocol: #'clojure.java.io/IOFactory found for class: nil Is there something special I need to do to convert output stream into an input stream ? Thanks, Trevor -- 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
How to: convert output stream into an input stream
I have created an output stream, which appears to work fine, however I get an error when trying to convert the output stream into an input stream for use in ring: ('use [clojure.java.io :only [input-stream]]) = (with-out-str (ofn var)) it works! Now when I use ring: {:body (input-stream (ofn var))} java.lang.IllegalArgumentException: No implementation of method: :make- input-stream of protocol: #'clojure.java.io/IOFactory found for class: nil Is there something special I need to do to convert output stream into an input stream ? Thanks, Trevor -- 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: N00b alert! - A question on immutable/mutable data structures...
ahh,... I see. Thank you all - you've been very helpful. Trevor On Sep 14, 12:31 am, Stuart Campbell stu...@harto.org wrote: I knew there must be a nicer way to write that :) On 14 September 2011 16:22, Meikel Brandmeyer (kotarak) m...@kotka.de wrote: Or: (swap! user-queues update-in [k] (fnil conj clojure.lang.PersistentQueue/EMPTY) v) 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.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
N00b alert! - A question on immutable/mutable data structures...
For the most part, I *believe* I understand why immutable data structures with transactions are important to manage concurrent operations to shared data, but I often wonder why it matters in some cases... For example, what if I have a hash-map that needs to handle concurrent changes to the data structure, but never needs to have concurrent changes to a given piece of data (i.e a key/value pair). Wouldn't there be value in being able to modify the data in-place without making a copy, or needing to endure the overhead associated with STM? And if what I am suggesting is reasonable how can I create a mutable hash-map in Clojure and still use (mostly) the same access functions. Notes: * Yes, I have watched Rich's video on identity and state, but it hasn't helped my understand the above scenario. * I am not suggesting a hash-map data structure should support mixed operations. Thanks, Trevor -- 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: N00b alert! - A question on immutable/mutable data structures...
Thanks for the quick responses. I'll try to answer Andy's question: How do you know, in advance, that it doesn't need to handle such concurrent changes? ... and at the same time I will try to provide this example to Stuart, hoping I can see how using a map inside an atom might work: Let's say my users log into a web page and each user has a queue that does stuff for them. Since the users id is unique and each user can only be logged in from one session, when I use the user id as a key within a hash-map then I know *well-enough* there will not be any concurrent changes to that key value pair, particularly since enqueing means each change is actually an just addition to the stack. -- So I am picking queue's to make a point... -- Queue's are chosen over lists as they are both constant time and fast. Being atomic is great, but wouldn't making a copy of a queue and re-assembling it defeat the purpose of using it? So let's try this: (def user-queues* (atom (hash-map))) #'project/user-queues* (swap! user-queues* assoc user1 clojure.lang.PersistentQueue/EMPTY) {user1 #PersistentQueue clojure.lang.PersistentQueue@0} (@user-queues* user1) #PersistentQueue clojure.lang.PersistentQueue@0 I would like to add an item to the users queue, but it seems when using an atom I can only swap in and out the value as opposed to modifying the value in-place. So let's start with just the basic atom'd queue: (def q (atom clojure.lang.PersistentQueue/EMPTY)) #'project/q (swap! q conj (seconds)) #PersistentQueue clojure.lang.PersistentQueue@d3232253 (apply list (swap! q conj (seconds))) (1315961557 1315961570) awesome. Now I want to store each users queue in the user-queues* hash-map. How would I do that while maintaining a real queue? My initial attempts always lead to reading the full queue into a list, then to conj and item on that list, then I have to remake a queue to then be stored back into the map via swapso it's at that point I might as well not be using a queue - right? Certainly hash-maps with queue's would be a reasonable idea - right?. 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: Clojure job scheduler
That works it's really easy to use - Thanks. On Jan 9, 9:22 am, Patrik Fredriksson patri...@gmail.com wrote: I have used cron4j in a small project, it's like a more lightweight version of Quartz and fits nicely with Clojure:http://www.sauronsoftware.it/projects/cron4j/ Code example here:https://gist.github.com/388555 /Patrik On Jan 8, 8:37 pm, Trevor tcr1...@gmail.com wrote: Thanks, everyone for all you help. I noticed a few questions I should answer. re: email option: I really just planned on sending a gmail to indicate the job succeeded or failed. Being somewhat new to programming the straightest path, for me, would be using clojure code (I'm not a network guru, so for me it's grab a library and use use it). re: webapp status: The job I want to run is really 3 jobs bundled in one (they need not all run, but they at least need to run sequentially if they do). So when I see an email notifying the fail, I will use the web app to determine if #1, #2 or #3 failed. If #1 failed, then I can trigger 2 and 3. I want this to be a eyeball decision, not a programmatic one. Really, I just don't like cron jobs. I'd rather stay with in clojure if I can where I'm comfortable that I'm not somehow pooching the system, plus it just seems like something a language ought to be able to do. I noticed a point made about not having to deal with OS differences, which while not an immediate problem for me, is still noteworthy. At some point I'd like to distribute my code, and not leave that burden to others. I'm leaning towards just building my own, testing it out (learn more this way). I looked at the function gaz, provided, but it didn't seem like what I would implement, but I may end up there. If that fails I will probably use quartz-scheduler. Once again - thank you for all the replies. On Jan 8, 6:14 am, Ken Wesson kwess...@gmail.com wrote: On Sat, Jan 8, 2011 at 12:04 AM, Michael Gardner gardne...@gmail.com wrote: On Jan 7, 2011, at 9:19 PM, Ken Wesson wrote: On the other hand, running a job scheduler from outside Clojure results in cranking up a big, slow to start up, expensive JVM process every single time a task needs to run, each of which runs one task once, and the scheduling itself must be done in an icky language like shell or cron's idiosyncratic crontab files with icky error reporting (e.g., need to run a local mail *server* to receive error notifications). If you care about startup times, you can use nailgun. But that shouldn't matter unless you're running the job every minute or something. Obviously, that requires knowing about, and learning how to use, nailgun. Solutions with a higher cost in novel-tools-you-have-to-figure-out-how-to-use are not, all other things being equal, superior ones. As for scheduling, crontabs are really not hard to figure out. If you need more complex scheduling, you can do that from your Clojure script (essentially using cron to set the polling interval). If you're going to do that anyway, you might as well do the whole thing from inside Clojure. And what kinds of error reporting could you do from a persistent daemon that you couldn't also do from a cron job? Besides, most systems that have cron also come with postfix (though it's disabled by default on Mac OS X), so all you have to do is add your email address to /etc/aliases. Email-based error reporting for background tasks is really nice because you don't have to remember to check some log file or other task-specific status indicator periodically (which has burned me in the past). Well, both Windows and MacOS have variations on the nifty concept of tray notification. But this is all somewhat beside the point. What Trevor said sounded as though the specific types of tasks he mentioned (sending emails and checking some kind of status via web app) were particularly unsuited to scheduled jobs; I was asking what it was about those tasks in particular that made him lean towards a daemon instead. Maybe he needs timely responses to something, so something more akin to a web server than a periodically-run job? -- 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 job scheduler
Thanks, everyone for all you help. I noticed a few questions I should answer. re: email option: I really just planned on sending a gmail to indicate the job succeeded or failed. Being somewhat new to programming the straightest path, for me, would be using clojure code (I'm not a network guru, so for me it's grab a library and use use it). re: webapp status: The job I want to run is really 3 jobs bundled in one (they need not all run, but they at least need to run sequentially if they do). So when I see an email notifying the fail, I will use the web app to determine if #1, #2 or #3 failed. If #1 failed, then I can trigger 2 and 3. I want this to be a eyeball decision, not a programmatic one. Really, I just don't like cron jobs. I'd rather stay with in clojure if I can where I'm comfortable that I'm not somehow pooching the system, plus it just seems like something a language ought to be able to do. I noticed a point made about not having to deal with OS differences, which while not an immediate problem for me, is still noteworthy. At some point I'd like to distribute my code, and not leave that burden to others. I'm leaning towards just building my own, testing it out (learn more this way). I looked at the function gaz, provided, but it didn't seem like what I would implement, but I may end up there. If that fails I will probably use quartz-scheduler. Once again - thank you for all the replies. On Jan 8, 6:14 am, Ken Wesson kwess...@gmail.com wrote: On Sat, Jan 8, 2011 at 12:04 AM, Michael Gardner gardne...@gmail.com wrote: On Jan 7, 2011, at 9:19 PM, Ken Wesson wrote: On the other hand, running a job scheduler from outside Clojure results in cranking up a big, slow to start up, expensive JVM process every single time a task needs to run, each of which runs one task once, and the scheduling itself must be done in an icky language like shell or cron's idiosyncratic crontab files with icky error reporting (e.g., need to run a local mail *server* to receive error notifications). If you care about startup times, you can use nailgun. But that shouldn't matter unless you're running the job every minute or something. Obviously, that requires knowing about, and learning how to use, nailgun. Solutions with a higher cost in novel-tools-you-have-to-figure-out-how-to-use are not, all other things being equal, superior ones. As for scheduling, crontabs are really not hard to figure out. If you need more complex scheduling, you can do that from your Clojure script (essentially using cron to set the polling interval). If you're going to do that anyway, you might as well do the whole thing from inside Clojure. And what kinds of error reporting could you do from a persistent daemon that you couldn't also do from a cron job? Besides, most systems that have cron also come with postfix (though it's disabled by default on Mac OS X), so all you have to do is add your email address to /etc/aliases. Email-based error reporting for background tasks is really nice because you don't have to remember to check some log file or other task-specific status indicator periodically (which has burned me in the past). Well, both Windows and MacOS have variations on the nifty concept of tray notification. But this is all somewhat beside the point. What Trevor said sounded as though the specific types of tasks he mentioned (sending emails and checking some kind of status via web app) were particularly unsuited to scheduled jobs; I was asking what it was about those tasks in particular that made him lean towards a daemon instead. Maybe he needs timely responses to something, so something more akin to a web server than a periodically-run job? -- 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
Clojure job scheduler
What's the best way to kick off Clojure code at scheduled times? I have some that would run once a day. Some that might run 2 or 3 times a day based upon a test being met. 1. I could write a function that sleeps an interval, check the time differential to perform a time-box triggered function, but would that consume too much memory?, cause long term problems? 2. I could use quartz, but that seems like overkill. 3. I could set a job-schedule using the OS to run a clojure script. I'd rather not, I would like to do things like send emails / check status via web app (making option 1 more appealing). I'm looking for input/guidance. What are your experiences? 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
name protect anonymous macros ?
n00b questions :) 1. How do I create a function and/or a macro that accepts an unbound name and interprets that name as a symbol? example: (defn perpetuate [name args] (do-stuff-with name args) (println name)) = (perpetuate world arg1 arg2) world this may seem silly or non-idiomatic, but really for specific functions (and more likely macros) I don't want to have to protect the name for it to be interpreted as a symbol. This is simply to accommodate my personal, good or bad, behaviors. 2. Is there a form for anonymous macros? i.e. I know I can do : (fn[x](do x)), but can I not do: (macro[x](let [x# x] `(do x))) ? 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: name protect anonymous macros ?
Thanks for responding, but I know all this. 1. I know how to pass string and symbols into functions and I know how to coerce. 2. I don't want to bind the name, I want to interpret the name as a symbol, thus - (defmacro baz [x y] `(def x y)), is not useful. 3. CL has anonymous macros, so why do you think CL has them - because they're not useful? On Dec 17, 9:31 am, Ken Wesson kwess...@gmail.com wrote: On Fri, Dec 17, 2010 at 10:54 AM, Trevor tcr1...@gmail.com wrote: n00b questions :) 1. How do I create a function and/or a macro that accepts an unbound name and interprets that name as a symbol? Function: (defn foo [x] (println x)) user=(foo 'quux) quux nil user= (defn bar [x] (do-something-with (symbol x))) user= (bar quux) ; whatever user= (defmacro baz [x y] `(def x y)) user= (baz quux 42) #'user/quux user= quux 42 this may seem silly or non-idiomatic, but really for specific functions (and more likely macros) I don't want to have to protect the name for it to be interpreted as a symbol. This is simply to accommodate my personal, good or bad, behaviors. If you mean you don't want to have to quote it, well, macro arguments aren't evaluated during macro expansion so you can generally pass unquoted symbols to macros. In fact you do so whenever you use defn. With function arguments, you need to quote a symbol to pass a symbol, or else pass a string the function will convert by using (symbol x) on it. 2. Is there a form for anonymous macros? Nope. I'm not sure why you'd want one, either. -- 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: name protect anonymous macros ?
ahhh - thank you! On Dec 17, 1:23 pm, Armando Blancas armando_blan...@yahoo.com wrote: 2. I don't want to bind the name, I want to interpret the name as a symbol user= (defmacro perpetuate [name] `(let [q# (quote ~name)] (println q#) q#)) #'user/perpetuate user= (class (perpetuate somename)) somename clojure.lang.Symbol -- 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: name protect anonymous macros ?
Lol.You're correct - it's so easy i don't know why I didn't see it. I'm somewhat new to macros. That said - I thought my question was clearly stated: How do I create a function and/or a macro that accepts an unbound name and interprets that name as a symbol? On Dec 17, 1:35 pm, Ken Wesson kwess...@gmail.com wrote: On Fri, Dec 17, 2010 at 3:26 PM, Trevor tcr1...@gmail.com wrote: ahhh - thank you! On Dec 17, 1:23 pm, Armando Blancas armando_blan...@yahoo.com wrote: 2. I don't want to bind the name, I want to interpret the name as a symbol user= (defmacro perpetuate [name] `(let [q# (quote ~name)] (println q#) q#)) #'user/perpetuate user= (class (perpetuate somename)) somename clojure.lang.Symbol Is *that* all you wanted? A version of (quote x) that printed out its argument as well as evaluating to a symbol? Well why didn't you just *say* so? -- 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: Saving the Clojure.org webiste
I haven't personally tried it on clojure.org, but wget -m tends to work well for this kind of task. Trevor Kei Suzuki wrote: I wanted to save the Clojure.org website so that I can read it when I'm off-line. The problem is that none of the website downloader tools I found is satisfactory; the pages don't look right and links are broken (I think I know now why they don't work by looking into the html and css files of the website). So I wrote a downloader in Clojure. It's a bit slow and inefficient (but I don't care). Besides it depends on the way the website is written and organized. But it does what I want, so I'm happy...until the website changes radically. I'll upload the code to the Clojure Google Groups file area. The file name is save_clojure.org.tar.bz2. Hope you find it useful too. --~--~-~--~~~---~--~~ 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 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: list vs vector
Remember clojure, like other lisps, is homoiconic: the program code itself is clojure data. Lists are very common in clojure, since a list is is used in the function invocation syntax, e.g. (inc 0). Otherwise, used as a general purpose lists have the same benefits of linked lists over arrays that they would in any other programming language: O(1) insertion at the head, O(1) deletion, etc. Trevor On Fri, May 15, 2009 at 3:36 PM, Vagif Verdi vagif.ve...@gmail.com wrote: What are the use case scenarios where one is preferable to the other in clojure ? It looks to me like vectors almost completely overtake lists for all purposes. --~--~-~--~~~---~--~~ 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 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: Override the + operator for a 'struct'
One way to accomplish this is via :refer-clojure in ns. Usage is like: (ns test (:refer-clojure :exclude [+])) This would allow you to, for example, dispatch the implementation based on the type of the first argument via multimethods (as Michel S. noted, at a performance penalty). The original implementation of + is still available as clojure.core/+. For example, you could define + for complex numbers (as a contrived example) by switching on the class of the first element, using a custom adding routing for complex numbers when the first element is a struct instance, and falling back on clojure.core/+ otherwise. (defstruct complex :real :imaginary) (defmulti + (fn [ args] (class (first args (defmethod + clojure.lang.PersistentStructMap [ more] (letfn [(add-complex [{x-real :real x-imaginary :imaginary} {y-real :real y-imaginary :imaginary}] (struct-map complex :real (clojure.core/+ x-real y-real) :imaginary (clojure.core/+ x-imaginary y-imaginary)))] (reduce add-complex more))) (defmethod + :default [ more] (apply clojure.core/+ more)) Example usage would be: (println (+ 1 2 3)) ; - 6 (println (+ (struct complex 1 2) (struct complex 2 3) (struct complex 3 4))) ; - {:real 6 :imaginary 9} That said, I believe it is considered bad practice to redefine core functions. A better approach to this particular problem can be seen in clojure.core.complex-numbers. Best, Trevor On May 16, 4:32 pm, Saptarshi saptarshi.g...@gmail.com wrote: Hello, I am totally new to Clojure and have dabbled in Scala. In Scala, it is possible to override the + operator ,e.g a class A can overide +. In Clojure, I would have a struct and not a class. Can I still override the + operator in Clojure? Regards Saptarshi --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---