Re: core.async

2013-06-29 Thread Philip Potter
Looks awesome! I've just taken a moment to think of all the possibilities
this could allow.

One question: can multiple concurrent IoC threads be multiplexed over
multiple JVM threads? One advantage go's goroutines have is that they work
fine for single-thread concurrency, but if more cores are available they
can use them.

Phil
On Jun 28, 2013 8:06 PM, "Rich Hickey"  wrote:

> I've blogged a bit about the new core.async library:
>
> http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html
>
> Please try it out.
>
> Thanks,
>
> Rich
>
>  --
> --
> 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.
>
>
>

-- 
-- 
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: core.async

2013-06-29 Thread Thomas Heller
Hey,

this looks very interesting. However I'm a little concerned about the 
semantics of >! and https://gist.github.com/thheller/5890363

(ns thheller.async-test
  (:use clojure.test)
  (:require [clojure.core.async :as async :refer (go >! !! ! reply-to reply)
(recur (inc work-done))
)))
 
(let [me (async/chan)]
  (>!! c [me :work-work])
  (! never returns, cause the 
consumer died and the buffer is full. How do you "return" from that? Can I 
do alt! (timeout) on a put? Or does a full buffer throw?

>From what I understand one can "http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#timers
[2] 
https://developer.mozilla.org/en-US/docs/Web/API/window.setTimeout#Minimum.2F_maximum_delay_and_timeout_nesting
[3] http://dbaron.org/log/20100309-faster-timeouts

On Friday, June 28, 2013 9:06:47 PM UTC+2, Rich Hickey wrote:
>
> I've blogged a bit about the new core.async library:
>
> http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html
>
> Please try it out.
>
> Thanks,
>
> Rich
>
>

-- 
-- 
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: core.async

2013-06-29 Thread Peter Taoussanis
 

Oh man, how is everyone _not_ running around screaming about this right now?

It seems to me that the Clojure space suffers from an unusual malady: it's 
busy sitting here quietly advancing half of applied computer science, and 
no one seems to notice the full extent of its import.

Man, I'm sometimes forced to just stop for a moment and sit in awe at how 
lucky I've been to see this stuff develop and to get to use it.

Clojure was huge. And before we're close to digesting its potential, 
there's protocols. And Clojurescript. Then Datomic. Reducers. Now this.

And it's not about everything being necessarily _novel_, though there is 
often novelty. For me it's largely about the cohesiveness of the design and 
the consistency of the overarching vision. Everything _fits_. I feel like 
I'm using tools and ideas that weren't just developed with care, or 
cleverness, or experience, but all of those things in a kind of harmony 
that's vanishingly rare to find in any field.

I honestly feel like I'm witnessing history being made.

Thank you Rich Hickey, and everyone else in this community for making my 
work every day so enjoyable.

- Peter Taoussanis

-- 
-- 
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: core.async

2013-06-29 Thread Baishampayan Ghose
On Sat, Jun 29, 2013 at 4:37 PM, Peter Taoussanis  wrote:
> I honestly feel like I'm witnessing history being made.

We all are.

-BG

--
Baishampayan Ghose
b.ghose at gmail.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 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: multiline strings and multiline comments ?

2013-06-29 Thread Daniel Kwiecinski
(clojure.string/join "\n" [
   "this"
   "is"
   "multiline"
   "sting"
])

;produces "this\nis\nmultiline\nsting"

;)



On Monday, 16 August 2010 08:34:03 UTC+1, faenvie wrote:
>
> hi clojure-users, 
>
> i wonder what the reason is, that clojure(-reader) 
> does not allow 
>
> 1. multiline-strings like scala: 
>
>  """this is a 
>| multiline string""" 
>
> 2. multiline comments like java 
>
> /* this is a 
>multiline comment */ 
>
> someone who can explain or point 
> to relevant info ? 
>
> 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 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.




Timing expressions and comparing results

2013-06-29 Thread Frantisek Sodomka
Hi all,

If you need to compare running times of different expressions, you could 
use 'timings' macro:
https://gist.github.com/fsodomka/5890711

It takes the number of runs and expressions to time. For example:
user=> (timings 1e7 (+ 1 2 3 4) (+ 1 (+ 2 (+ 3 4
[{:time 55.028223, :expr (+ 1 2 3 4)} {:time 55.738369, :expr (+ 1 (+ 2 (+ 
3 4)))}]

Function 'report' prints out comparison of timings. For it to work, 
function 'clojure.pprint/print-table' is needed (Clojure 1.3+).

Results of expressions must be equal (=), otherwise an exception is thrown:
user=> (timings 1e7 (+ 100 2 3 4) (+ 1 (+ 2 (+ 3 4
Exception Results of expressions are not equal  user/eval1153 
(NO_SOURCE_FILE:354)

I hope you find it useful and it helps your programs to run faster,
Frantisek

-- 
-- 
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.




Tortoise-hare algorithm

2013-06-29 Thread Zhemin Lin
Hi.
One of my colleagues gave a share about the cycle detecting tortoise-hare 
algorithm (wiki
).
I translated the script on Wiki from Python to Clojure.
It worked, but not elegant.  I'd like to make it more functional, more 
tasty.
Any suggestions to help it evolve?

I uploaded my (messy) code here: 
https://github.com/miaoski/clojure-tortoise-hare
Thanks a lot! :)

-- 
-- 
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: Is there a better way to update a map atom?

2013-06-29 Thread John D. Hume
It's worth knowing that the "moment" is implemented via a compare-and-set,
and if the value has been changed (by another thread), the fn you passed to
swap! will be called again with the atom's new value.
On Jun 28, 2013 11:57 PM, "Greg"  wrote:

> OK, I've found something that shows how these two work when used in the
> implementation of a generator:
>
> https://gist.github.com/daveray/1263503
>
> I think I understand what the problem is now:
>
> (reset! id (inc @id))
>
> There's a "time gap" in between the dereference of 'id' and its assignment
> back to 'id' (after being incremented).
>
> With swap!, no such problem exists, because it's an atomic operation where
> there is no such "time gap" between dereferencing, applying a function, and
> setting the new value. That all takes place in on magical atomic moment.
>
> If I've got this wrong, please let me know!
>
> Cheers,
> Greg
>
> On Jun 28, 2013, at 11:19 PM, Greg  wrote:
>
> Can anyone explain the relationship between swap! and reset! ?
>
> Why is using swap! in this example "safe" and using reset! not?
>
> I've tried searching google for comparisons of the two but can't find
> anything, and the documentation doesn't help much.
>
> Thanks,
> Greg
>
> On Jan 21, 2013, at 6:22 PM, Stephen Compall 
> wrote:
>
> On Jan 21, 2013 3:28 PM, "Jim - FooBar();"  wrote:
> > ...or you can go all the way, skipping reset! completely:
> >
> > (swap! game-objects (fn [objects] (reduce-kv #(assoc % %2 (update-object
> %3)) {} objects) ))
>
> Which also has the benefit of being safe, unlike any reset!-based update.
>
> --
> Stephen Compall
> If anyone in the MSA is online, you should watch this flythrough.
>
> --
> 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 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.
>
>
>
>
>  --
> --
> 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.
>
>
>

-- 
-- 
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: multiline strings and multiline comments ?

2013-06-29 Thread Niels van Klaveren
In my version of CCW CTRL-/ multiline (un)commenting just works (under 
Windows).
Perhaps it's a keyboard shortcut problem ?

Only problem there is when multiple lines are selected, and some are 
uncommented, uncommenting the whole block doesn't work.

On Wednesday, August 18, 2010 10:40:39 AM UTC+2, Zmitro Lapcjonak wrote:
>
> On Aug 17, 12:14 am, Lee Spector  wrote: 
> > On Aug 16, 2010, at 4:13 PM, Meikel Brandmeyer wrote: 
> > 
> > > Every descent editor should provide a comment-selected-text 
> functionality. 
>
> > I've worked in several editors that have comment-selected-text, but I 
> don't see it in Eclipse/Counterclockwise 
>
> I've created issue: "comment multiple lines by pressing Ctrl+/" 
> http://code.google.com/p/counterclockwise/issues/detail?id=61 
>
> Still under development. 
>
> -- 
> Zmi La 
>

-- 
-- 
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: core.async

2013-06-29 Thread Jim - FooBar();

On 29/06/13 12:07, Peter Taoussanis wrote:


I honestly feel like I'm witnessing history being made.

Thank you Rich Hickey, and everyone else in this community for making 
my work every day so enjoyable.




+100! that makes 2 of us :)

Thanks indeed Rich (and everyone else of course)...

Jim

--
--
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.




question about java 'finalizers' (Charlie's Hunt talk)

2013-06-29 Thread Jim - FooBar();

Hi all,

I just finished watching this ( 
http://www.infoq.com/presentations/jvm-tuning?utm_source=infoq&utm_medium=videos_homepage&utm_campaign=videos_row1)
and I'm not sure I understood everything and specifically what he said 
about finalizers. I noticed that Stuart Sierra  (yes, I recognise his 
voice!) asked a question about this but the answer he got was pretty 
vague in my opinion...


First of all what does he mean by "finalizers"? Does the mean the 
.finalize() method on java.lang.Object, the try/finally idiom or custom 
"cleaning-up" methods?
Secondly, he said they are not good practice because they require 2 GC 
cyclesbut why do they require 2 GC cycles?


Did anyone else watch this presentation yet? Any clues?

thanks,

Jim

ps: I seriously hope he didn't mean the try/finally idiom because 
clojure makes significant use of 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
--- 
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: core.async

2013-06-29 Thread JeremyS
Hi guys,

Some time ago I was thinking how nice it would be to have Clojure on top of 
Go to be able to use channels and goroutines...
Well, I stand corrected, we don't need Go, it is now done as a library ! 
Clojure is a golden inspiration mine, every time something 
new arrives, if I am not running around like a headless chicken, since my 
mind (and so my head) is blown away, I am very close to...

Exciting times !!!

Cheers,

Jeremys.

On Saturday, June 29, 2013 2:01:29 PM UTC+2, Jim foo.bar wrote:
>
> On 29/06/13 12:07, Peter Taoussanis wrote: 
> > 
> > I honestly feel like I'm witnessing history being made. 
> > 
> > Thank you Rich Hickey, and everyone else in this community for making 
> > my work every day so enjoyable. 
> > 
>
> +100! that makes 2 of us :) 
>
> Thanks indeed Rich (and everyone else of course)... 
>
> Jim 
>

-- 
-- 
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: core.async

2013-06-29 Thread David Nolen
Only experience will tell if setTimeout is a problem. I doubt it. I've
toyed around with a queueing dispatcher that waits till we get 32 events
with flush after 6ms (the time span between which mouse events may arrive
under OS X). This permits queueing and dispatching a million events in less
than half a second.

I know Dart selects the best dispatching mechanism available - setTimeout,
DOM mutation observer etc

We should also explore our options.

David

On Saturday, June 29, 2013, Thomas Heller wrote:

> Hey,
>
> this looks very interesting. However I'm a little concerned about the
> semantics of >! and 
> https://gist.github.com/thheller/5890363
>
> (ns thheller.async-test
>   (:use clojure.test)
>   (:require [clojure.core.async :as async :refer (go >! !! 
> (def c (async/chan))
>
> (defn do-some-work [work]
>   (throw (ex-info "no way" {:work work})))
>
> (go (loop [work-done 0]
>   (let [[reply-to work] ( reply (do-some-work work)]
> (>! reply-to reply)
> (recur (inc work-done))
> )))
>
> (let [me (async/chan)]
>   (>!! c [me :work-work])
>   (   )
>
>
> The go-thread dies on the first message and never replies, the other
> thread waiting for a reply (be it the current thread as in my example, or
> another go-thread) will now be stuck. Thus I need an extra timeout for
> EVERY  messages that never arrive.
>
> However you may also run into situations where >! never returns, cause the
> consumer died and the buffer is full. How do you "return" from that? Can I
> do alt! (timeout) on a put? Or does a full buffer throw?
>
> From what I understand one can " detect that it in fact "ended"? I guess there could be some helper
> functions which restart go-threads in case of accidental deaths. Although
> right now an exception does not seem to close the go result channel.
>
> I still prefer Erlang (Actors) since it seems way easier to reason about
> and process links and monitors (supervisors) certainly make failures alot
> easier to detect/handle.
>
> Any words on the state of the CLJS port? Looking through the code I found
> that setTimeout(fn, 0) is used alot. HTML5 Spec [1,2,3] says "If the
> currently running task is a task that was created by the setTimeout()
> method, and timeout is less than 4, then increase timeout to 4." That may
> cause some trouble, thought I mention this.
>
> Anyways, its pretty nice piece of work and I will certainly play with it
> for a while.
>
> Cheers,
> /thomas
>
> [1]
> http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#timers
> [2]
> https://developer.mozilla.org/en-US/docs/Web/API/window.setTimeout#Minimum.2F_maximum_delay_and_timeout_nesting
> [3] http://dbaron.org/log/20100309-faster-timeouts
>
> On Friday, June 28, 2013 9:06:47 PM UTC+2, Rich Hickey wrote:
>>
>> I've blogged a bit about the new core.async library:
>>
>> http://clojure.com/blog/2013/**06/28/clojure-core-async-**channels.html
>>
>> Please try it out.
>>
>> Thanks,
>>
>> Rich
>>
>>  --
> --
> 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 '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  'clojure%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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com  'clojure%2bunsubscr...@googlegroups.com');>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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: Tortoise-hare algorithm

2013-06-29 Thread Simone Mosciatti
It is very interesting, just a friendly suggestion, if you share code, and 
need some help, make sure people can get immediately what is going on.
(READ: comment the code)

On Saturday, June 29, 2013 1:34:57 PM UTC+2, Zhemin Lin wrote:
>
> Hi.
> One of my colleagues gave a share about the cycle detecting tortoise-hare 
> algorithm 
> (wiki
> ).
> I translated the script on Wiki from Python to Clojure.
> It worked, but not elegant.  I'd like to make it more functional, more 
> tasty.
> Any suggestions to help it evolve?
>
> I uploaded my (messy) code here: 
> https://github.com/miaoski/clojure-tortoise-hare
> Thanks a lot! :)
>
>

-- 
-- 
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.




Suggested 'server' for hosting clojure web app

2013-06-29 Thread Ravindra Jaju
I want to deploy a small web app - serving mostly static content. I'm using
Luminus (http://www.luminusweb.net/) - which is quite neat in the way it
builds itself from well-known components.

I'm having trouble deciding how to deploy it. I want some automation while
deploying upgrades, and would like it to be light-weight. Jetty, http-kit,
or immutant?
(I tried immutant - but it seems to be taking up too much memory for my
comfort, on my modest server.)

Jetty and http-kit - I would like to hear about how I can deploy them as
nice system daemons, with monitoring etc. so that they can be brought up
automatically if something goes wrong. I'm also unable to find out how I
can do a re-deploy without restarting.

Any help or pointers appreciated!

Thanks,
jaju

-- 
-- 
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: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Ravindra Jaju
Oops - I meant to sent this to our local clojure group.

But thankfully, it still went to a relevant group rather than a completely
wrong one!


On Sat, Jun 29, 2013 at 8:17 PM, Ravindra Jaju wrote:

> I want to deploy a small web app - serving mostly static content. I'm
> using Luminus (http://www.luminusweb.net/) - which is quite neat in the
> way it builds itself from well-known components.
>
> I'm having trouble deciding how to deploy it. I want some automation while
> deploying upgrades, and would like it to be light-weight. Jetty, http-kit,
> or immutant?
> (I tried immutant - but it seems to be taking up too much memory for my
> comfort, on my modest server.)
>
> Jetty and http-kit - I would like to hear about how I can deploy them as
> nice system daemons, with monitoring etc. so that they can be brought up
> automatically if something goes wrong. I'm also unable to find out how I
> can do a re-deploy without restarting.
>
> Any help or pointers appreciated!
>
> Thanks,
> jaju
>

-- 
-- 
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: core.async

2013-06-29 Thread Ben Wolfson
So how does all this compare to lamina?


On Sat, Jun 29, 2013 at 4:07 AM, Peter Taoussanis wrote:

> Oh man, how is everyone _not_ running around screaming about this right
> now?
>
> It seems to me that the Clojure space suffers from an unusual malady: it's
> busy sitting here quietly advancing half of applied computer science, and
> no one seems to notice the full extent of its import.
>
> Man, I'm sometimes forced to just stop for a moment and sit in awe at how
> lucky I've been to see this stuff develop and to get to use it.
>
> Clojure was huge. And before we're close to digesting its potential,
> there's protocols. And Clojurescript. Then Datomic. Reducers. Now this.
>
> And it's not about everything being necessarily _novel_, though there is
> often novelty. For me it's largely about the cohesiveness of the design and
> the consistency of the overarching vision. Everything _fits_. I feel like
> I'm using tools and ideas that weren't just developed with care, or
> cleverness, or experience, but all of those things in a kind of harmony
> that's vanishingly rare to find in any field.
>
> I honestly feel like I'm witnessing history being made.
>
> Thank you Rich Hickey, and everyone else in this community for making my
> work every day so enjoyable.
>
> - Peter Taoussanis
>
> --
> --
> 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.
>
>
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
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: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Daniel Pittman
On Sat, Jun 29, 2013 at 7:47 AM, Ravindra Jaju  wrote:
> I want to deploy a small web app - serving mostly static content. I'm using
> Luminus (http://www.luminusweb.net/) - which is quite neat in the way it
> builds itself from well-known components.
>
> I'm having trouble deciding how to deploy it. I want some automation while
> deploying upgrades, and would like it to be light-weight. Jetty, http-kit,
> or immutant?
> (I tried immutant - but it seems to be taking up too much memory for my
> comfort, on my modest server.)
>
> Jetty and http-kit - I would like to hear about how I can deploy them as
> nice system daemons, with monitoring etc. so that they can be brought up
> automatically if something goes wrong. I'm also unable to find out how I can
> do a re-deploy without restarting.

If you are looking for advanced features like hot redeploy, you
probably want to consider if you really are after a "small" solution
or not -- if you can't tolerate that small downtime, are you sure you
won't need the clustering, XA transaction capabilities, and other
advanced features that a toolkit like immutant brings to the table
soon?

Regardless, you could use the `ring.reload` middleware in production,
or bring your own solution to the table for code reloading and use a
var as your ring handler to allow dynamic change.  (eg: in cgrand's
moustache, `(app #'my-handler-function)` allows redefining the handler
fn at runtime, transparently.)

Given either of those solutions you can then use jetty, netty,
http-kit, or anything else.  Personally, though, if you really want
automated deployment and zero-downtime upgrades, I would totally look
to a full blown - and heavy - stack. :)

--
Daniel Pittman
♲ Made with 100 percent post-consumer electrons

-- 
-- 
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: core.async

2013-06-29 Thread Rich Hickey


On Saturday, June 29, 2013 1:32:26 AM UTC-4, Brandon Bloom wrote:
>
> > CSP proper is amenable to certain kinds of automated correctness 
> analysis.
> > No work has been done on that front for core.async as yet.
>
> Although a far cry from Go's race 
> detector, 
> Go did ship with one feature that is helpful for preventing a certain class 
> of bugs: explicit restriction to a send-only or receive-only channel via 
> constraining conversion or assignment. See 
> http://golang.org/ref/spec#Channel_types
>
> Although Go utilizes the type system to accomplish this at compile time, 
> core.async could achieve the same effect at runtime. Essentially, there 
> could be two conversion functions for wrapping a channel in a read-only or 
> write-only proxy object.
>
> I'm not sure if this is actually useful, but I'm curious: Has this been 
> considered?
>

Yes, that's why some of the args are called 'ports'. We will probably have 
read/write ports representing just one end of a channel.

Rich  

-- 
-- 
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: core.async

2013-06-29 Thread Rich Hickey


On Saturday, June 29, 2013 5:16:55 AM UTC-4, Thomas Heller wrote:
>
> Hey,
>
> this looks very interesting. However I'm a little concerned about the 
> semantics of >! and 
> https://gist.github.com/thheller/5890363
>
> (ns thheller.async-test
>   (:use clojure.test)
>   (:require [clojure.core.async :as async :refer (go >! !!   
> (def c (async/chan))
>  
> (defn do-some-work [work]
>   (throw (ex-info "no way" {:work work})))
>  
> (go (loop [work-done 0]
>   (let [[reply-to work] ( reply (do-some-work work)]
> (>! reply-to reply)
> (recur (inc work-done))
> )))
>  
> (let [me (async/chan)]
>   (>!! c [me :work-work])
>   (   )
>
>
> The go-thread dies on the first message and never replies, the other 
> thread waiting for a reply (be it the current thread as in my example, or 
> another go-thread) will now be stuck. Thus I need an extra timeout for 
> EVERY  messages that never arrive.
>
> However you may also run into situations where >! never returns, cause the 
> consumer died and the buffer is full. How do you "return" from that? Can I 
> do alt! (timeout) on a put? Or does a full buffer throw?
>
> From what I understand one can " detect that it in fact "ended"? I guess there could be some helper 
> functions which restart go-threads in case of accidental deaths. Although 
> right now an exception does not seem to close the go result channel.
>
> I still prefer Erlang (Actors) since it seems way easier to reason about 
> and process links and monitors (supervisors) certainly make failures alot 
> easier to detect/handle.
>
> Any words on the state of the CLJS port? Looking through the code I found 
> that setTimeout(fn, 0) is used alot. HTML5 Spec [1,2,3] says "If the 
> currently running task is a task that was created by the setTimeout() 
> method, and timeout is less than 4, then increase timeout to 4." That may 
> cause some trouble, thought I mention this.
>
> Anyways, its pretty nice piece of work and I will certainly play with it 
> for a while.
>

Links and monitors can be applied as well to channel-using processes, and 
remain an interesting area for further work.

Rich

-- 
-- 
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] Edgar: A basic tool for performing Technical Analysis on financial instruments

2013-06-29 Thread Timothy Washington
Edgar  is a basic tool for performing
Technical Analysis on financial instruments. This tool is predicated on the
presence of high price movements of stock. So far, the emphasis is on:

   - stock market trading
   - algorthmic, automated trading
   - using the Interactive Brokers
trading platform


You will need these tools installed on your machine.

   1. Leiningen , 2.0 or abouve
   2. Datomic 
   3. An Interactive Brokers account with the API
Gateway(Trader
Workstation) installed on your machine


Some friends have suggested I turn this into a start-up, which isn't a bad
idea. But I'm 1 person, and don't have the time or resources to build this
out to the degree that I would like. As such, Edgar is currently in a bit
of a hackey state. However, I do have a working system that i) collects
historical and live tick data and calculates ii) Simple and Exponential
Moving Averages iii) a Bollinger Band, iv) Moving Average Convergence /
Divergence v) a Stochastic Oscillator and vi) On Balance Volume
calculations. As well, there are other goodies like RSI and Price
divergence.

That's all to say that I think some people might find this stuff useful.
There are many open source systems on the internet (see
here).
I wanted something like Edgar, to leverage the power of Clojure in this
domain. I think Edgar could be a feasible Clojure codebase, along the lines
of TradeLink (see here ) or Open Java
Trading System (see here ).


*Features*

   - load stocks that have a price differential over the past 24hrs, or
   some other constraint; this is a primitive tool though, and you should use
   a real-time stock filter if you can find it
   - load historical and live stock data
   - track many live stocks simultaneously
   - perform technical analysis on tracked stocks; the packages will be
   organised as follows.


*Lagging Indicators: *Lagging indicators are ones that follow price
movements and have less predictive qualities.

 - Moving Averages
 - Bollinger 
Bands

*Leading Indicators*: Leading indicators are those created to proceed the
price movements of a security giving predictive qualities.

- Stochastic 
Oscillator
- 
MACD


*Confirming Indicators*:

- On Balance 
Volume
- Relative Strength
Index



   - generate up and down signals based on technical analysis
   - allows the creation of custom strategies that use signals, or create
   custom filters based on technical analysis
   - creates buy and sell orders based on strategy signals



As I said this is in a very hackey state, and there are a lot of things
outstanding. These are some things that I will be working on. Have a look
and let me know what else you think would be useful.

   - make starting the system, a function
   - more documentation ; installation, startup
   - needs layout work and UI functional improvements ; I have some
   specific ideas around that
   - test suite
   - create a real-time stock filter based price volatility , or some other
   constraint
   - abstract strategies into a plug-in system
   - et al.



Tim Washington
Interruptsoftware.ca

-- 
-- 
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: core.async

2013-06-29 Thread Joseph Smith
> It seems to me that the Clojure space suffers from an unusual malady: it's 
> busy sitting here quietly advancing half of applied computer science, and no 
> one seems to notice the full extent of its import.
> 
And it makes me sound like a broken record with my colleagues: "Oh! Clojure 
has..."



 

---
Joseph Smith
@solussd






On Jun 29, 2013, at 6:07 AM, Peter Taoussanis  wrote:

> Oh man, how is everyone _not_ running around screaming about this right now?
> 
> It seems to me that the Clojure space suffers from an unusual malady: it's 
> busy sitting here quietly advancing half of applied computer science, and no 
> one seems to notice the full extent of its import.
> 
> Man, I'm sometimes forced to just stop for a moment and sit in awe at how 
> lucky I've been to see this stuff develop and to get to use it.
> 
> Clojure was huge. And before we're close to digesting its potential, there's 
> protocols. And Clojurescript. Then Datomic. Reducers. Now this.
> 
> And it's not about everything being necessarily _novel_, though there is 
> often novelty. For me it's largely about the cohesiveness of the design and 
> the consistency of the overarching vision. Everything _fits_. I feel like I'm 
> using tools and ideas that weren't just developed with care, or cleverness, 
> or experience, but all of those things in a kind of harmony that's 
> vanishingly rare to find in any field.
> 
> I honestly feel like I'm witnessing history being made.
> 
> Thank you Rich Hickey, and everyone else in this community for making my work 
> every day so enjoyable.
> 
> - Peter Taoussanis
> 
> 
> -- 
> -- 
> 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.
>  
>  

-- 
-- 
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: Suggested 'server' for hosting clojure web app

2013-06-29 Thread James Reeves
If you just want to deploy your application, and don't particularly care
about having control over your system architecture, you might want to
consider a platform like Heroku.

Otherwise, a common solution, and one I'd personally recommend, is to have
a standalone app executed via Upstart, running behind an nginx proxy.

Upstart allows you to run a process as a daemon, and it can do useful
things like automatically restart a process if it unexpectedly terminates.
Upstart is by no means the only program that does this, but it's the one
Ubuntu uses and is therefore stable and well-tested.

A HTTP proxy server like nginx is useful for buffering against restarts and
application failures. You can configure nginx to buffer a request while
your server restarts, or to distribute request over a cluster of processes,
or to cache static content.

You could create the standalone app manually, with a -main function that
calls run-jetty, or use the lein-ring plugin and the "lein ring uberjar"
command to do it for you.

- James


On 29 June 2013 15:47, Ravindra Jaju  wrote:

> I want to deploy a small web app - serving mostly static content. I'm
> using Luminus (http://www.luminusweb.net/) - which is quite neat in the
> way it builds itself from well-known components.
>
> I'm having trouble deciding how to deploy it. I want some automation while
> deploying upgrades, and would like it to be light-weight. Jetty, http-kit,
> or immutant?
> (I tried immutant - but it seems to be taking up too much memory for my
> comfort, on my modest server.)
>
> Jetty and http-kit - I would like to hear about how I can deploy them as
> nice system daemons, with monitoring etc. so that they can be brought up
> automatically if something goes wrong. I'm also unable to find out how I
> can do a re-deploy without restarting.
>
> Any help or pointers appreciated!
>
> Thanks,
> jaju
>
> --
> --
> 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.
>
>
>

-- 
-- 
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] byte-streams: a rosetta stone for all the byte representations the jvm has to offer

2013-06-29 Thread Zach Tellman
I've recently been trying to pull out useful pieces from some of my more 
monolithic libraries.  The most recent result is 'byte-streams' [1], a 
library that figures how how to convert between different byte 
representations (including character streams), and how to efficiently 
transfer bytes between various byte sources and sinks.  The net result is 
that you can do something like:

  (byte-streams/convert (File. "/tmp/foo") String {:encoding "utf-8"})

and get a string representation of the file's contents.  Of course, this is 
already possible using 'slurp', but you could also convert it to a 
CharSequence, or lazy sequence of ByteBuffers, or pretty much anything else 
you can imagine.  This is accomplished by traversing a graph of available 
conversions (don't worry, it's memoized), so simply defining a new 
conversion from some custom type to (say) a ByteBuffer will transitively 
allow you to convert it to any other type.

As an aside, this sort of conversion mechanism isn't limited to just byte 
representations, but I'm not sure if there's another large collection of 
mostly-isomorphic types out there that would benefit from this.  If anyone 
has ideas on where else this could be applied, I'd be interested to hear 
them.

Zach

[1] https://github.com/ztellman/byte-streams

-- 
-- 
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: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Ravindra Jaju
Thank you Daniel and James. I appreciate the detailed response and advice.

I'll make myself more clear and specify what I have in mind. I don't want
hot-deploys, for sure. :) I erred when I mentioned "without restarting" -
that certainly changes quite a few things!

Here's what I have in mind for my app as well as the deployment design. Its
main goals are primarily to (1) Get more familiar with clojure dev since I
enjoy it, (2) host my personal blog (mostly markdown, processed at runtime
or pre-preprocessed), and (3) some dynamic content.

| nginx | > | static content - markdown, possibly preprocessed -
with markdown-clj | --> | clojure app for some dynamic content |

I've only started using luminus, and it serves markdown by processing it at
runtime, which makes my content serving dependent on the app-server. I have
the option of pre-processing markdown and serving it completely statically
with nginx. Until then, I'm okay right now using the app to serve it.

It is at this point where I need advice. I currently only know of running
the clojure app via "lein ring server" (or equivalent) from the
command-line - no scripts which can run it like those init scripts with
start/stop/reload support. nginx runs fine as a daemon, but I need to
figure out the java side.

1] Upstart is good - so, I will need to figure out the equivalent on Fedora
(which is what I use - primarily because I'm too familiar with it and have
been an RH/Fedora guy since about ~1995). Essentially, a daemon monitor
which will restart in case of failures. I've been somewhat rusty with the
recent releases of all Linux-es from the systems admin point of view.
2] Is there a suggested way to manage the java process - especially
starting and stopping? I'm okay with a few seconds of downtime, and I can
write scripts to do this myself, but don't want to reinvent the wheel if
there are already some tools/scripts/practices which make it
straightforward. I'm especially looking for current practices with folks
who use clojure with jetty/http-kit like servers, and not jboss et al. :)

Best regards,
jaju



On Sat, Jun 29, 2013 at 10:36 PM, James Reeves wrote:

> If you just want to deploy your application, and don't particularly care
> about having control over your system architecture, you might want to
> consider a platform like Heroku.
>
> Otherwise, a common solution, and one I'd personally recommend, is to have
> a standalone app executed via Upstart, running behind an nginx proxy.
>
> Upstart allows you to run a process as a daemon, and it can do useful
> things like automatically restart a process if it unexpectedly terminates.
> Upstart is by no means the only program that does this, but it's the one
> Ubuntu uses and is therefore stable and well-tested.
>
> A HTTP proxy server like nginx is useful for buffering against restarts
> and application failures. You can configure nginx to buffer a request while
> your server restarts, or to distribute request over a cluster of processes,
> or to cache static content.
>
> You could create the standalone app manually, with a -main function that
> calls run-jetty, or use the lein-ring plugin and the "lein ring uberjar"
> command to do it for you.
>
> - James
>
>
> On 29 June 2013 15:47, Ravindra Jaju  wrote:
>
>> I want to deploy a small web app - serving mostly static content. I'm
>> using Luminus (http://www.luminusweb.net/) - which is quite neat in the
>> way it builds itself from well-known components.
>>
>> I'm having trouble deciding how to deploy it. I want some automation
>> while deploying upgrades, and would like it to be light-weight. Jetty,
>> http-kit, or immutant?
>> (I tried immutant - but it seems to be taking up too much memory for my
>> comfort, on my modest server.)
>>
>> Jetty and http-kit - I would like to hear about how I can deploy them as
>> nice system daemons, with monitoring etc. so that they can be brought up
>> automatically if something goes wrong. I'm also unable to find out how I
>> can do a re-deploy without restarting.
>>
>> Any help or pointers appreciated!
>>
>> Thanks,
>> jaju
>>
>> --
>> --
>> 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.
>>
>>
>>
>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send

Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Baishampayan Ghose
Pick http-kit, create a uberjar with lein and deploy via Upstart etc. It
works like a charm. Jetty is quite good too. ~BG

Sent from phone. Please excuse brevity.
On 29 Jun 2013 20:17, "Ravindra Jaju"  wrote:

> I want to deploy a small web app - serving mostly static content. I'm
> using Luminus (http://www.luminusweb.net/) - which is quite neat in the
> way it builds itself from well-known components.
>
> I'm having trouble deciding how to deploy it. I want some automation while
> deploying upgrades, and would like it to be light-weight. Jetty, http-kit,
> or immutant?
> (I tried immutant - but it seems to be taking up too much memory for my
> comfort, on my modest server.)
>
> Jetty and http-kit - I would like to hear about how I can deploy them as
> nice system daemons, with monitoring etc. so that they can be brought up
> automatically if something goes wrong. I'm also unable to find out how I
> can do a re-deploy without restarting.
>
> Any help or pointers appreciated!
>
> Thanks,
> jaju
>
> --
> --
> 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.
>
>
>

-- 
-- 
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: lein repl and missing yank

2013-06-29 Thread Cedric Greevey
OTOH, your readline can't handle inserting text you've just copied in some
other application, such as copy snippet from web browser window (e.g.
Clojuredocs example) and paste in REPL.

Using the system-wide copy and paste has clear advantages over using an
application-internal one. I'm sure I copy and paste across application
boundaries much more often than I want a history of past cuts and copies,
and on the rare occasions when I need to juggle multiple clipboard
snippets, being able to cross application boundaries makes that easy, since
I always keep a blank Notepad open anyway (to leave maximized when AFK, to
harmlessly absorb any keystrokes typed by paws). I can just paste snippets
into that and copy the needed ones. Similarly if I anticipate needing a
text snippet intermittently over longer periods, during which the clipboard
contents will certainly get clobbered (and then it would have likely fallen
off the end of any reasonably-sized "kill ring" or "history" before I was
done needing it!) ... and I don't have to try to track in my head a huge
amount of invisible state (what's in the ring, where the unseen
current-item-pointer is in that ring, etc., just the last thing copied or
cut -- the rest is visible if I alt-tab to the Notepad window).

Oh, and my method gives me a LAN-wide clipboard, too, since I can use a
normally-empty file on a network drive and give that file global write
permissions. Paste into file and save; on other computer, refresh view of
file and cut/copy.

On Fri, Jun 28, 2013 at 11:22 PM, Phil Hagelberg  wrote:

> On Friday, June 28, 2013 7:17:14 PM UTC-7, Jonathan Fischer Friberg wrote:
> > Should pasting be part of jline? Am I the only one that finds that
> really odd?
>
> jLine is a port of readline to the JVM. readline supports a kill ring, so
> jLine should too. That's different from the terminal performing pasting
> since all that can do is insert the primary selection, it can't handle
> history or inserting text that you've just killed.
>
> -Phil
>
> --
> --
> 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.
>
>
>

-- 
-- 
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: Is there a better way to update a map atom?

2013-06-29 Thread Cedric Greevey
As nobody else has said this, it bears making explicit that:

* swap! is for when the new value depends, in some way, on the previous
value.

* reset! is for when the new value is independent of the previous value.

If you're simply setting a flag, for example, (reset! foo true) works. If
you're incrementing a counter, though, you want (swap! foo inc), etc.

-- 
-- 
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: question about java 'finalizers' (Charlie's Hunt talk)

2013-06-29 Thread Cedric Greevey
On Sat, Jun 29, 2013 at 8:41 AM, Jim - FooBar(); wrote:

>  Hi all,
>
> I just finished watching this (
> http://www.infoq.com/presentations/jvm-tuning?utm_source=infoq&utm_medium=videos_homepage&utm_campaign=videos_row1
> )
> and I'm not sure I understood everything and specifically what he said
> about finalizers. I noticed that Stuart Sierra  (yes, I recognise his
> voice!) asked a question about this but the answer he got was pretty vague
> in my opinion...
>
> First of all what does he mean by "finalizers"? Does the mean the
> .finalize() method on java.lang.Object, the try/finally idiom or custom
> "cleaning-up" methods?
> Secondly, he said they are not good practice because they require 2 GC
> cycles
>

Then he meant the .finalize() method.

but why do they require 2 GC cycles?
>

Because the first time the object is found to be unreferenced, the
finalizer is scheduled to run, and the object must be kept alive as the
finalizer presumably uses it in some way (e.g. a stream object finalizer
closes a file descriptor held by the stream object in a field somewhere).
Then a second GC cycle needs to catch the finalized object unreferenced and
actually collect it. The finalizer could, in theory, "resurrect" an object
so eagerly composting it as soon as the finalizer exits isn't an option.

>  ps: I seriously hope he didn't mean the try/finally idiom because clojure
> makes significant use of it :)
>

They didn't. :)

-- 
-- 
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: core.async

2013-06-29 Thread David Pollak
What's the entry in project.clj to use the core.async stuff?

Thanks!


On Sat, Jun 29, 2013 at 9:44 AM, Joseph Smith  wrote:

> It seems to me that the Clojure space suffers from an unusual malady: it's
> busy sitting here quietly advancing half of applied computer science, and
> no one seems to notice the full extent of its import.
>
> And it makes me sound like a broken record with my colleagues: "Oh!
> Clojure has..."
>
>
>
> ---
> Joseph Smith
> @solussd
>
>
>
>
>
>
> On Jun 29, 2013, at 6:07 AM, Peter Taoussanis 
> wrote:
>
> Oh man, how is everyone _not_ running around screaming about this right
> now?
>
> It seems to me that the Clojure space suffers from an unusual malady: it's
> busy sitting here quietly advancing half of applied computer science, and
> no one seems to notice the full extent of its import.
>
> Man, I'm sometimes forced to just stop for a moment and sit in awe at how
> lucky I've been to see this stuff develop and to get to use it.
>
> Clojure was huge. And before we're close to digesting its potential,
> there's protocols. And Clojurescript. Then Datomic. Reducers. Now this.
>
> And it's not about everything being necessarily _novel_, though there is
> often novelty. For me it's largely about the cohesiveness of the design and
> the consistency of the overarching vision. Everything _fits_. I feel like
> I'm using tools and ideas that weren't just developed with care, or
> cleverness, or experience, but all of those things in a kind of harmony
> that's vanishingly rare to find in any field.
>
> I honestly feel like I'm witnessing history being made.
>
> Thank you Rich Hickey, and everyone else in this community for making my
> work every day so enjoyable.
>
> - Peter Taoussanis
>
> --
> --
> 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.
>
>
>
>
>  --
> --
> 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.
>
>
>

-- 
-- 
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: Tortoise-hare algorithm

2013-06-29 Thread Cedric Greevey
If the function is expensive to compute, you might prefer Brent's
periodicity detection algorithm, which instead of 1.5xn invocations of the
function only requires n + o(log n) invocations and supposedly detects just
as fast.

You store [last-n, last-f, next-n] = [0, f(0), 1] and then, for n = 1 to
whatever:

* compute f(n)
* see if it's equal to last-f; if it is, f is or becomes periodic with a
period dividing n - last-n.
* if n = next-n, change the store to [n, f(n), 2*next-n]
* move on to f(n + 1).



On Sat, Jun 29, 2013 at 10:43 AM, Simone Mosciatti wrote:

> It is very interesting, just a friendly suggestion, if you share code, and
> need some help, make sure people can get immediately what is going on.
> (READ: comment the code)
>
>
> On Saturday, June 29, 2013 1:34:57 PM UTC+2, Zhemin Lin wrote:
>>
>> Hi.
>> One of my colleagues gave a share about the cycle detecting tortoise-hare
>> algorithm 
>> (wiki
>> ).
>> I translated the script on Wiki from Python to Clojure.
>> It worked, but not elegant.  I'd like to make it more functional, more
>> tasty.
>> Any suggestions to help it evolve?
>>
>> I uploaded my (messy) code here: https://github.com/**
>> miaoski/clojure-tortoise-hare
>> Thanks a lot! :)
>>
>>  --
> --
> 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.
>
>
>

-- 
-- 
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: core.async

2013-06-29 Thread Brandon Bloom
I don't think it's published to a maven repository yet. You can check it
out, install it with `lein install`, then depend on it via [core.async
"0.1.0-SNAPSHOT"]


On Sat, Jun 29, 2013 at 2:50 PM, David Pollak  wrote:

> What's the entry in project.clj to use the core.async stuff?
>
> Thanks!
>
>
> On Sat, Jun 29, 2013 at 9:44 AM, Joseph Smith  wrote:
>
>> It seems to me that the Clojure space suffers from an unusual malady:
>> it's busy sitting here quietly advancing half of applied computer science,
>> and no one seems to notice the full extent of its import.
>>
>> And it makes me sound like a broken record with my colleagues: "Oh!
>> Clojure has..."
>>
>>
>>
>>---
>> Joseph Smith
>> @solussd
>>
>>
>>
>>
>>
>>
>> On Jun 29, 2013, at 6:07 AM, Peter Taoussanis 
>> wrote:
>>
>> Oh man, how is everyone _not_ running around screaming about this right
>> now?
>>
>> It seems to me that the Clojure space suffers from an unusual malady:
>> it's busy sitting here quietly advancing half of applied computer science,
>> and no one seems to notice the full extent of its import.
>>
>> Man, I'm sometimes forced to just stop for a moment and sit in awe at how
>> lucky I've been to see this stuff develop and to get to use it.
>>
>> Clojure was huge. And before we're close to digesting its potential,
>> there's protocols. And Clojurescript. Then Datomic. Reducers. Now this.
>>
>> And it's not about everything being necessarily _novel_, though there is
>> often novelty. For me it's largely about the cohesiveness of the design and
>> the consistency of the overarching vision. Everything _fits_. I feel like
>> I'm using tools and ideas that weren't just developed with care, or
>> cleverness, or experience, but all of those things in a kind of harmony
>> that's vanishingly rare to find in any field.
>>
>> I honestly feel like I'm witnessing history being made.
>>
>> Thank you Rich Hickey, and everyone else in this community for making my
>> work every day so enjoyable.
>>
>> - Peter Taoussanis
>>
>> --
>> --
>> 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.
>>
>>
>>
>>
>>  --
>> --
>> 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.
>>
>>
>>
>
>  --
> --
> 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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/PZ6sM2WXR1Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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...@googl

Re: core.async

2013-06-29 Thread Cedric Greevey
On Sat, Jun 29, 2013 at 7:07 AM, Peter Taoussanis wrote:

> Oh man, how is everyone _not_ running around screaming about this right
> now?
>
> It seems to me that the Clojure space suffers from an unusual malady: it's
> busy sitting here quietly advancing half of applied computer science, and
> no one seems to notice the full extent of its import.
>
> Man, I'm sometimes forced to just stop for a moment and sit in awe at how
> lucky I've been to see this stuff develop and to get to use it.
>

Agreed. But the lack of notice means we're "in on the ground floor", so to
speak, and can run circles around rival programming shops until they catch
on. :)


> Clojure was huge. And before we're close to digesting its potential,
> there's protocols. And Clojurescript. Then Datomic. Reducers. Now this.
>
One of these things is not like the others; one of these things is not open
source ...


> And it's not about everything being necessarily _novel_, though there is
> often novelty. For me it's largely about the cohesiveness of the design and
> the consistency of the overarching vision. Everything _fits_. I feel like
> I'm using tools and ideas that weren't just developed with care, or
> cleverness, or experience, but all of those things in a kind of harmony
> that's vanishingly rare to find in any field.
>
> I honestly feel like I'm witnessing history being made.
>
> Thank you Rich Hickey, and everyone else in this community for making my
> work every day so enjoyable.
>
The NSA is probably getting a FISA warrant right now to search Hickey's
home and place of business for any evidence of a flying saucer or time
machine, on the grounds that either would have national security
implications. :P

-- 
-- 
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: Suggested 'server' for hosting clojure web app

2013-06-29 Thread James Reeves
On 29 June 2013 18:59, Ravindra Jaju  wrote:

> 1] Upstart is good - so, I will need to figure out the equivalent on
> Fedora (which is what I use - primarily because I'm too familiar with it
> and have been an RH/Fedora guy since about ~1995). Essentially, a daemon
> monitor which will restart in case of failures. I've been somewhat rusty
> with the recent releases of all Linux-es from the systems admin point of
> view.
>

Since Fedora 9, Upstart has been the default on that as well, so you're in
luck :)


>  2] Is there a suggested way to manage the java process - especially
> starting and stopping? I'm okay with a few seconds of downtime, and I can
> write scripts to do this myself, but don't want to reinvent the wheel if
> there are already some tools/scripts/practices which make it
> straightforward. I'm especially looking for current practices with folks
> who use clojure with jetty/http-kit like servers, and not jboss et al. :)
>

Upstart will handle the starting and stopping. It'll just run a script to
start, and terminate the process to stop. You can avoid any downtime by
configuring nginx buffer requests; if your application is unavailable,
nginx will keep retrying until a timeout. From your user's point of view,
one request will take a few seconds longer, but there won't be any
downtime. And if you have more than one application process, you can
restart the processes one at a time, and avoid any sort of delay.

If you're interested, I could be persuaded to write a blog post on it. :)

- James

-- 
-- 
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: Clojure generates unnecessary and slow type-checks

2013-06-29 Thread Jason Wolfe
This looks very interesting, thanks for sharing!  I'll think about it a bit
while working on our codebase and see if I can contribute any good examples.


On Fri, Jun 28, 2013 at 7:17 AM, Mikera wrote:

> On Thursday, 20 June 2013 08:45:47 UTC+1, Jason Wolfe wrote:
>>
>> On Saturday, June 15, 2013 4:37:06 AM UTC-7, Mikera wrote:
>>>
>>> On Friday, 14 June 2013 18:15:34 UTC+1, Jason Wolfe wrote:
>>>
 Hey Mikera,

 I did look at core.matrix awhile ago, but I'll take another look.

 Right now, flop is just trying to make it easy to write *arbitrary*
 array operations compactly, while minimizing  the chance of getting
 worse-than-Java performance.  This used to be very tricky to get right
 when flop was developed (against Clojure 1.2); the situation has
 clearly improved since then, but there still seem to be some
 subtleties in going fast with arrays in 1.5.1 that we are trying to
 understand and then automate.

 As I understand it, core.matrix has a much more ambitious goal of
 abstracting over all matrix types.  This is a great goal, but I'm not
 sure if the protocol-based implementation can give users any help
 writing new core operations efficiently (say, making a new array with
 c[i] = a[i] + b[i]^2 / 2) -- unless there's some clever way of
 combining protocols with macros (hmmm).

>>>
>>> A longer term objective for core.matrix could be to allow compiling such
>>> expressions. Our GSoC student Maik Schünemann is exploring how to represent
>>> and optimised mathematical expressions in Clojure, and in theory these
>>> could be used to compile down to efficient low-level operations. API could
>>> look something like this:
>>>
>>> ;; define an expression
>>> (def my-expression (expression [a b] (+ a (/ (* b b) 2
>>>
>>> ;; compile the expression for the specified matrix implementation A
>>> (def func (compile-expression A my-expression)).
>>>
>>> ;; now computation can be run using the pre-compiled, optimised function
>>> (func A B)
>>>
>>> In the case that A is a Java double array, then perhaps the flop macros
>>> could be the engine behind generating the compiled function?
>>>
>>>
>>>
 I just benchmarked core.matrix/esum, and on my machine in Clojure
 1.5.1 it's 2.69x slower than the Java version above, and 1.62x slower
 than our current best Clojure version.

>>>
>>> Great - happy to steal your implementation :-)
>>>
>>> Other core.matrix implementations are probably faster BTW: vectorz-clj
>>> is pure Java and has esum for the general-purpose Vector type implemented
>>> in exactly the same way as your fast Java example. Clatrix executes a lot
>>> of operations via native code using BLAS.
>>>
>>
>> I should follow up on this and clarify that core.matrix's esum is in fact
>> as fast as Java -- I apologize for the false statement (I was unaware that
>> new versions of leiningen disable advanced JIT optimizations by default,
>> which lead to the numbers I reported).
>>
>> Nevertheless, I hope there may be room for interesting collaboration on
>> more complex operations, or code gen as you mentioned.  I'll follow up
>> later when we're a bit further along.
>>
>>
>
> Great thanks for confirming, I was getting worried :-)
>
> On the topic of code gen, we've been thinking a bit about how to represent
> expressions in the expresso project, and are developing a few potential use
> case API examples.
>
> https://github.com/clojure-numerics/expresso/wiki/User-API-examples
>
> If anyone has any additional use cases to think about, then please throw
> them 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.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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/LTtxhPxH_ws/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 grou

Re: core.async

2013-06-29 Thread Jozef Wagner
This is great news! Especially that it is designed also to support other 
hosts besides JVM.

BTW how do IOC threads compare (e.g. in performance and ability to use 
ForkJoinPool) to coroutines such as those in pulsar? [1] [2]

[1] http://blog.paralleluniverse.co/post/49445260575/quasar-pulsar
[2] http://puniverse.github.io/pulsar/manual/core.html#fibers

Jozef

On Friday, June 28, 2013 9:06:47 PM UTC+2, Rich Hickey wrote:
>
> I've blogged a bit about the new core.async library:
>
> http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html
>
> Please try it out.
>
> Thanks,
>
> Rich
>
>

-- 
-- 
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: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Maciej Mazur
On Sat, 29 Jun 2013 21:31:22 +0100, James Reeves wrote:

> On 29 June 2013 18:59, Ravindra Jaju  wrote:
> 
>> 1] Upstart is good - so, I will need to figure out the equivalent on
>> Fedora (which is what I use - primarily because I'm too familiar with
>> it and have been an RH/Fedora guy since about ~1995). Essentially, a
>> daemon monitor which will restart in case of failures. I've been
>> somewhat rusty with the recent releases of all Linux-es from the
>> systems admin point of view.
>>
>>
> Since Fedora 9, Upstart has been the default on that as well, so you're
> in luck :)

Actually Upstart has been replaced by systemd since Fedora 15

Maciej Mazur



signature.asc
Description: PGP signature


Re: Suggested 'server' for hosting clojure web app

2013-06-29 Thread James Reeves
On 30 June 2013 00:12, Maciej Mazur  wrote:

> On Sat, 29 Jun 2013 21:31:22 +0100, James Reeves wrote:
>
> > Since Fedora 9, Upstart has been the default on that as well, so you're
> > in luck :)
>
> Actually Upstart has been replaced by systemd since Fedora 15
>
>
Oops! Sorry for the misinformation. I'm clearly not up to date with Fedora.

- James

-- 
-- 
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: Is there a better way to update a map atom?

2013-06-29 Thread Brandon Bloom
> Can anyone explain the relationship between swap! and reset! ?

swap! is for "CAS"

See: http://en.wikipedia.org/wiki/Compare-and-swap

In the examples here, you're fully replacing a value, so reset! is fine... 
assuming that the replacement value was not derived from the existing 
value. If the atom was deref-ed (via deref or the @ reader macro), that 
value is a perception of a potentially old state. Making a decision outside 
of an atomic swap operation would potentially be invalidated by another 
thread performing a conflicting mutation.

-- 
-- 
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.




Help deciphering ArityException message

2013-06-29 Thread Dave Kincaid
Could someone help me decipher the ArityException I'm getting. It's not 
making sense to me. First here is the exception:

ArityException Wrong number of args (1) passed to: 
lastN$reformat-headers$fn  clojure.lang.AFn.throwArity (AFn.java:437)

and here is the function reformat-headers:

(defn reformat-headers
  [headers]
  (map #(.toString %) headers))

as far as I can tell the exception is saying that 1 argument is the wrong 
number of arguments for reformat-headers, but as you can clearly see it is 
a function of one argument. What am I interpreting wrong?

Thanks,

Dave

-- 
-- 
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.




UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
I'm using pprint to write out a map to a file then trying to read it back 
in using clojure.edn/read (I also get the same error using read). Here is 
the output (it's a map that was created by the Langohr rabbitmq library):

{:header
  {:timestamp #inst "2058-04-07T17:56:17.000-00:00",
   :delivery-tag 2,
   :expiration nil,
   :correlation-id nil,
   :delivery-mode 1,
   :app-id nil,
   :user-id nil,
   :redelivery? true,
   :header {:headers ()},
   :content-type nil,
   :persistent? false,
   :reply-to nil,
   :routing-key "pims_data_capture",
   :headers {"pluginKey" #},
   :type nil,
   :message-id nil,
   :cluster-id nil,
   :message-count 3,
   :exchange "",
   :content-encoding nil,
   :priority nil},
  :payload
  "{\"software\":\"CSTONE\",\"entity\":\"\","}

when I try to read it in I get an UnreadableForm exception. I've narrowed 
it down to the # element. If I manually change 
that to just a regular string I can read it. What is the idiomatic way to 
handle this noting that there could be a number of different values in that 
:headers map.

-- 
-- 
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: Is there a better way to update a map atom?

2013-06-29 Thread Ben Wolfson
On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom wrote:

> > Can anyone explain the relationship between swap! and reset! ?
>
> swap! is for "CAS"
>
> See: http://en.wikipedia.org/wiki/Compare-and-swap
>
>
How so? No comparison is done (unless it's done in the supplied function,
which is entirely up to the user of swap!). There's a separate
compare-and-set! function for atoms.

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
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: Is there a better way to update a map atom?

2013-06-29 Thread Ben Wolfson
anyway the relationship between swap! and reset! is that (reset! atom
newval) === (swap! atom (constantly newval)). (Though that isn't how reset!
is implemented.)


On Sat, Jun 29, 2013 at 5:21 PM, Ben Wolfson  wrote:

> On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom 
> wrote:
>
>> > Can anyone explain the relationship between swap! and reset! ?
>>
>> swap! is for "CAS"
>>
>> See: http://en.wikipedia.org/wiki/Compare-and-swap
>>
>>
> How so? No comparison is done (unless it's done in the supplied function,
> which is entirely up to the user of swap!). There's a separate
> compare-and-set! function for atoms.
>
> --
> Ben Wolfson
> "Human kind has used its intelligence to vary the flavour of drinks, which
> may be sweet, aromatic, fermented or spirit-based. ... Family and social
> life also offer numerous other occasions to consume drinks for pleasure."
> [Larousse, "Drink" entry]
>
>


-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
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: Is there a better way to update a map atom?

2013-06-29 Thread Cedric Greevey
On Sat, Jun 29, 2013 at 8:21 PM, Ben Wolfson  wrote:

> On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom 
> wrote:
>
>> > Can anyone explain the relationship between swap! and reset! ?
>>
>> swap! is for "CAS"
>>
>> See: http://en.wikipedia.org/wiki/Compare-and-swap
>>
>>
> How so? No comparison is done (unless it's done in the supplied function,
> which is entirely up to the user of swap!). There's a separate
> compare-and-set! function for atoms.
>

Er, swap! is basically

(loop []
  (let [x @a y (f x)]
(if (compare-and-set! a x y)
  y
  (recur

though it actually calls a .swap method of the Atom object that has
equivalent semantics.

-- 
-- 
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: Suggested 'server' for hosting clojure web app

2013-06-29 Thread Nick Gonzalez
I'm a big fan of http-kit. Lightweight, easy to use, and responsive. 

-- 
-- 
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: Is there a better way to update a map atom?

2013-06-29 Thread Ben Wolfson
On Sat, Jun 29, 2013 at 5:27 PM, Cedric Greevey  wrote:

>
> On Sat, Jun 29, 2013 at 8:21 PM, Ben Wolfson  wrote:
>
>> On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom > > wrote:
>>
>>> > Can anyone explain the relationship between swap! and reset! ?
>>>
>>>  swap! is for "CAS"
>>>
>>> See: http://en.wikipedia.org/wiki/Compare-and-swap
>>>
>>>
>> How so? No comparison is done (unless it's done in the supplied function,
>> which is entirely up to the user of swap!). There's a separate
>> compare-and-set! function for atoms.
>>
>
> Er, swap! is basically
>
> (loop []
>   (let [x @a y (f x)]
> (if (compare-and-set! a x y)
>   y
>   (recur
>
> though it actually calls a .swap method of the Atom object that has
> equivalent semantics.
>
>
The fact that swap! can be implemented with compare-and-set! doesn't make
it enlightening (or even correct) to say that swap! is CAS, especially
since compare-and-swap as explicated by the linked wikipedia page is
actually compare-and-set! in Clojure terms (there's no transformation by a
function and it's not unconditional).

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
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: Is there a better way to update a map atom?

2013-06-29 Thread Cedric Greevey
Who said swap *was* CAS, rather than was implemented *in terms of* CAS? In
any event, your claim that "no comparison is done unless it's done in the
supplied function" is just plain wrong. Comparison *is* done, outside that
function, to make sure the atom wasn't changed by another thread while the
function was executing.

Or just look at the source for clojure.lang.Atom.swap():

public Object swap(IFn f) {
for(; ;)
{
Object v = deref();
Object newv = f.invoke(v);
validate(newv);
if(state.compareAndSet(v, newv))
{
notifyWatches(v, newv);
return newv;
}
}
}


The compareAndSet method of a java.util.concurrent.AtomicReference is
invoked, and other than the watcher and validator stuff you can see that
it's semantically the same as the Clojure loop I posted previously.

On Sat, Jun 29, 2013 at 8:52 PM, Ben Wolfson  wrote:

> On Sat, Jun 29, 2013 at 5:27 PM, Cedric Greevey wrote:
>
>>
>> On Sat, Jun 29, 2013 at 8:21 PM, Ben Wolfson  wrote:
>>
>>> On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom <
>>> brandon.d.bl...@gmail.com> wrote:
>>>
 > Can anyone explain the relationship between swap! and reset! ?

  swap! is for "CAS"

 See: http://en.wikipedia.org/wiki/Compare-and-swap


>>> How so? No comparison is done (unless it's done in the supplied
>>> function, which is entirely up to the user of swap!). There's a separate
>>> compare-and-set! function for atoms.
>>>
>>
>> Er, swap! is basically
>>
>> (loop []
>>   (let [x @a y (f x)]
>> (if (compare-and-set! a x y)
>>   y
>>   (recur
>>
>> though it actually calls a .swap method of the Atom object that has
>> equivalent semantics.
>>
>>
> The fact that swap! can be implemented with compare-and-set! doesn't make
> it enlightening (or even correct) to say that swap! is CAS, especially
> since compare-and-swap as explicated by the linked wikipedia page is
> actually compare-and-set! in Clojure terms (there's no transformation by a
> function and it's not unconditional).
>
> --
> Ben Wolfson
> "Human kind has used its intelligence to vary the flavour of drinks, which
> may be sweet, aromatic, fermented or spirit-based. ... Family and social
> life also offer numerous other occasions to consume drinks for pleasure."
> [Larousse, "Drink" entry]
>
>  --
> --
> 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.
>
>
>

-- 
-- 
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: Help deciphering ArityException message

2013-06-29 Thread Baishampayan Ghose
This should work. What does headers look like? Sometimes the #(...)
reader form can cause problems. Does using the (fn ...) form help? ~BG

On Sun, Jun 30, 2013 at 5:39 AM, Dave Kincaid  wrote:
> Could someone help me decipher the ArityException I'm getting. It's not
> making sense to me. First here is the exception:
>
> ArityException Wrong number of args (1) passed to: lastN$reformat-headers$fn
> clojure.lang.AFn.throwArity (AFn.java:437)
>
> and here is the function reformat-headers:
>
> (defn reformat-headers
>   [headers]
>   (map #(.toString %) headers))
>
> as far as I can tell the exception is saying that 1 argument is the wrong
> number of arguments for reformat-headers, but as you can clearly see it is a
> function of one argument. What am I interpreting wrong?
>
> Thanks,
>
> Dave
>
> --
> --
> 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.
>
>



-- 
Baishampayan Ghose
b.ghose at gmail.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 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: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
Adding a method to the `print-dup` multimethod that dispatches on
ByteArrayLongString should help. See here for an example -
http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG

On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid  wrote:
> I'm using pprint to write out a map to a file then trying to read it back in
> using clojure.edn/read (I also get the same error using read). Here is the
> output (it's a map that was created by the Langohr rabbitmq library):
>
> {:header
>   {:timestamp #inst "2058-04-07T17:56:17.000-00:00",
>:delivery-tag 2,
>:expiration nil,
>:correlation-id nil,
>:delivery-mode 1,
>:app-id nil,
>:user-id nil,
>:redelivery? true,
>:header {:headers ()},
>:content-type nil,
>:persistent? false,
>:reply-to nil,
>:routing-key "pims_data_capture",
>:headers {"pluginKey" #},
>:type nil,
>:message-id nil,
>:cluster-id nil,
>:message-count 3,
>:exchange "",
>:content-encoding nil,
>:priority nil},
>   :payload
>   "{\"software\":\"CSTONE\",\"entity\":\"\","}
>
> when I try to read it in I get an UnreadableForm exception. I've narrowed it
> down to the # element. If I manually change
> that to just a regular string I can read it. What is the idiomatic way to
> handle this noting that there could be a number of different values in that
> :headers map.
>
> --
> --
> 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.
>
>



-- 
Baishampayan Ghose
b.ghose at gmail.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 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: Help deciphering ArityException message

2013-06-29 Thread Dave Kincaid
Here is the whole thing:

(defn reformat-headers
  [headers]
  (debug (str "Reformatting " headers))
  (map #(hash-map [%1 0] (.toString [%2 1])) headers))

(defn spit-messages
  "Write out the messages in the given seq."
  [messages dest]
  (pprint 
   (for [[metadata ^bytes payload] messages]
 {:header (update-in metadata [:headers] *reformat-headers*) :payload 
(String. payload)})
   dest))


On Saturday, June 29, 2013 8:12:26 PM UTC-5, Baishampayan Ghose wrote:
>
> This should work. What does headers look like? Sometimes the #(...) 
> reader form can cause problems. Does using the (fn ...) form help? ~BG 
>
> On Sun, Jun 30, 2013 at 5:39 AM, Dave Kincaid 
> > 
> wrote: 
> > Could someone help me decipher the ArityException I'm getting. It's not 
> > making sense to me. First here is the exception: 
> > 
> > ArityException Wrong number of args (1) passed to: 
> lastN$reformat-headers$fn 
> > clojure.lang.AFn.throwArity (AFn.java:437) 
> > 
> > and here is the function reformat-headers: 
> > 
> > (defn reformat-headers 
> >   [headers] 
> >   (map #(.toString %) headers)) 
> > 
> > as far as I can tell the exception is saying that 1 argument is the 
> wrong 
> > number of arguments for reformat-headers, but as you can clearly see it 
> is a 
> > function of one argument. What am I interpreting wrong? 
> > 
> > Thanks, 
> > 
> > Dave 
> > 
> > -- 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>
>
> -- 
> Baishampayan Ghose 
> b.ghose at gmail.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 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: Is there a better way to update a map atom?

2013-06-29 Thread Ben Wolfson
On Sat, Jun 29, 2013 at 6:06 PM, Cedric Greevey  wrote:

> Who said swap *was* CAS, rather than was implemented *in terms of* CAS? In
> any event, your claim that "no comparison is done unless it's done in the
> supplied function" is just plain wrong. Comparison *is* done, outside that
> function, to make sure the atom wasn't changed by another thread while the
> function was executing.
>

"swap! is for "CAS""

The claim here is clearly not that swap! is implemented in terms of CAS
(which would be very unenlightening, since the question was about the
distinction between swap! and reset!, which can *also* be implemented in
terms of CAS). I admit it would have been more careful of me to say that
the semantics of swap! are such that whether or not any comparison is done
is an implementation detail; those semantics (which are that swap!
"[a]tomically swaps the value of atom to be: (apply f current-value-of-atom
args)" don't specify a comparison, which is not the case with CAS. (reset!
*isn't* implemented in terms of swap! or CAS, but it *could* be, as far as
the semantics are concerned; if it were, I think it would still be right to
say that reset! conceptually doesn't do a comparison against anything, even
though, again, as an implementation detail, it could.)

Or just look at the source for clojure.lang.Atom.swap():
>

IOW, "the first 100 lines of Atom.java contain all the answers"?



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
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: Is there a better way to update a map atom?

2013-06-29 Thread Brandon Bloom
Could we please curb the pedantry?

On Sat, Jun 29, 2013 at 9:21 PM, Ben Wolfson  wrote:

> On Sat, Jun 29, 2013 at 6:06 PM, Cedric Greevey wrote:
>
>> Who said swap *was* CAS, rather than was implemented *in terms of* CAS?
>> In any event, your claim that "no comparison is done unless it's done in
>> the supplied function" is just plain wrong. Comparison *is* done, outside
>> that function, to make sure the atom wasn't changed by another thread while
>> the function was executing.
>>
>
> "swap! is for "CAS""
>
> The claim here is clearly not that swap! is implemented in terms of CAS
> (which would be very unenlightening, since the question was about the
> distinction between swap! and reset!, which can *also* be implemented in
> terms of CAS). I admit it would have been more careful of me to say that
> the semantics of swap! are such that whether or not any comparison is done
> is an implementation detail; those semantics (which are that swap!
> "[a]tomically swaps the value of atom to be: (apply f current-value-of-atom
> args)" don't specify a comparison, which is not the case with CAS. (reset!
> *isn't* implemented in terms of swap! or CAS, but it *could* be, as far as
> the semantics are concerned; if it were, I think it would still be right to
> say that reset! conceptually doesn't do a comparison against anything, even
> though, again, as an implementation detail, it could.)
>
> Or just look at the source for clojure.lang.Atom.swap():
>>
>
> IOW, "the first 100 lines of Atom.java contain all the answers"?
>
>
>
> --
> Ben Wolfson
> "Human kind has used its intelligence to vary the flavour of drinks, which
> may be sweet, aromatic, fermented or spirit-based. ... Family and social
> life also offer numerous other occasions to consume drinks for pleasure."
> [Larousse, "Drink" entry]
>
>  --
> --
> 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 a topic in the
> Google Groups "Clojure" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojure/PBiSzidSIVM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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: Help deciphering ArityException message

2013-06-29 Thread Baishampayan Ghose
What is the shape of `headers`? It looks like headers is a sequence of
two-element sequences, in which case `reformat-headers` should be
something like this -

(defn reformat-headers
[headers]
(map (fn [[x y]] (hash-map [x 0] (.toString [y 1]))) headers))
;; note the destructuring.

The problem is, the lambda inside the map is expecting two args but is
getting one arg (which is a two element sequence) instead.

Hope that helps.

~BG



On Sun, Jun 30, 2013 at 6:49 AM, Dave Kincaid  wrote:
> Here is the whole thing:
>
> (defn reformat-headers
>   [headers]
>   (debug (str "Reformatting " headers))
>   (map #(hash-map [%1 0] (.toString [%2 1])) headers))
>
> (defn spit-messages
>   "Write out the messages in the given seq."
>   [messages dest]
>   (pprint
>(for [[metadata ^bytes payload] messages]
>  {:header (update-in metadata [:headers] reformat-headers) :payload
> (String. payload)})
>dest))
>
>
> On Saturday, June 29, 2013 8:12:26 PM UTC-5, Baishampayan Ghose wrote:
>>
>> This should work. What does headers look like? Sometimes the #(...)
>> reader form can cause problems. Does using the (fn ...) form help? ~BG
>>
>> On Sun, Jun 30, 2013 at 5:39 AM, Dave Kincaid  wrote:
>> > Could someone help me decipher the ArityException I'm getting. It's not
>> > making sense to me. First here is the exception:
>> >
>> > ArityException Wrong number of args (1) passed to:
>> > lastN$reformat-headers$fn
>> > clojure.lang.AFn.throwArity (AFn.java:437)
>> >
>> > and here is the function reformat-headers:
>> >
>> > (defn reformat-headers
>> >   [headers]
>> >   (map #(.toString %) headers))
>> >
>> > as far as I can tell the exception is saying that 1 argument is the
>> > wrong
>> > number of arguments for reformat-headers, but as you can clearly see it
>> > is a
>> > function of one argument. What am I interpreting wrong?
>> >
>> > Thanks,
>> >
>> > Dave
>> >
>> > --
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>>
>>
>>
>> --
>> Baishampayan Ghose
>> b.ghose at gmail.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 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.
>
>



-- 
Baishampayan Ghose
b.ghose at gmail.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 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: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
Thanks! If that works, it is perfect. However, my first attempt isn't 
making any difference. Here is what I have:

(defmethod print-dup 
com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w]
  (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w))

(defn spit-messages
  "Write out the messages in the given seq."
  [messages dest]
  (print-dup
   (for [[metadata ^bytes payload] messages]
 {:header metadata :payload (String. payload)})
   dest))

but it still prints it out to the file with #. 
Did I miss something?

On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose wrote:
>
> Adding a method to the `print-dup` multimethod that dispatches on 
> ByteArrayLongString should help. See here for an example - 
> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG 
>
> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid 
> > 
> wrote: 
> > I'm using pprint to write out a map to a file then trying to read it 
> back in 
> > using clojure.edn/read (I also get the same error using read). Here is 
> the 
> > output (it's a map that was created by the Langohr rabbitmq library): 
> > 
> > {:header 
> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00", 
> >:delivery-tag 2, 
> >:expiration nil, 
> >:correlation-id nil, 
> >:delivery-mode 1, 
> >:app-id nil, 
> >:user-id nil, 
> >:redelivery? true, 
> >:header {:headers ()}, 
> >:content-type nil, 
> >:persistent? false, 
> >:reply-to nil, 
> >:routing-key "pims_data_capture", 
> >:headers {"pluginKey" #}, 
> >:type nil, 
> >:message-id nil, 
> >:cluster-id nil, 
> >:message-count 3, 
> >:exchange "", 
> >:content-encoding nil, 
> >:priority nil}, 
> >   :payload 
> >   "{\"software\":\"CSTONE\",\"entity\":\"\","} 
> > 
> > when I try to read it in I get an UnreadableForm exception. I've 
> narrowed it 
> > down to the # element. If I manually change 
> > that to just a regular string I can read it. What is the idiomatic way 
> to 
> > handle this noting that there could be a number of different values in 
> that 
> > :headers map. 
> > 
> > -- 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>
>
> -- 
> Baishampayan Ghose 
> b.ghose at gmail.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 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: Help deciphering ArityException message

2013-06-29 Thread Dave Kincaid
Yes! That does help. It's complaining about the arity of the function in 
the map, not the reformat-headers function. Now I understand. Thank you 
very much for helping clarify it for me.

Dave

On Saturday, June 29, 2013 8:30:21 PM UTC-5, Baishampayan Ghose wrote:
>
> What is the shape of `headers`? It looks like headers is a sequence of 
> two-element sequences, in which case `reformat-headers` should be 
> something like this - 
>
> (defn reformat-headers 
> [headers] 
> (map (fn [[x y]] (hash-map [x 0] (.toString [y 1]))) headers)) 
> ;; note the destructuring. 
>
> The problem is, the lambda inside the map is expecting two args but is 
> getting one arg (which is a two element sequence) instead. 
>
> Hope that helps. 
>
> ~BG 
>
>
>
> On Sun, Jun 30, 2013 at 6:49 AM, Dave Kincaid 
> > 
> wrote: 
> > Here is the whole thing: 
> > 
> > (defn reformat-headers 
> >   [headers] 
> >   (debug (str "Reformatting " headers)) 
> >   (map #(hash-map [%1 0] (.toString [%2 1])) headers)) 
> > 
> > (defn spit-messages 
> >   "Write out the messages in the given seq." 
> >   [messages dest] 
> >   (pprint 
> >(for [[metadata ^bytes payload] messages] 
> >  {:header (update-in metadata [:headers] reformat-headers) :payload 
> > (String. payload)}) 
> >dest)) 
> > 
> > 
> > On Saturday, June 29, 2013 8:12:26 PM UTC-5, Baishampayan Ghose wrote: 
> >> 
> >> This should work. What does headers look like? Sometimes the #(...) 
> >> reader form can cause problems. Does using the (fn ...) form help? ~BG 
> >> 
> >> On Sun, Jun 30, 2013 at 5:39 AM, Dave Kincaid  
> wrote: 
> >> > Could someone help me decipher the ArityException I'm getting. It's 
> not 
> >> > making sense to me. First here is the exception: 
> >> > 
> >> > ArityException Wrong number of args (1) passed to: 
> >> > lastN$reformat-headers$fn 
> >> > clojure.lang.AFn.throwArity (AFn.java:437) 
> >> > 
> >> > and here is the function reformat-headers: 
> >> > 
> >> > (defn reformat-headers 
> >> >   [headers] 
> >> >   (map #(.toString %) headers)) 
> >> > 
> >> > as far as I can tell the exception is saying that 1 argument is the 
> >> > wrong 
> >> > number of arguments for reformat-headers, but as you can clearly see 
> it 
> >> > is a 
> >> > function of one argument. What am I interpreting wrong? 
> >> > 
> >> > Thanks, 
> >> > 
> >> > Dave 
> >> > 
> >> > -- 
> >> > -- 
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Clojure" group. 
> >> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. 
> >> > For more options, visit https://groups.google.com/groups/opt_out. 
> >> > 
> >> > 
> >> 
> >> 
> >> 
> >> -- 
> >> Baishampayan Ghose 
> >> b.ghose at gmail.com 
> > 
> > -- 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>
>
> -- 
> Baishampayan Ghose 
> b.ghose at gmail.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 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: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
Does this work?

;; do the defmethod extension as usual and then define spit-messages as such
(defn spit-messages
  "Write out the messages in the given seq."
  [messages dest]
  (binding [*print-dup* true]
(pprint
 (for [[metadata ^bytes payload] messages]
   {:header metadata :payload (String. payload)})
 dest)))

~BG

On Sun, Jun 30, 2013 at 7:05 AM, Dave Kincaid  wrote:
> Thanks! If that works, it is perfect. However, my first attempt isn't making
> any difference. Here is what I have:
>
> (defmethod print-dup
> com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w]
>   (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w))
>
> (defn spit-messages
>   "Write out the messages in the given seq."
>   [messages dest]
>   (print-dup
>(for [[metadata ^bytes payload] messages]
>  {:header metadata :payload (String. payload)})
>dest))
>
> but it still prints it out to the file with #.
> Did I miss something?
>
> On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose wrote:
>>
>> Adding a method to the `print-dup` multimethod that dispatches on
>> ByteArrayLongString should help. See here for an example -
>> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG
>>
>> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid  wrote:
>> > I'm using pprint to write out a map to a file then trying to read it
>> > back in
>> > using clojure.edn/read (I also get the same error using read). Here is
>> > the
>> > output (it's a map that was created by the Langohr rabbitmq library):
>> >
>> > {:header
>> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00",
>> >:delivery-tag 2,
>> >:expiration nil,
>> >:correlation-id nil,
>> >:delivery-mode 1,
>> >:app-id nil,
>> >:user-id nil,
>> >:redelivery? true,
>> >:header {:headers ()},
>> >:content-type nil,
>> >:persistent? false,
>> >:reply-to nil,
>> >:routing-key "pims_data_capture",
>> >:headers {"pluginKey" #},
>> >:type nil,
>> >:message-id nil,
>> >:cluster-id nil,
>> >:message-count 3,
>> >:exchange "",
>> >:content-encoding nil,
>> >:priority nil},
>> >   :payload
>> >   "{\"software\":\"CSTONE\",\"entity\":\"\","}
>> >
>> > when I try to read it in I get an UnreadableForm exception. I've
>> > narrowed it
>> > down to the # element. If I manually change
>> > that to just a regular string I can read it. What is the idiomatic way
>> > to
>> > handle this noting that there could be a number of different values in
>> > that
>> > :headers map.
>> >
>> > --
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>>
>>
>>
>> --
>> Baishampayan Ghose
>> b.ghose at gmail.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 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.
>
>



-- 
Baishampayan Ghose
b.ghose at gmail.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 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: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
Hmm. No, it doesn't. This is what I get with pprint by itself:

:headers {"pluginKey" #}

with your version I get:

:headers
   #=(java.util.HashMap. {"pluginKey" 
#=(com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString. 
"PLUGIN2")})

what I think I needs to be able to read it back in is:

:headers {"pluginKey" "PLUGIN2"}

On Saturday, June 29, 2013 8:41:16 PM UTC-5, Baishampayan Ghose wrote:
>
> Does this work? 
>
> ;; do the defmethod extension as usual and then define spit-messages as 
> such 
> (defn spit-messages 
>   "Write out the messages in the given seq." 
>   [messages dest] 
>   (binding [*print-dup* true] 
> (pprint 
>  (for [[metadata ^bytes payload] messages] 
>{:header metadata :payload (String. payload)}) 
>  dest))) 
>
> ~BG 
>
> On Sun, Jun 30, 2013 at 7:05 AM, Dave Kincaid 
> > 
> wrote: 
> > Thanks! If that works, it is perfect. However, my first attempt isn't 
> making 
> > any difference. Here is what I have: 
> > 
> > (defmethod print-dup 
> > com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w] 
> >   (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w)) 
> > 
> > (defn spit-messages 
> >   "Write out the messages in the given seq." 
> >   [messages dest] 
> >   (print-dup 
> >(for [[metadata ^bytes payload] messages] 
> >  {:header metadata :payload (String. payload)}) 
> >dest)) 
> > 
> > but it still prints it out to the file with # PLUGIN2>. 
> > Did I miss something? 
> > 
> > On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose wrote: 
> >> 
> >> Adding a method to the `print-dup` multimethod that dispatches on 
> >> ByteArrayLongString should help. See here for an example - 
> >> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG 
> >> 
> >> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid  
> wrote: 
> >> > I'm using pprint to write out a map to a file then trying to read it 
> >> > back in 
> >> > using clojure.edn/read (I also get the same error using read). Here 
> is 
> >> > the 
> >> > output (it's a map that was created by the Langohr rabbitmq library): 
> >> > 
> >> > {:header 
> >> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00", 
> >> >:delivery-tag 2, 
> >> >:expiration nil, 
> >> >:correlation-id nil, 
> >> >:delivery-mode 1, 
> >> >:app-id nil, 
> >> >:user-id nil, 
> >> >:redelivery? true, 
> >> >:header {:headers ()}, 
> >> >:content-type nil, 
> >> >:persistent? false, 
> >> >:reply-to nil, 
> >> >:routing-key "pims_data_capture", 
> >> >:headers {"pluginKey" #}, 
> >> >:type nil, 
> >> >:message-id nil, 
> >> >:cluster-id nil, 
> >> >:message-count 3, 
> >> >:exchange "", 
> >> >:content-encoding nil, 
> >> >:priority nil}, 
> >> >   :payload 
> >> >   "{\"software\":\"CSTONE\",\"entity\":\"\","} 
> >> > 
> >> > when I try to read it in I get an UnreadableForm exception. I've 
> >> > narrowed it 
> >> > down to the # element. If I manually 
> change 
> >> > that to just a regular string I can read it. What is the idiomatic 
> way 
> >> > to 
> >> > handle this noting that there could be a number of different values 
> in 
> >> > that 
> >> > :headers map. 
> >> > 
> >> > -- 
> >> > -- 
> >> > You received this message because you are subscribed to the Google 
> >> > Groups "Clojure" group. 
> >> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. 
> >> > For more options, visit https://groups.google.com/groups/opt_out. 
> >> > 
> >> > 
> >> 
> >> 
> >> 
> >> -- 
> >> Baishampayan Ghose 
> >> b.ghose at gmail.com 
> > 
> > -- 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>
>
> -- 
> Baisham

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
This form, by the way is readable. Not sure why the print-dup
extension is not working though... ~BG

On Sun, Jun 30, 2013 at 7:18 AM, Dave Kincaid  wrote:
> Hmm. No, it doesn't. This is what I get with pprint by itself:
>
> :headers {"pluginKey" #}
>
> with your version I get:
>
> :headers
>#=(java.util.HashMap. {"pluginKey"
> #=(com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString.
> "PLUGIN2")})
>
> what I think I needs to be able to read it back in is:
>
> :headers {"pluginKey" "PLUGIN2"}
>
> On Saturday, June 29, 2013 8:41:16 PM UTC-5, Baishampayan Ghose wrote:
>>
>> Does this work?
>>
>> ;; do the defmethod extension as usual and then define spit-messages as
>> such
>> (defn spit-messages
>>   "Write out the messages in the given seq."
>>   [messages dest]
>>   (binding [*print-dup* true]
>> (pprint
>>  (for [[metadata ^bytes payload] messages]
>>{:header metadata :payload (String. payload)})
>>  dest)))
>>
>> ~BG
>>
>> On Sun, Jun 30, 2013 at 7:05 AM, Dave Kincaid  wrote:
>> > Thanks! If that works, it is perfect. However, my first attempt isn't
>> > making
>> > any difference. Here is what I have:
>> >
>> > (defmethod print-dup
>> > com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w]
>> >   (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w))
>> >
>> > (defn spit-messages
>> >   "Write out the messages in the given seq."
>> >   [messages dest]
>> >   (print-dup
>> >(for [[metadata ^bytes payload] messages]
>> >  {:header metadata :payload (String. payload)})
>> >dest))
>> >
>> > but it still prints it out to the file with #> > PLUGIN2>.
>> > Did I miss something?
>> >
>> > On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose wrote:
>> >>
>> >> Adding a method to the `print-dup` multimethod that dispatches on
>> >> ByteArrayLongString should help. See here for an example -
>> >> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG
>> >>
>> >> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid 
>> >> wrote:
>> >> > I'm using pprint to write out a map to a file then trying to read it
>> >> > back in
>> >> > using clojure.edn/read (I also get the same error using read). Here
>> >> > is
>> >> > the
>> >> > output (it's a map that was created by the Langohr rabbitmq library):
>> >> >
>> >> > {:header
>> >> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00",
>> >> >:delivery-tag 2,
>> >> >:expiration nil,
>> >> >:correlation-id nil,
>> >> >:delivery-mode 1,
>> >> >:app-id nil,
>> >> >:user-id nil,
>> >> >:redelivery? true,
>> >> >:header {:headers ()},
>> >> >:content-type nil,
>> >> >:persistent? false,
>> >> >:reply-to nil,
>> >> >:routing-key "pims_data_capture",
>> >> >:headers {"pluginKey" #},
>> >> >:type nil,
>> >> >:message-id nil,
>> >> >:cluster-id nil,
>> >> >:message-count 3,
>> >> >:exchange "",
>> >> >:content-encoding nil,
>> >> >:priority nil},
>> >> >   :payload
>> >> >   "{\"software\":\"CSTONE\",\"entity\":\"\","}
>> >> >
>> >> > when I try to read it in I get an UnreadableForm exception. I've
>> >> > narrowed it
>> >> > down to the # element. If I manually
>> >> > change
>> >> > that to just a regular string I can read it. What is the idiomatic
>> >> > way
>> >> > to
>> >> > handle this noting that there could be a number of different values
>> >> > in
>> >> > that
>> >> > :headers map.
>> >> >
>> >> > --
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups "Clojure" group.
>> >> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>> >> > For more options, visit https://groups.google.com/groups/opt_out.
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Baishampayan Ghose
>> >> b.ghose at gmail.com
>> >
>> > --
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clo...@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+u...@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 unsu

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
By the way, there is also the print-method multimethod which might
just do the trick for you. Just try this one with your original
version of `spit-messages` -
http://clojuredocs.org/clojure_core/clojure.core/print-method ~BG

On Sun, Jun 30, 2013 at 7:18 AM, Dave Kincaid  wrote:
> Hmm. No, it doesn't. This is what I get with pprint by itself:
>
> :headers {"pluginKey" #}
>
> with your version I get:
>
> :headers
>#=(java.util.HashMap. {"pluginKey"
> #=(com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString.
> "PLUGIN2")})
>
> what I think I needs to be able to read it back in is:
>
> :headers {"pluginKey" "PLUGIN2"}
>
> On Saturday, June 29, 2013 8:41:16 PM UTC-5, Baishampayan Ghose wrote:
>>
>> Does this work?
>>
>> ;; do the defmethod extension as usual and then define spit-messages as
>> such
>> (defn spit-messages
>>   "Write out the messages in the given seq."
>>   [messages dest]
>>   (binding [*print-dup* true]
>> (pprint
>>  (for [[metadata ^bytes payload] messages]
>>{:header metadata :payload (String. payload)})
>>  dest)))
>>
>> ~BG
>>
>> On Sun, Jun 30, 2013 at 7:05 AM, Dave Kincaid  wrote:
>> > Thanks! If that works, it is perfect. However, my first attempt isn't
>> > making
>> > any difference. Here is what I have:
>> >
>> > (defmethod print-dup
>> > com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w]
>> >   (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w))
>> >
>> > (defn spit-messages
>> >   "Write out the messages in the given seq."
>> >   [messages dest]
>> >   (print-dup
>> >(for [[metadata ^bytes payload] messages]
>> >  {:header metadata :payload (String. payload)})
>> >dest))
>> >
>> > but it still prints it out to the file with #> > PLUGIN2>.
>> > Did I miss something?
>> >
>> > On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose wrote:
>> >>
>> >> Adding a method to the `print-dup` multimethod that dispatches on
>> >> ByteArrayLongString should help. See here for an example -
>> >> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG
>> >>
>> >> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid 
>> >> wrote:
>> >> > I'm using pprint to write out a map to a file then trying to read it
>> >> > back in
>> >> > using clojure.edn/read (I also get the same error using read). Here
>> >> > is
>> >> > the
>> >> > output (it's a map that was created by the Langohr rabbitmq library):
>> >> >
>> >> > {:header
>> >> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00",
>> >> >:delivery-tag 2,
>> >> >:expiration nil,
>> >> >:correlation-id nil,
>> >> >:delivery-mode 1,
>> >> >:app-id nil,
>> >> >:user-id nil,
>> >> >:redelivery? true,
>> >> >:header {:headers ()},
>> >> >:content-type nil,
>> >> >:persistent? false,
>> >> >:reply-to nil,
>> >> >:routing-key "pims_data_capture",
>> >> >:headers {"pluginKey" #},
>> >> >:type nil,
>> >> >:message-id nil,
>> >> >:cluster-id nil,
>> >> >:message-count 3,
>> >> >:exchange "",
>> >> >:content-encoding nil,
>> >> >:priority nil},
>> >> >   :payload
>> >> >   "{\"software\":\"CSTONE\",\"entity\":\"\","}
>> >> >
>> >> > when I try to read it in I get an UnreadableForm exception. I've
>> >> > narrowed it
>> >> > down to the # element. If I manually
>> >> > change
>> >> > that to just a regular string I can read it. What is the idiomatic
>> >> > way
>> >> > to
>> >> > handle this noting that there could be a number of different values
>> >> > in
>> >> > that
>> >> > :headers map.
>> >> >
>> >> > --
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups "Clojure" group.
>> >> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>> >> > For more options, visit https://groups.google.com/groups/opt_out.
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Baishampayan Ghose
>> >> b.ghose at gmail.com
>> >
>> > --
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clo...@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+u...@googlegroups.com
>> > For more options, visit this group at
>> > http://groups.google.com/group/clojure?hl=en
>>

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
Thank you very much for the help. I really appreciate you trying. I don't 
know what is going on, but I need to move on from this.

Dave

On Saturday, June 29, 2013 8:57:31 PM UTC-5, Baishampayan Ghose wrote:
>
> This form, by the way is readable. Not sure why the print-dup 
> extension is not working though... ~BG 
>
> On Sun, Jun 30, 2013 at 7:18 AM, Dave Kincaid 
> > 
> wrote: 
> > Hmm. No, it doesn't. This is what I get with pprint by itself: 
> > 
> > :headers {"pluginKey" #} 
> > 
> > with your version I get: 
> > 
> > :headers 
> >#=(java.util.HashMap. {"pluginKey" 
> > #=(com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString. 
> > "PLUGIN2")}) 
> > 
> > what I think I needs to be able to read it back in is: 
> > 
> > :headers {"pluginKey" "PLUGIN2"} 
> > 
> > On Saturday, June 29, 2013 8:41:16 PM UTC-5, Baishampayan Ghose wrote: 
> >> 
> >> Does this work? 
> >> 
> >> ;; do the defmethod extension as usual and then define spit-messages as 
> >> such 
> >> (defn spit-messages 
> >>   "Write out the messages in the given seq." 
> >>   [messages dest] 
> >>   (binding [*print-dup* true] 
> >> (pprint 
> >>  (for [[metadata ^bytes payload] messages] 
> >>{:header metadata :payload (String. payload)}) 
> >>  dest))) 
> >> 
> >> ~BG 
> >> 
> >> On Sun, Jun 30, 2013 at 7:05 AM, Dave Kincaid  
> wrote: 
> >> > Thanks! If that works, it is perfect. However, my first attempt isn't 
> >> > making 
> >> > any difference. Here is what I have: 
> >> > 
> >> > (defmethod print-dup 
> >> > com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w] 
> >> >   (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w)) 
> >> > 
> >> > (defn spit-messages 
> >> >   "Write out the messages in the given seq." 
> >> >   [messages dest] 
> >> >   (print-dup 
> >> >(for [[metadata ^bytes payload] messages] 
> >> >  {:header metadata :payload (String. payload)}) 
> >> >dest)) 
> >> > 
> >> > but it still prints it out to the file with # >> > PLUGIN2>. 
> >> > Did I miss something? 
> >> > 
> >> > On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose 
> wrote: 
> >> >> 
> >> >> Adding a method to the `print-dup` multimethod that dispatches on 
> >> >> ByteArrayLongString should help. See here for an example - 
> >> >> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG 
> >> >> 
> >> >> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid  
> >> >> wrote: 
> >> >> > I'm using pprint to write out a map to a file then trying to read 
> it 
> >> >> > back in 
> >> >> > using clojure.edn/read (I also get the same error using read). 
> Here 
> >> >> > is 
> >> >> > the 
> >> >> > output (it's a map that was created by the Langohr rabbitmq 
> library): 
> >> >> > 
> >> >> > {:header 
> >> >> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00", 
> >> >> >:delivery-tag 2, 
> >> >> >:expiration nil, 
> >> >> >:correlation-id nil, 
> >> >> >:delivery-mode 1, 
> >> >> >:app-id nil, 
> >> >> >:user-id nil, 
> >> >> >:redelivery? true, 
> >> >> >:header {:headers ()}, 
> >> >> >:content-type nil, 
> >> >> >:persistent? false, 
> >> >> >:reply-to nil, 
> >> >> >:routing-key "pims_data_capture", 
> >> >> >:headers {"pluginKey" #}, 
> >> >> >:type nil, 
> >> >> >:message-id nil, 
> >> >> >:cluster-id nil, 
> >> >> >:message-count 3, 
> >> >> >:exchange "", 
> >> >> >:content-encoding nil, 
> >> >> >:priority nil}, 
> >> >> >   :payload 
> >> >> >   "{\"software\":\"CSTONE\",\"entity\":\"\","} 
> >> >> > 
> >> >> > when I try to read it in I get an UnreadableForm exception. I've 
> >> >> > narrowed it 
> >> >> > down to the # element. If I manually 
> >> >> > change 
> >> >> > that to just a regular string I can read it. What is the idiomatic 
> >> >> > way 
> >> >> > to 
> >> >> > handle this noting that there could be a number of different 
> values 
> >> >> > in 
> >> >> > that 
> >> >> > :headers map. 
> >> >> > 
> >> >> > -- 
> >> >> > -- 
> >> >> > You received this message because you are subscribed to the Google 
> >> >> > Groups "Clojure" group. 
> >> >> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. 
> >> >> > For more options, visit https://groups.google.com/groups/opt_out. 
> >> >> > 
> >> >> > 
> >> >> 
> >> >> 
> >> >> 
> >> >> -- 
> >> >

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
Readable by clojure.edn/read? I get this exception from it:

RuntimeException No dispatch macro for: = 
 clojure.lang.Util.runtimeException (Util.java:219)

I think I'm going to give up on this and serialize it to JSON. Should be 
easier.

On Saturday, June 29, 2013 8:57:31 PM UTC-5, Baishampayan Ghose wrote:
>
> This form, by the way is readable. Not sure why the print-dup 
> extension is not working though... ~BG 
>
> On Sun, Jun 30, 2013 at 7:18 AM, Dave Kincaid 
> > 
> wrote: 
> > Hmm. No, it doesn't. This is what I get with pprint by itself: 
> > 
> > :headers {"pluginKey" #} 
> > 
> > with your version I get: 
> > 
> > :headers 
> >#=(java.util.HashMap. {"pluginKey" 
> > #=(com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString. 
> > "PLUGIN2")}) 
> > 
> > what I think I needs to be able to read it back in is: 
> > 
> > :headers {"pluginKey" "PLUGIN2"} 
> > 
> > On Saturday, June 29, 2013 8:41:16 PM UTC-5, Baishampayan Ghose wrote: 
> >> 
> >> Does this work? 
> >> 
> >> ;; do the defmethod extension as usual and then define spit-messages as 
> >> such 
> >> (defn spit-messages 
> >>   "Write out the messages in the given seq." 
> >>   [messages dest] 
> >>   (binding [*print-dup* true] 
> >> (pprint 
> >>  (for [[metadata ^bytes payload] messages] 
> >>{:header metadata :payload (String. payload)}) 
> >>  dest))) 
> >> 
> >> ~BG 
> >> 
> >> On Sun, Jun 30, 2013 at 7:05 AM, Dave Kincaid  
> wrote: 
> >> > Thanks! If that works, it is perfect. However, my first attempt isn't 
> >> > making 
> >> > any difference. Here is what I have: 
> >> > 
> >> > (defmethod print-dup 
> >> > com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w] 
> >> >   (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w)) 
> >> > 
> >> > (defn spit-messages 
> >> >   "Write out the messages in the given seq." 
> >> >   [messages dest] 
> >> >   (print-dup 
> >> >(for [[metadata ^bytes payload] messages] 
> >> >  {:header metadata :payload (String. payload)}) 
> >> >dest)) 
> >> > 
> >> > but it still prints it out to the file with # >> > PLUGIN2>. 
> >> > Did I miss something? 
> >> > 
> >> > On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose 
> wrote: 
> >> >> 
> >> >> Adding a method to the `print-dup` multimethod that dispatches on 
> >> >> ByteArrayLongString should help. See here for an example - 
> >> >> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG 
> >> >> 
> >> >> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid  
> >> >> wrote: 
> >> >> > I'm using pprint to write out a map to a file then trying to read 
> it 
> >> >> > back in 
> >> >> > using clojure.edn/read (I also get the same error using read). 
> Here 
> >> >> > is 
> >> >> > the 
> >> >> > output (it's a map that was created by the Langohr rabbitmq 
> library): 
> >> >> > 
> >> >> > {:header 
> >> >> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00", 
> >> >> >:delivery-tag 2, 
> >> >> >:expiration nil, 
> >> >> >:correlation-id nil, 
> >> >> >:delivery-mode 1, 
> >> >> >:app-id nil, 
> >> >> >:user-id nil, 
> >> >> >:redelivery? true, 
> >> >> >:header {:headers ()}, 
> >> >> >:content-type nil, 
> >> >> >:persistent? false, 
> >> >> >:reply-to nil, 
> >> >> >:routing-key "pims_data_capture", 
> >> >> >:headers {"pluginKey" #}, 
> >> >> >:type nil, 
> >> >> >:message-id nil, 
> >> >> >:cluster-id nil, 
> >> >> >:message-count 3, 
> >> >> >:exchange "", 
> >> >> >:content-encoding nil, 
> >> >> >:priority nil}, 
> >> >> >   :payload 
> >> >> >   "{\"software\":\"CSTONE\",\"entity\":\"\","} 
> >> >> > 
> >> >> > when I try to read it in I get an UnreadableForm exception. I've 
> >> >> > narrowed it 
> >> >> > down to the # element. If I manually 
> >> >> > change 
> >> >> > that to just a regular string I can read it. What is the idiomatic 
> >> >> > way 
> >> >> > to 
> >> >> > handle this noting that there could be a number of different 
> values 
> >> >> > in 
> >> >> > that 
> >> >> > :headers map. 
> >> >> > 
> >> >> > -- 
> >> >> > -- 
> >> >> > You received this message because you are subscribed to the Google 
> >> >> > Groups "Clojure" group. 
> >> >> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. 
> >> >> > For more options, visit https://

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
No problem, but I am sure someone else on this group will have the answer :) ~BG

On Sun, Jun 30, 2013 at 7:33 AM, Dave Kincaid  wrote:
> Thank you very much for the help. I really appreciate you trying. I don't
> know what is going on, but I need to move on from this.
>
> Dave
>
>
> On Saturday, June 29, 2013 8:57:31 PM UTC-5, Baishampayan Ghose wrote:
>>
>> This form, by the way is readable. Not sure why the print-dup
>> extension is not working though... ~BG
>>
>> On Sun, Jun 30, 2013 at 7:18 AM, Dave Kincaid  wrote:
>> > Hmm. No, it doesn't. This is what I get with pprint by itself:
>> >
>> > :headers {"pluginKey" #}
>> >
>> > with your version I get:
>> >
>> > :headers
>> >#=(java.util.HashMap. {"pluginKey"
>> > #=(com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString.
>> > "PLUGIN2")})
>> >
>> > what I think I needs to be able to read it back in is:
>> >
>> > :headers {"pluginKey" "PLUGIN2"}
>> >
>> > On Saturday, June 29, 2013 8:41:16 PM UTC-5, Baishampayan Ghose wrote:
>> >>
>> >> Does this work?
>> >>
>> >> ;; do the defmethod extension as usual and then define spit-messages as
>> >> such
>> >> (defn spit-messages
>> >>   "Write out the messages in the given seq."
>> >>   [messages dest]
>> >>   (binding [*print-dup* true]
>> >> (pprint
>> >>  (for [[metadata ^bytes payload] messages]
>> >>{:header metadata :payload (String. payload)})
>> >>  dest)))
>> >>
>> >> ~BG
>> >>
>> >> On Sun, Jun 30, 2013 at 7:05 AM, Dave Kincaid 
>> >> wrote:
>> >> > Thanks! If that works, it is perfect. However, my first attempt isn't
>> >> > making
>> >> > any difference. Here is what I have:
>> >> >
>> >> > (defmethod print-dup
>> >> > com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w]
>> >> >   (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w))
>> >> >
>> >> > (defn spit-messages
>> >> >   "Write out the messages in the given seq."
>> >> >   [messages dest]
>> >> >   (print-dup
>> >> >(for [[metadata ^bytes payload] messages]
>> >> >  {:header metadata :payload (String. payload)})
>> >> >dest))
>> >> >
>> >> > but it still prints it out to the file with #> >> > PLUGIN2>.
>> >> > Did I miss something?
>> >> >
>> >> > On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose
>> >> > wrote:
>> >> >>
>> >> >> Adding a method to the `print-dup` multimethod that dispatches on
>> >> >> ByteArrayLongString should help. See here for an example -
>> >> >> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG
>> >> >>
>> >> >> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid 
>> >> >> wrote:
>> >> >> > I'm using pprint to write out a map to a file then trying to read
>> >> >> > it
>> >> >> > back in
>> >> >> > using clojure.edn/read (I also get the same error using read).
>> >> >> > Here
>> >> >> > is
>> >> >> > the
>> >> >> > output (it's a map that was created by the Langohr rabbitmq
>> >> >> > library):
>> >> >> >
>> >> >> > {:header
>> >> >> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00",
>> >> >> >:delivery-tag 2,
>> >> >> >:expiration nil,
>> >> >> >:correlation-id nil,
>> >> >> >:delivery-mode 1,
>> >> >> >:app-id nil,
>> >> >> >:user-id nil,
>> >> >> >:redelivery? true,
>> >> >> >:header {:headers ()},
>> >> >> >:content-type nil,
>> >> >> >:persistent? false,
>> >> >> >:reply-to nil,
>> >> >> >:routing-key "pims_data_capture",
>> >> >> >:headers {"pluginKey" #},
>> >> >> >:type nil,
>> >> >> >:message-id nil,
>> >> >> >:cluster-id nil,
>> >> >> >:message-count 3,
>> >> >> >:exchange "",
>> >> >> >:content-encoding nil,
>> >> >> >:priority nil},
>> >> >> >   :payload
>> >> >> >   "{\"software\":\"CSTONE\",\"entity\":\"\","}
>> >> >> >
>> >> >> > when I try to read it in I get an UnreadableForm exception. I've
>> >> >> > narrowed it
>> >> >> > down to the # element. If I manually
>> >> >> > change
>> >> >> > that to just a regular string I can read it. What is the idiomatic
>> >> >> > way
>> >> >> > to
>> >> >> > handle this noting that there could be a number of different
>> >> >> > values
>> >> >> > in
>> >> >> > that
>> >> >> > :headers map.
>> >> >> >
>> >> >> > --
>> >> >> > --
>> >> >> > You received this message because you are subscribed to the Google
>> >> >> > Groups "Clojure" group.
>> >> >> > To post to this group, send email to clo...@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+u...@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
>> >> >> > e

Re: Is there a better way to update a map atom?

2013-06-29 Thread Cedric Greevey
On Sat, Jun 29, 2013 at 9:21 PM, Ben Wolfson  wrote:

> On Sat, Jun 29, 2013 at 6:06 PM, Cedric Greevey wrote:
>
>> Who said swap *was* CAS, rather than was implemented *in terms of* CAS?
>> In any event, your claim that "no comparison is done unless it's done in
>> the supplied function" is just plain wrong. Comparison *is* done, outside
>> that function, to make sure the atom wasn't changed by another thread while
>> the function was executing.
>>
>
> "swap! is for "CAS""
>

Who claimed that, again? I said  "swap! is for when the new value depends,
in some way, on the previous value", which is not the same thing, and then
mentioned twice that it's implemented in terms of CAS.

-- 
-- 
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: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Dave Kincaid
That works perfectly! Thank you again very much.

On Saturday, June 29, 2013 9:01:32 PM UTC-5, Baishampayan Ghose wrote:
>
> By the way, there is also the print-method multimethod which might 
> just do the trick for you. Just try this one with your original 
> version of `spit-messages` - 
> http://clojuredocs.org/clojure_core/clojure.core/print-method ~BG 
>
> On Sun, Jun 30, 2013 at 7:18 AM, Dave Kincaid 
> > 
> wrote: 
> > Hmm. No, it doesn't. This is what I get with pprint by itself: 
> > 
> > :headers {"pluginKey" #} 
> > 
> > with your version I get: 
> > 
> > :headers 
> >#=(java.util.HashMap. {"pluginKey" 
> > #=(com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString. 
> > "PLUGIN2")}) 
> > 
> > what I think I needs to be able to read it back in is: 
> > 
> > :headers {"pluginKey" "PLUGIN2"} 
> > 
> > On Saturday, June 29, 2013 8:41:16 PM UTC-5, Baishampayan Ghose wrote: 
> >> 
> >> Does this work? 
> >> 
> >> ;; do the defmethod extension as usual and then define spit-messages as 
> >> such 
> >> (defn spit-messages 
> >>   "Write out the messages in the given seq." 
> >>   [messages dest] 
> >>   (binding [*print-dup* true] 
> >> (pprint 
> >>  (for [[metadata ^bytes payload] messages] 
> >>{:header metadata :payload (String. payload)}) 
> >>  dest))) 
> >> 
> >> ~BG 
> >> 
> >> On Sun, Jun 30, 2013 at 7:05 AM, Dave Kincaid  
> wrote: 
> >> > Thanks! If that works, it is perfect. However, my first attempt isn't 
> >> > making 
> >> > any difference. Here is what I have: 
> >> > 
> >> > (defmethod print-dup 
> >> > com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w] 
> >> >   (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w)) 
> >> > 
> >> > (defn spit-messages 
> >> >   "Write out the messages in the given seq." 
> >> >   [messages dest] 
> >> >   (print-dup 
> >> >(for [[metadata ^bytes payload] messages] 
> >> >  {:header metadata :payload (String. payload)}) 
> >> >dest)) 
> >> > 
> >> > but it still prints it out to the file with # >> > PLUGIN2>. 
> >> > Did I miss something? 
> >> > 
> >> > On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose 
> wrote: 
> >> >> 
> >> >> Adding a method to the `print-dup` multimethod that dispatches on 
> >> >> ByteArrayLongString should help. See here for an example - 
> >> >> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG 
> >> >> 
> >> >> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid  
> >> >> wrote: 
> >> >> > I'm using pprint to write out a map to a file then trying to read 
> it 
> >> >> > back in 
> >> >> > using clojure.edn/read (I also get the same error using read). 
> Here 
> >> >> > is 
> >> >> > the 
> >> >> > output (it's a map that was created by the Langohr rabbitmq 
> library): 
> >> >> > 
> >> >> > {:header 
> >> >> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00", 
> >> >> >:delivery-tag 2, 
> >> >> >:expiration nil, 
> >> >> >:correlation-id nil, 
> >> >> >:delivery-mode 1, 
> >> >> >:app-id nil, 
> >> >> >:user-id nil, 
> >> >> >:redelivery? true, 
> >> >> >:header {:headers ()}, 
> >> >> >:content-type nil, 
> >> >> >:persistent? false, 
> >> >> >:reply-to nil, 
> >> >> >:routing-key "pims_data_capture", 
> >> >> >:headers {"pluginKey" #}, 
> >> >> >:type nil, 
> >> >> >:message-id nil, 
> >> >> >:cluster-id nil, 
> >> >> >:message-count 3, 
> >> >> >:exchange "", 
> >> >> >:content-encoding nil, 
> >> >> >:priority nil}, 
> >> >> >   :payload 
> >> >> >   "{\"software\":\"CSTONE\",\"entity\":\"\","} 
> >> >> > 
> >> >> > when I try to read it in I get an UnreadableForm exception. I've 
> >> >> > narrowed it 
> >> >> > down to the # element. If I manually 
> >> >> > change 
> >> >> > that to just a regular string I can read it. What is the idiomatic 
> >> >> > way 
> >> >> > to 
> >> >> > handle this noting that there could be a number of different 
> values 
> >> >> > in 
> >> >> > that 
> >> >> > :headers map. 
> >> >> > 
> >> >> > -- 
> >> >> > -- 
> >> >> > You received this message because you are subscribed to the Google 
> >> >> > Groups "Clojure" group. 
> >> >> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. 
> >> >> > For more options, visit https://groups.google.com/groups/opt_out. 
> >> >> > 
> >> >> > 
> 

Re: UnreadableForm exception trying to read an EDN file

2013-06-29 Thread Baishampayan Ghose
Cool! ~BG

On Sun, Jun 30, 2013 at 7:49 AM, Dave Kincaid  wrote:
> That works perfectly! Thank you again very much.
>
>
> On Saturday, June 29, 2013 9:01:32 PM UTC-5, Baishampayan Ghose wrote:
>>
>> By the way, there is also the print-method multimethod which might
>> just do the trick for you. Just try this one with your original
>> version of `spit-messages` -
>> http://clojuredocs.org/clojure_core/clojure.core/print-method ~BG
>>
>> On Sun, Jun 30, 2013 at 7:18 AM, Dave Kincaid  wrote:
>> > Hmm. No, it doesn't. This is what I get with pprint by itself:
>> >
>> > :headers {"pluginKey" #}
>> >
>> > with your version I get:
>> >
>> > :headers
>> >#=(java.util.HashMap. {"pluginKey"
>> > #=(com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString.
>> > "PLUGIN2")})
>> >
>> > what I think I needs to be able to read it back in is:
>> >
>> > :headers {"pluginKey" "PLUGIN2"}
>> >
>> > On Saturday, June 29, 2013 8:41:16 PM UTC-5, Baishampayan Ghose wrote:
>> >>
>> >> Does this work?
>> >>
>> >> ;; do the defmethod extension as usual and then define spit-messages as
>> >> such
>> >> (defn spit-messages
>> >>   "Write out the messages in the given seq."
>> >>   [messages dest]
>> >>   (binding [*print-dup* true]
>> >> (pprint
>> >>  (for [[metadata ^bytes payload] messages]
>> >>{:header metadata :payload (String. payload)})
>> >>  dest)))
>> >>
>> >> ~BG
>> >>
>> >> On Sun, Jun 30, 2013 at 7:05 AM, Dave Kincaid 
>> >> wrote:
>> >> > Thanks! If that works, it is perfect. However, my first attempt isn't
>> >> > making
>> >> > any difference. Here is what I have:
>> >> >
>> >> > (defmethod print-dup
>> >> > com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString [o w]
>> >> >   (print-ctor o (fn [o w] (print-dup (String. (.getBytes o)) w)) w))
>> >> >
>> >> > (defn spit-messages
>> >> >   "Write out the messages in the given seq."
>> >> >   [messages dest]
>> >> >   (print-dup
>> >> >(for [[metadata ^bytes payload] messages]
>> >> >  {:header metadata :payload (String. payload)})
>> >> >dest))
>> >> >
>> >> > but it still prints it out to the file with #> >> > PLUGIN2>.
>> >> > Did I miss something?
>> >> >
>> >> > On Saturday, June 29, 2013 8:14:49 PM UTC-5, Baishampayan Ghose
>> >> > wrote:
>> >> >>
>> >> >> Adding a method to the `print-dup` multimethod that dispatches on
>> >> >> ByteArrayLongString should help. See here for an example -
>> >> >> http://clojuredocs.org/clojure_core/clojure.core/print-dup ~BG
>> >> >>
>> >> >> On Sun, Jun 30, 2013 at 5:47 AM, Dave Kincaid 
>> >> >> wrote:
>> >> >> > I'm using pprint to write out a map to a file then trying to read
>> >> >> > it
>> >> >> > back in
>> >> >> > using clojure.edn/read (I also get the same error using read).
>> >> >> > Here
>> >> >> > is
>> >> >> > the
>> >> >> > output (it's a map that was created by the Langohr rabbitmq
>> >> >> > library):
>> >> >> >
>> >> >> > {:header
>> >> >> >   {:timestamp #inst "2058-04-07T17:56:17.000-00:00",
>> >> >> >:delivery-tag 2,
>> >> >> >:expiration nil,
>> >> >> >:correlation-id nil,
>> >> >> >:delivery-mode 1,
>> >> >> >:app-id nil,
>> >> >> >:user-id nil,
>> >> >> >:redelivery? true,
>> >> >> >:header {:headers ()},
>> >> >> >:content-type nil,
>> >> >> >:persistent? false,
>> >> >> >:reply-to nil,
>> >> >> >:routing-key "pims_data_capture",
>> >> >> >:headers {"pluginKey" #},
>> >> >> >:type nil,
>> >> >> >:message-id nil,
>> >> >> >:cluster-id nil,
>> >> >> >:message-count 3,
>> >> >> >:exchange "",
>> >> >> >:content-encoding nil,
>> >> >> >:priority nil},
>> >> >> >   :payload
>> >> >> >   "{\"software\":\"CSTONE\",\"entity\":\"\","}
>> >> >> >
>> >> >> > when I try to read it in I get an UnreadableForm exception. I've
>> >> >> > narrowed it
>> >> >> > down to the # element. If I manually
>> >> >> > change
>> >> >> > that to just a regular string I can read it. What is the idiomatic
>> >> >> > way
>> >> >> > to
>> >> >> > handle this noting that there could be a number of different
>> >> >> > values
>> >> >> > in
>> >> >> > that
>> >> >> > :headers map.
>> >> >> >
>> >> >> > --
>> >> >> > --
>> >> >> > You received this message because you are subscribed to the Google
>> >> >> > Groups "Clojure" group.
>> >> >> > To post to this group, send email to clo...@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+u...@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+u...@googlegroup

Re: Tortoise-hare algorithm

2013-06-29 Thread Zhemin Lin
Hi Simone & Cedric,

Thanks for your comment.  In fact, my purpose is to demonstrate to my 
colleagues how Clojure deals with this algorithm.
I'm going to implement the Brent's way.

However, I'm wondering if I can make the Floyd's more functional.
Tail recursion is good, but not good enough to show the "paradigm shift" 
(of functional programming) to my colleagues.

Any ideas?
Thanks! :)

2013年6月30日日曜日 2時58分57秒 UTC+8 Cedric Greevey:
>
> If the function is expensive to compute, you might prefer Brent's 
> periodicity detection algorithm, which instead of 1.5xn invocations of the 
> function only requires n + o(log n) invocations and supposedly detects just 
> as fast.
>
> You store [last-n, last-f, next-n] = [0, f(0), 1] and then, for n = 1 to 
> whatever:
>
> * compute f(n)
> * see if it's equal to last-f; if it is, f is or becomes periodic with a 
> period dividing n - last-n.
> * if n = next-n, change the store to [n, f(n), 2*next-n]
> * move on to f(n + 1).
>
>
>
> On Sat, Jun 29, 2013 at 10:43 AM, Simone Mosciatti 
> 
> > wrote:
>
>> It is very interesting, just a friendly suggestion, if you share code, 
>> and need some help, make sure people can get immediately what is going on.
>> (READ: comment the code)
>>
>>
>> On Saturday, June 29, 2013 1:34:57 PM UTC+2, Zhemin Lin wrote:
>>>
>>> Hi.
>>> One of my colleagues gave a share about the cycle detecting 
>>> tortoise-hare algorithm 
>>> (wiki
>>> ).
>>> I translated the script on Wiki from Python to Clojure.
>>> It worked, but not elegant.  I'd like to make it more functional, more 
>>> tasty.
>>> Any suggestions to help it evolve?
>>>
>>> I uploaded my (messy) code here: https://github.com/**
>>> miaoski/clojure-tortoise-hare
>>> Thanks a lot! :)
>>>
>>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
-- 
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.