Re: I can not find any function that might give rise tothisStackOverflow error

2017-04-03 Thread piastkrakow

Thank you again. This has been educational. 



On Monday, April 3, 2017 at 1:07:18 PM UTC-4, Sean Corfield wrote:
>
> This is lazy:  (remove #{(first scores)} scores)
>
>  
>
> Since find-related-positive-negative-true-false-records does not realize 
> set-of-scores in order to return its value, then you still have laziness on 
> scores.
>
>  
>
> I think, in your original, if you wrap that remove call with doall, you 
> won’t get a stack overflow.
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> On 4/3/17, 9:24 AM, "clo...@googlegroups.com  on behalf of 
> piast...@gmail.com "  on behalf of piast...@gmail.com > wrote:
>
>  
>
> I apologize for my ignorance, but why is this lazy?
>
>  
>
>  (conj vector-of-maps-of-vector-key-and-score 
> (find-related-positive-negative-true-false-records scores (first scores
>
>  
>
> Assuming the functions are not called eagerly simply because I am in a 
> loop. But what would the eager version of this be? I 
>
>  
>
>
> On Sunday, April 2, 2017 at 1:42:20 AM UTC-4, Sean Corfield wrote:
>
> > But does that mean one can't use functions to build up sequences in a 
> loop? That seems to limit loops a great deal. 
>
> You just need to ensure you are building the sequences in an eager manner, 
> rather than a lazy manner.
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> *From: *piast...@gmail.com
> *Sent: *Saturday, April 1, 2017 9:56 PM
> *To: *Clojure
> *Subject: *Re: I can not find any function that might give rise 
> tothisStackOverflow error
>
>  
>
>
> > Because when you recur in your loop, you’re passing in lazy sequences, 
> so those 
> > are essentially building up a giant stack of delayed evaluations – and 
> when you hit bottom 
> > and try to realize those, that’s when your stack overflow hits you.
>
> I was thinking the answer had something to do with the lazyness, but I 
> wasn't sure because the app seemed to die before the loop finished -- which 
> I assume is before the functions were realized. But it is possible the 
> logging functions were slow and didn't show the whole truth. I am grateful 
> to have someone with your experience clarify this. 
>
> But does that mean one can't use functions to build up sequences in a 
> loop? That seems to limit loops a great deal. 
>
>
>
> On Saturday, April 1, 2017 at 10:22:04 PM UTC-4, Sean Corfield wrote:
>
> Because when you recur in your loop, you’re passing in lazy sequences, so 
> those are essentially building up a giant stack of delayed evaluations – 
> and when you hit bottom and try to realize those, that’s when your stack 
> overflow hits you.
>
>  
>
> By contrast, your reduce code is eager so the work is done as you work 
> through the sequence, instead of “stacked up” lazily, to be done later.
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> *From: *piast...@gmail.com
> *Sent: *Saturday, April 1, 2017 6:52 PM
> *To: *Clojure
> *Subject: *Re: I can not find any function that might give rise to 
> thisStackOverflow error
>
>  
>
>
> Crazy! I re-wrote the (loop) to use (reduce) instead and now everything 
> works: 
>
>
> (defn loop-over-scores
>   [set-of-scores]
>   "2017-03-08 -- called from start.clj"
>   (reduce
>;; 2017-04-01 -- we assume vector-with-path-score looks like this:
>;;  [[:positive :true 0.88 19 60 10 12 3 1 3 1 2 1] 1]
>;; so we do a minor bit of destructuring
>(fn [vector-of-maps-of-vector-key-and-score [vector-with-path score]]
>  (conj vector-of-maps-of-vector-key-and-score
>(dire/supervise #'map-of-vector-path-and-true-false-scores 
> vector-with-path)))
>[]
>set-of-scores))
>
>
> The StackOverflow error is gone. 
>
> Sad to say, I'm left with a feeling as if I know nothing about Clojure. I 
> don't know why (loop) gave me a StackOverflow error whereas (reduce) works 
> just fine. This is black magic to me, which, sad to say, is not a 
> comfortable feeling. 
>
>
>
>
>
>
> On Saturday, April 1, 2017 at 7:51:08 PM UTC-4, piast...@gmail.com wrote:
>
> Well, I am out of ideas. Let's assume I'll re-write this some other way. 
> What would be better than using (loop)? What would be less likely to cause 
> StackOverflow, or at least reveal why I'm seeing it. 
>
>
> On Saturday, April 1, 2017 at 6:23:29 PM UTC-4, piast...@gmail.com wrote:
>
>
> I have a function that will run repeatedly, so I use the at-at library to 
> call it:
>
> https://github.com/overtone/at-at
>
> I don't think this is the problem. 
>
> Sad to say, the Error is catching a StackOverflow, which I'm 

Re: I can not find any function that might give rise tothisStackOverflow error

2017-04-03 Thread piastkrakow
I apologize for my ignorance, but why is this lazy?
 
 (conj vector-of-maps-of-vector-key-and-score 
(find-related-positive-negative-true-false-records scores (first scores

Assuming the functions are not called eagerly simply because I am in a 
loop. But what would the eager version of this be? I 


On Sunday, April 2, 2017 at 1:42:20 AM UTC-4, Sean Corfield wrote:
>
> > But does that mean one can't use functions to build up sequences in a 
> loop? That seems to limit loops a great deal. 
>
> You just need to ensure you are building the sequences in an eager manner, 
> rather than a lazy manner.
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> *From: *piast...@gmail.com 
> *Sent: *Saturday, April 1, 2017 9:56 PM
> *To: *Clojure 
> *Subject: *Re: I can not find any function that might give rise 
> tothisStackOverflow error
>
>  
>
>
> > Because when you recur in your loop, you’re passing in lazy sequences, 
> so those 
> > are essentially building up a giant stack of delayed evaluations – and 
> when you hit bottom 
> > and try to realize those, that’s when your stack overflow hits you.
>
> I was thinking the answer had something to do with the lazyness, but I 
> wasn't sure because the app seemed to die before the loop finished -- which 
> I assume is before the functions were realized. But it is possible the 
> logging functions were slow and didn't show the whole truth. I am grateful 
> to have someone with your experience clarify this. 
>
> But does that mean one can't use functions to build up sequences in a 
> loop? That seems to limit loops a great deal. 
>
>
>
> On Saturday, April 1, 2017 at 10:22:04 PM UTC-4, Sean Corfield wrote:
>
> Because when you recur in your loop, you’re passing in lazy sequences, so 
> those are essentially building up a giant stack of delayed evaluations – 
> and when you hit bottom and try to realize those, that’s when your stack 
> overflow hits you.
>
>  
>
> By contrast, your reduce code is eager so the work is done as you work 
> through the sequence, instead of “stacked up” lazily, to be done later.
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> *From: *piast...@gmail.com
> *Sent: *Saturday, April 1, 2017 6:52 PM
> *To: *Clojure
> *Subject: *Re: I can not find any function that might give rise to 
> thisStackOverflow error
>
>  
>
>
> Crazy! I re-wrote the (loop) to use (reduce) instead and now everything 
> works: 
>
>
> (defn loop-over-scores
>   [set-of-scores]
>   "2017-03-08 -- called from start.clj"
>   (reduce
>;; 2017-04-01 -- we assume vector-with-path-score looks like this:
>;;  [[:positive :true 0.88 19 60 10 12 3 1 3 1 2 1] 1]
>;; so we do a minor bit of destructuring
>(fn [vector-of-maps-of-vector-key-and-score [vector-with-path score]]
>  (conj vector-of-maps-of-vector-key-and-score
>(dire/supervise #'map-of-vector-path-and-true-false-scores 
> vector-with-path)))
>[]
>set-of-scores))
>
>
> The StackOverflow error is gone. 
>
> Sad to say, I'm left with a feeling as if I know nothing about Clojure. I 
> don't know why (loop) gave me a StackOverflow error whereas (reduce) works 
> just fine. This is black magic to me, which, sad to say, is not a 
> comfortable feeling. 
>
>
>
>
>
>
> On Saturday, April 1, 2017 at 7:51:08 PM UTC-4, piast...@gmail.com wrote:
>
> Well, I am out of ideas. Let's assume I'll re-write this some other way. 
> What would be better than using (loop)? What would be less likely to cause 
> StackOverflow, or at least reveal why I'm seeing it. 
>
>
> On Saturday, April 1, 2017 at 6:23:29 PM UTC-4, piast...@gmail.com wrote:
>
>
> I have a function that will run repeatedly, so I use the at-at library to 
> call it:
>
> https://github.com/overtone/at-at
>
> I don't think this is the problem. 
>
> Sad to say, the Error is catching a StackOverflow, which I'm having 
> trouble finding. I don't see a place where I call a function recursively, 
> so I don't see where any of this becomes stackoverflow. 
>
> I'm using Dire to catch errors, but for now I'm just logging them. I don't 
> see anything fancy or clever that would give me a stackoverflow, and yet 
> this anonymous function called by at-at is definitely giving rise to 
> StackOverflow.
>
> (defn- calculate--scores []
>   (let [my-pool (at/mk-pool)]
> (at/every 18
>   (fn []
> (append-to-file "/var/log/example/-scores.log" "Will 
> attempt to write scores")
> (future 
>   (try 
> (let [
>   map-of-all-sums   
> (api/get-accuracy-and-precision)
>   set-of-all-scores (dire/supervise 
> #'api/path-entries 

Re: I can not find any function that might give rise to thisStackOverflow error

2017-04-01 Thread piastkrakow

> Because when you recur in your loop, you’re passing in lazy sequences, so 
those 
> are essentially building up a giant stack of delayed evaluations – and 
when you hit bottom 
> and try to realize those, that’s when your stack overflow hits you.

I was thinking the answer had something to do with the lazyness, but I 
wasn't sure because the app seemed to die before the loop finished -- which 
I assume is before the functions were realized. But it is possible the 
logging functions were slow and didn't show the whole truth. I am grateful 
to have someone with your experience clarify this. 

But does that mean one can't use functions to build up sequences in a loop? 
That seems to limit loops a great deal. 



On Saturday, April 1, 2017 at 10:22:04 PM UTC-4, Sean Corfield wrote:
>
> Because when you recur in your loop, you’re passing in lazy sequences, so 
> those are essentially building up a giant stack of delayed evaluations – 
> and when you hit bottom and try to realize those, that’s when your stack 
> overflow hits you.
>
>  
>
> By contrast, your reduce code is eager so the work is done as you work 
> through the sequence, instead of “stacked up” lazily, to be done later.
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> *From: *piast...@gmail.com 
> *Sent: *Saturday, April 1, 2017 6:52 PM
> *To: *Clojure 
> *Subject: *Re: I can not find any function that might give rise to 
> thisStackOverflow error
>
>  
>
>
> Crazy! I re-wrote the (loop) to use (reduce) instead and now everything 
> works: 
>
>
> (defn loop-over-scores
>   [set-of-scores]
>   "2017-03-08 -- called from start.clj"
>   (reduce
>;; 2017-04-01 -- we assume vector-with-path-score looks like this:
>;;  [[:positive :true 0.88 19 60 10 12 3 1 3 1 2 1] 1]
>;; so we do a minor bit of destructuring
>(fn [vector-of-maps-of-vector-key-and-score [vector-with-path score]]
>  (conj vector-of-maps-of-vector-key-and-score
>(dire/supervise #'map-of-vector-path-and-true-false-scores 
> vector-with-path)))
>[]
>set-of-scores))
>
>
> The StackOverflow error is gone. 
>
> Sad to say, I'm left with a feeling as if I know nothing about Clojure. I 
> don't know why (loop) gave me a StackOverflow error whereas (reduce) works 
> just fine. This is black magic to me, which, sad to say, is not a 
> comfortable feeling. 
>
>
>
>
>
>
> On Saturday, April 1, 2017 at 7:51:08 PM UTC-4, piast...@gmail.com wrote:
>
> Well, I am out of ideas. Let's assume I'll re-write this some other way. 
> What would be better than using (loop)? What would be less likely to cause 
> StackOverflow, or at least reveal why I'm seeing it. 
>
>
> On Saturday, April 1, 2017 at 6:23:29 PM UTC-4, piast...@gmail.com wrote:
>
>
> I have a function that will run repeatedly, so I use the at-at library to 
> call it:
>
> https://github.com/overtone/at-at
>
> I don't think this is the problem. 
>
> Sad to say, the Error is catching a StackOverflow, which I'm having 
> trouble finding. I don't see a place where I call a function recursively, 
> so I don't see where any of this becomes stackoverflow. 
>
> I'm using Dire to catch errors, but for now I'm just logging them. I don't 
> see anything fancy or clever that would give me a stackoverflow, and yet 
> this anonymous function called by at-at is definitely giving rise to 
> StackOverflow.
>
> (defn- calculate--scores []
>   (let [my-pool (at/mk-pool)]
> (at/every 18
>   (fn []
> (append-to-file "/var/log/example/-scores.log" "Will 
> attempt to write scores")
> (future 
>   (try 
> (let [
>   map-of-all-sums   
> (api/get-accuracy-and-precision)
>   set-of-all-scores (dire/supervise 
> #'api/path-entries map-of-all-sums)
>   path-and--scores (dire/supervise 
> #'api/loop-over-scores set-of-all-scores)
>   ]
>   (append-to-file "/var/log/example/-scores.log" 
> "\n\n\n\n\n")
>   (append-to-file "/var/log/example/-scores.log" " 
> path-and--scores: ")
>   (append-to-file "/var/log/example/-scores.log"  (str 
> "(count set-of-all-scores): " (count set-of-all-scores)))
>   (append-to-file "/var/log/example/-scores.log" 
> path-and--scores))
> (catch Exception e
>   (do
> (append-to-file "/var/log/example/-scores.log" 
> (str " EXCEPTION:: " e))
> (append-to-file "/var/log/example/-scores.log" 
> (stack/parse-exception e))
> (errors/error e)))
> (catch Error o
>   (println (str " a problem in the anonymous function 
> in calculate--scores: " o)))
>   

Re: I can not find any function that might give rise to this StackOverflow error

2017-04-01 Thread piastkrakow

Crazy! I re-wrote the (loop) to use (reduce) instead and now everything 
works: 


(defn loop-over-scores
  [set-of-scores]
  "2017-03-08 -- called from start.clj"
  (reduce
   ;; 2017-04-01 -- we assume vector-with-path-score looks like this:
   ;;  [[:positive :true 0.88 19 60 10 12 3 1 3 1 2 1] 1]
   ;; so we do a minor bit of destructuring
   (fn [vector-of-maps-of-vector-key-and-score [vector-with-path score]]
 (conj vector-of-maps-of-vector-key-and-score
   (dire/supervise #'map-of-vector-path-and-true-false-scores 
vector-with-path)))
   []
   set-of-scores))


The StackOverflow error is gone. 

Sad to say, I'm left with a feeling as if I know nothing about Clojure. I 
don't know why (loop) gave me a StackOverflow error whereas (reduce) works 
just fine. This is black magic to me, which, sad to say, is not a 
comfortable feeling. 






On Saturday, April 1, 2017 at 7:51:08 PM UTC-4, piast...@gmail.com wrote:
>
> Well, I am out of ideas. Let's assume I'll re-write this some other way. 
> What would be better than using (loop)? What would be less likely to cause 
> StackOverflow, or at least reveal why I'm seeing it. 
>
>
> On Saturday, April 1, 2017 at 6:23:29 PM UTC-4, piast...@gmail.com wrote:
>>
>>
>> I have a function that will run repeatedly, so I use the at-at library to 
>> call it:
>>
>> https://github.com/overtone/at-at
>>
>> I don't think this is the problem. 
>>
>> Sad to say, the Error is catching a StackOverflow, which I'm having 
>> trouble finding. I don't see a place where I call a function recursively, 
>> so I don't see where any of this becomes stackoverflow. 
>>
>> I'm using Dire to catch errors, but for now I'm just logging them. I 
>> don't see anything fancy or clever that would give me a stackoverflow, and 
>> yet this anonymous function called by at-at is definitely giving rise to 
>> StackOverflow.
>>
>> (defn- calculate--scores []
>>   (let [my-pool (at/mk-pool)]
>> (at/every 18
>>   (fn []
>> (append-to-file "/var/log/example/-scores.log" "Will 
>> attempt to write scores")
>> (future 
>>   (try 
>> (let [
>>   map-of-all-sums   
>> (api/get-accuracy-and-precision)
>>   set-of-all-scores (dire/supervise 
>> #'api/path-entries map-of-all-sums)
>>   path-and--scores (dire/supervise 
>> #'api/loop-over-scores set-of-all-scores)
>>   ]
>>   (append-to-file "/var/log/example/-scores.log" 
>> "\n\n\n\n\n")
>>   (append-to-file "/var/log/example/-scores.log" " 
>> path-and--scores: ")
>>   (append-to-file "/var/log/example/-scores.log"  
>> (str "(count set-of-all-scores): " (count set-of-all-scores)))
>>   (append-to-file "/var/log/example/-scores.log" 
>> path-and--scores))
>> (catch Exception e
>>   (do
>> (append-to-file "/var/log/example/-scores.log" 
>> (str " EXCEPTION:: " e))
>> (append-to-file "/var/log/example/-scores.log" 
>> (stack/parse-exception e))
>> (errors/error e)))
>> (catch Error o
>>   (println (str " a problem in the anonymous function 
>> in calculate--scores: " o)))
>> )))
>>   my-pool)))
>>
>>
>> The problem appears to be here, which will loop several thousand times 
>> and then die. But I don't see why. (This function used to just be a loop, 
>> and I added the (let) so I could see if I could read the end -- but I could 
>> not reach the end).
>>
>>
>>
>> (defn loop-over-scores
>>   [set-of-scores]
>>   "2017-03-08 -- called from start.clj"
>>   (try
>> (let [return-value  (loop [
>>how-many-loops 0
>>scores set-of-scores
>>vector-of-maps-of-vector-key-and-score []
>>]
>>
>>   (println  (str  " in loop-over-scores again " 
>> how-many-loops))
>>   (if (next scores)
>> (recur
>>  (inc how-many-loops)
>>  (remove #{(first scores)} scores)
>>  (conj vector-of-maps-of-vector-key-and-score 
>> (find-related-positive-negative-true-false-records scores (first scores
>> vector-of-maps-of-vector-key-and-score))
>>   ]
>>
>>   (println " return-value in loop-over-scores " return-value " in 
>> loop-over-scores")
>>   return-value)
>> (catch Exception e (println " exception in loop-over-scores: " e
>>
>>
>> So this line prints out a result several thousand times:
>>
>>   (println " return-value in loop-over-scores " return-value " in 
>> loop-over-scores")
>>
>>
>> 

Re: I can not find any function that might give rise to this StackOverflow error

2017-04-01 Thread piastkrakow
Well, I am out of ideas. Let's assume I'll re-write this some other way. 
What would be better than using (loop)? What would be less likely to cause 
StackOverflow, or at least reveal why I'm seeing it. 


On Saturday, April 1, 2017 at 6:23:29 PM UTC-4, piast...@gmail.com wrote:
>
>
> I have a function that will run repeatedly, so I use the at-at library to 
> call it:
>
> https://github.com/overtone/at-at
>
> I don't think this is the problem. 
>
> Sad to say, the Error is catching a StackOverflow, which I'm having 
> trouble finding. I don't see a place where I call a function recursively, 
> so I don't see where any of this becomes stackoverflow. 
>
> I'm using Dire to catch errors, but for now I'm just logging them. I don't 
> see anything fancy or clever that would give me a stackoverflow, and yet 
> this anonymous function called by at-at is definitely giving rise to 
> StackOverflow.
>
> (defn- calculate--scores []
>   (let [my-pool (at/mk-pool)]
> (at/every 18
>   (fn []
> (append-to-file "/var/log/example/-scores.log" "Will 
> attempt to write scores")
> (future 
>   (try 
> (let [
>   map-of-all-sums   
> (api/get-accuracy-and-precision)
>   set-of-all-scores (dire/supervise 
> #'api/path-entries map-of-all-sums)
>   path-and--scores (dire/supervise 
> #'api/loop-over-scores set-of-all-scores)
>   ]
>   (append-to-file "/var/log/example/-scores.log" 
> "\n\n\n\n\n")
>   (append-to-file "/var/log/example/-scores.log" " 
> path-and--scores: ")
>   (append-to-file "/var/log/example/-scores.log"  (str 
> "(count set-of-all-scores): " (count set-of-all-scores)))
>   (append-to-file "/var/log/example/-scores.log" 
> path-and--scores))
> (catch Exception e
>   (do
> (append-to-file "/var/log/example/-scores.log" 
> (str " EXCEPTION:: " e))
> (append-to-file "/var/log/example/-scores.log" 
> (stack/parse-exception e))
> (errors/error e)))
> (catch Error o
>   (println (str " a problem in the anonymous function 
> in calculate--scores: " o)))
> )))
>   my-pool)))
>
>
> The problem appears to be here, which will loop several thousand times and 
> then die. But I don't see why. (This function used to just be a loop, and I 
> added the (let) so I could see if I could read the end -- but I could not 
> reach the end).
>
>
>
> (defn loop-over-scores
>   [set-of-scores]
>   "2017-03-08 -- called from start.clj"
>   (try
> (let [return-value  (loop [
>how-many-loops 0
>scores set-of-scores
>vector-of-maps-of-vector-key-and-score []
>]
>
>   (println  (str  " in loop-over-scores again " 
> how-many-loops))
>   (if (next scores)
> (recur
>  (inc how-many-loops)
>  (remove #{(first scores)} scores)
>  (conj vector-of-maps-of-vector-key-and-score 
> (find-related-positive-negative-true-false-records scores (first scores
> vector-of-maps-of-vector-key-and-score))
>   ]
>
>   (println " return-value in loop-over-scores " return-value " in 
> loop-over-scores")
>   return-value)
> (catch Exception e (println " exception in loop-over-scores: " e
>
>
> So this line prints out a result several thousand times:
>
>   (println " return-value in loop-over-scores " return-value " in 
> loop-over-scores")
>
>
> And then I get stackoverflow.
>
> But nothing seems suspicious here:
>
>
> (defn find-related-positive-negative-true-false-records [set-of-scores 
> vector-with-path-score]
>   (println " in find-related-positive-negative-true-false-records the 
> vector-with-path-score "  vector-with-path-score)
>   
>   (let [
> [vector-with-path score] vector-with-path-score
> ;; 2017-03-08 -- seq-as-path should be something like [30 8 34 
> 20.94 2]
> seq-as-path (rest (rest vector-with-path))
>
> ;;_ (append-to-file "/var/log/example/-scores.log" "seq-as-path")
> ;; _ (append-to-file "/var/log/example/-scores.log" 
> seq-as-path)
> 
> vector-as-path (apply conj [] seq-as-path)
>
>  _ (append-to-file "/var/log/example/-scores.log" "vector-as-path")
>  _ (append-to-file "/var/log/example/-scores.log" vector-as-path)
> ]
> (dire/supervise #'map-of-vector-path-and-true-false-scores 
> vector-as-path)))
>
>
> Nor here:
>
>
> (defn 

Re: I can not find any function that might give rise to this StackOverflow error

2017-04-01 Thread piastkrakow
So for instances, starting with an object that has about 32,000 lines that 
need to be looped over, the code gets this far: 

 in loop-over-scores again 2375

It prints that out and then throws StackOverflow error. 

But I don't see anything in there that would exhaust the stack. These 
functions run, return a value, and are done. 



On Saturday, April 1, 2017 at 6:23:29 PM UTC-4, piast...@gmail.com wrote:
>
>
> I have a function that will run repeatedly, so I use the at-at library to 
> call it:
>
> https://github.com/overtone/at-at
>
> I don't think this is the problem. 
>
> Sad to say, the Error is catching a StackOverflow, which I'm having 
> trouble finding. I don't see a place where I call a function recursively, 
> so I don't see where any of this becomes stackoverflow. 
>
> I'm using Dire to catch errors, but for now I'm just logging them. I don't 
> see anything fancy or clever that would give me a stackoverflow, and yet 
> this anonymous function called by at-at is definitely giving rise to 
> StackOverflow.
>
> (defn- calculate--scores []
>   (let [my-pool (at/mk-pool)]
> (at/every 18
>   (fn []
> (append-to-file "/var/log/example/-scores.log" "Will 
> attempt to write scores")
> (future 
>   (try 
> (let [
>   map-of-all-sums   
> (api/get-accuracy-and-precision)
>   set-of-all-scores (dire/supervise 
> #'api/path-entries map-of-all-sums)
>   path-and--scores (dire/supervise 
> #'api/loop-over-scores set-of-all-scores)
>   ]
>   (append-to-file "/var/log/example/-scores.log" 
> "\n\n\n\n\n")
>   (append-to-file "/var/log/example/-scores.log" " 
> path-and--scores: ")
>   (append-to-file "/var/log/example/-scores.log"  (str 
> "(count set-of-all-scores): " (count set-of-all-scores)))
>   (append-to-file "/var/log/example/-scores.log" 
> path-and--scores))
> (catch Exception e
>   (do
> (append-to-file "/var/log/example/-scores.log" 
> (str " EXCEPTION:: " e))
> (append-to-file "/var/log/example/-scores.log" 
> (stack/parse-exception e))
> (errors/error e)))
> (catch Error o
>   (println (str " a problem in the anonymous function 
> in calculate--scores: " o)))
> )))
>   my-pool)))
>
>
> The problem appears to be here, which will loop several thousand times and 
> then die. But I don't see why. (This function used to just be a loop, and I 
> added the (let) so I could see if I could read the end -- but I could not 
> reach the end).
>
>
>
> (defn loop-over-scores
>   [set-of-scores]
>   "2017-03-08 -- called from start.clj"
>   (try
> (let [return-value  (loop [
>how-many-loops 0
>scores set-of-scores
>vector-of-maps-of-vector-key-and-score []
>]
>
>   (println  (str  " in loop-over-scores again " 
> how-many-loops))
>   (if (next scores)
> (recur
>  (inc how-many-loops)
>  (remove #{(first scores)} scores)
>  (conj vector-of-maps-of-vector-key-and-score 
> (find-related-positive-negative-true-false-records scores (first scores
> vector-of-maps-of-vector-key-and-score))
>   ]
>
>   (println " return-value in loop-over-scores " return-value " in 
> loop-over-scores")
>   return-value)
> (catch Exception e (println " exception in loop-over-scores: " e
>
>
> So this line prints out a result several thousand times:
>
>   (println " return-value in loop-over-scores " return-value " in 
> loop-over-scores")
>
>
> And then I get stackoverflow.
>
> But nothing seems suspicious here:
>
>
> (defn find-related-positive-negative-true-false-records [set-of-scores 
> vector-with-path-score]
>   (println " in find-related-positive-negative-true-false-records the 
> vector-with-path-score "  vector-with-path-score)
>   
>   (let [
> [vector-with-path score] vector-with-path-score
> ;; 2017-03-08 -- seq-as-path should be something like [30 8 34 
> 20.94 2]
> seq-as-path (rest (rest vector-with-path))
>
> ;;_ (append-to-file "/var/log/example/-scores.log" "seq-as-path")
> ;; _ (append-to-file "/var/log/example/-scores.log" 
> seq-as-path)
> 
> vector-as-path (apply conj [] seq-as-path)
>
>  _ (append-to-file "/var/log/example/-scores.log" "vector-as-path")
>  _ (append-to-file "/var/log/example/-scores.log" vector-as-path)
> ]
> 

I can not find any function that might give rise to this StackOverflow error

2017-04-01 Thread piastkrakow

I have a function that will run repeatedly, so I use the at-at library to 
call it:

https://github.com/overtone/at-at

I don't think this is the problem. 

Sad to say, the Error is catching a StackOverflow, which I'm having trouble 
finding. I don't see a place where I call a function recursively, so I 
don't see where any of this becomes stackoverflow. 

I'm using Dire to catch errors, but for now I'm just logging them. I don't 
see anything fancy or clever that would give me a stackoverflow, and yet 
this anonymous function called by at-at is definitely giving rise to 
StackOverflow.

(defn- calculate--scores []
  (let [my-pool (at/mk-pool)]
(at/every 18
  (fn []
(append-to-file "/var/log/example/-scores.log" "Will 
attempt to write scores")
(future 
  (try 
(let [
  map-of-all-sums   (api/get-accuracy-and-precision)
  set-of-all-scores (dire/supervise 
#'api/path-entries map-of-all-sums)
  path-and--scores (dire/supervise 
#'api/loop-over-scores set-of-all-scores)
  ]
  (append-to-file "/var/log/example/-scores.log" 
"\n\n\n\n\n")
  (append-to-file "/var/log/example/-scores.log" " 
path-and--scores: ")
  (append-to-file "/var/log/example/-scores.log"  (str 
"(count set-of-all-scores): " (count set-of-all-scores)))
  (append-to-file "/var/log/example/-scores.log" 
path-and--scores))
(catch Exception e
  (do
(append-to-file "/var/log/example/-scores.log" (str 
" EXCEPTION:: " e))
(append-to-file "/var/log/example/-scores.log" 
(stack/parse-exception e))
(errors/error e)))
(catch Error o
  (println (str " a problem in the anonymous function 
in calculate--scores: " o)))
)))
  my-pool)))


The problem appears to be here, which will loop several thousand times and 
then die. But I don't see why. (This function used to just be a loop, and I 
added the (let) so I could see if I could read the end -- but I could not 
reach the end).



(defn loop-over-scores
  [set-of-scores]
  "2017-03-08 -- called from start.clj"
  (try
(let [return-value  (loop [
   how-many-loops 0
   scores set-of-scores
   vector-of-maps-of-vector-key-and-score []
   ]

  (println  (str  " in loop-over-scores again " 
how-many-loops))
  (if (next scores)
(recur
 (inc how-many-loops)
 (remove #{(first scores)} scores)
 (conj vector-of-maps-of-vector-key-and-score 
(find-related-positive-negative-true-false-records scores (first scores
vector-of-maps-of-vector-key-and-score))
  ]

  (println " return-value in loop-over-scores " return-value " in 
loop-over-scores")
  return-value)
(catch Exception e (println " exception in loop-over-scores: " e


So this line prints out a result several thousand times:

  (println " return-value in loop-over-scores " return-value " in 
loop-over-scores")


And then I get stackoverflow.

But nothing seems suspicious here:


(defn find-related-positive-negative-true-false-records [set-of-scores 
vector-with-path-score]
  (println " in find-related-positive-negative-true-false-records the 
vector-with-path-score "  vector-with-path-score)
  
  (let [
[vector-with-path score] vector-with-path-score
;; 2017-03-08 -- seq-as-path should be something like [30 8 34 
20.94 2]
seq-as-path (rest (rest vector-with-path))

;;_ (append-to-file "/var/log/example/-scores.log" "seq-as-path")
;; _ (append-to-file "/var/log/example/-scores.log" 
seq-as-path)

vector-as-path (apply conj [] seq-as-path)

 _ (append-to-file "/var/log/example/-scores.log" "vector-as-path")
 _ (append-to-file "/var/log/example/-scores.log" vector-as-path)
]
(dire/supervise #'map-of-vector-path-and-true-false-scores 
vector-as-path)))


Nor here:


(defn map-of-vector-path-and-true-false-scores
  [vector-as-path]
  (println " at the start of map-of-vector-path-and-true-false-scores")
  (try 
(if-not (empty? vector-as-path)
  (let [
;; 2017-03-30 -- this fails:
;; user> (apply conj [:positive :false] (30 6 40))
;; ClassCastException java.lang.Long cannot be cast to 
clojure.lang.IFn  user/eval1719 (NO_SOURCE_FILE:1)
;;
;; but this works: 
;; user> (apply conj [:positive :false] '(30 6 40))
;;[:positive 

Re: ANN: Cognitect acquired by Microsoft

2017-04-01 Thread piastkrakow

I was completely horrified when I saw the title. Truly a moment when the 
Empire wins and the Rebels are defeated. 



On Saturday, April 1, 2017 at 4:08:26 PM UTC-4, solussd wrote:
>
> Beware the 1st of April. 
>
> ---
> Joseph Smith
> j...@uwcreations.com 
> @solussd
>
>
> On Apr 1, 2017, at 3:00 PM, Gregg Reynolds  > wrote:
>
> made ya look!
>
> -- 
> 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/d/optout.
>
>

-- 
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/d/optout.


Re: off-topic: stackof developer survey

2017-03-25 Thread piastkrakow
> doesn't drive me mad, but it does puzzle ans annoy 
> me.  puzzle: why is it?  not sure, personally.

I've seen this pattern at the last 2 startups that I've worked at: 

The startup hires a bunch of people as they graduate from college. They are 
hired to do data analysis, typically on some kind of financial data (these 
are the types of startups I've been at). These newly hired people have a 
background in math and statistics. They learned programming by accident, 
incidentally. They learned Python, because that was what was recommended in 
all of the college classes that they took. Then they graduate and start 
work at the startup, and when they need to program, they do it in Python, 
because that is what they know. They are learning a great deal, very fast, 
about the business world, and financial analysis; they don't feel they have 
the time to learn about a new programming language. 

Meanwhile, from the perspective of the startup, the history of their 
decisions went like this: they had an idea, so they contracted with a team 
in India to build the prototype -- the founding team had no one technical 
on staff, so they went with the cheapest option, which was PHP. So the crew 
in India builds a flawed prototype in PHP. The basic idea for the startup 
was good, and they make some money, so after a year they hire a CTO, who 
immediately wants to scrap the prototype and build solid, high quality 
software. The decision is made to move away from PHP. But what should they 
move toward? They are already hiring a large number of data analysts who 
know Python, so the most obvious option is to hire more Python programmers, 
and standardize the company around Python. 

I've seen this pattern more than once. 







On Friday, March 24, 2017 at 6:17:15 PM UTC-4, Gregg Reynolds wrote:
>
>
>
> On Mar 24, 2017 5:05 PM,  wrote:
>
>
>
> > This did get me thinking though. If the community *did* want to score 
> highly 
> > on some of these metrics, what would those be?
>
> I'll be happy so long as Clojure is the popular choice for doing the 
> things where it's advantages should matter: machine learning, AI, NLP, 
> concurrent programming. 
>
> It drives me crazy that Python is doing so well in all of the areas where 
> Clojure should be winning. There are such beautiful libraries for working 
> with vectors and matrices with Clojure, which should obviously help with 
> NLP, yet people use Python instead. Likewise, so much of machine learning 
> should be done as work in parallel, and Clojure makes that easy, yet Python 
> is preferred. Drives me crazy. 
>
>
> doesn't drive me mad, but it does puzzle ans annoy me.  puzzle: why is it? 
>  not sure, personally.
>
>
> These last few years I've been at a lot of NLP startups, and the choice of 
> Python makes me sad. 
>
>
>
>
> On Wednesday, March 22, 2017 at 7:17:10 PM UTC-4, Luke Burton wrote:
>
>>
>> On Mar 22, 2017, at 2:26 PM, Gregg Reynolds  wrote:
>>
>> very interesting stuff, esp. the sociological bits:
>>
>> http://stackoverflow.com/insights/survey/2017
>>
>> sadly, clojure does not even rank in popularity.  but it's number 1 in 
>> pay worldwide.  o sweet vengeance!
>>
>>
>> Some fun reading in there, Clojure features a couple of times. It would 
>> be fun to watch for spikes in traffic to Clojure related resources, because 
>> I'm sure that landing "most highly paid" will cause a few people to sit up 
>> and take notice.
>>
>> This did get me thinking though. If the community *did* want to score 
>> highly on some of these metrics, what would those be? Or do none of them 
>> adequately capture what is valued by the Clojure community?
>>
>> I think I'd claim that popularity is a terrible metric, even though it 
>> can be gratifying to be popular. The fact that lots of people do a 
>> particular thing doesn't mean that thing is inherently good, or worth 
>> striving for. Some very popular things are bad lifestyle choices, like 
>> smoking, a diet high in sugary foods, and writing JavaScript.
>>
>> Conversely some very, very good things can die from even the perception 
>> of being unpopular. We often get people asking on the subreddit why they 
>> find so many "abandoned" libraries in Clojure. The fact a piece of software 
>> might have been written years ago, and still be perfectly usable, is such 
>> an anomaly in more "popular" languages that people assume we've all curled 
>> up and died. I recently had a project steered away from Clojure (suffice to 
>> say it was a very good fit, I thought) due to concerns around the 
>> availability of Clojure programmers in the long term. In Silicon Valley. 
>> Where you can throw a rock in the air and be certain it will hit a 
>> programmer on the way down.
>>
>> Anyway, my personal metric for Clojure success would be: "for projects 
>> where Clojure is an appropriate technical fit, how often are you able to 
>> choose Clojure?" It's a selfish metric but the higher it goes, 

Re: off-topic: stackof developer survey

2017-03-24 Thread piastkrakow


> This did get me thinking though. If the community *did* want to score 
highly 
> on some of these metrics, what would those be?

I'll be happy so long as Clojure is the popular choice for doing the things 
where it's advantages should matter: machine learning, AI, NLP, concurrent 
programming. 

It drives me crazy that Python is doing so well in all of the areas where 
Clojure should be winning. There are such beautiful libraries for working 
with vectors and matrices with Clojure, which should obviously help with 
NLP, yet people use Python instead. Likewise, so much of machine learning 
should be done as work in parallel, and Clojure makes that easy, yet Python 
is preferred. Drives me crazy. 

These last few years I've been at a lot of NLP startups, and the choice of 
Python makes me sad. 




On Wednesday, March 22, 2017 at 7:17:10 PM UTC-4, Luke Burton wrote:
>
>
> On Mar 22, 2017, at 2:26 PM, Gregg Reynolds  > wrote:
>
> very interesting stuff, esp. the sociological bits:
>
> http://stackoverflow.com/insights/survey/2017
>
> sadly, clojure does not even rank in popularity.  but it's number 1 in pay 
> worldwide.  o sweet vengeance!
>
>
> Some fun reading in there, Clojure features a couple of times. It would be 
> fun to watch for spikes in traffic to Clojure related resources, because 
> I'm sure that landing "most highly paid" will cause a few people to sit up 
> and take notice.
>
> This did get me thinking though. If the community *did* want to score 
> highly on some of these metrics, what would those be? Or do none of them 
> adequately capture what is valued by the Clojure community?
>
> I think I'd claim that popularity is a terrible metric, even though it can 
> be gratifying to be popular. The fact that lots of people do a particular 
> thing doesn't mean that thing is inherently good, or worth striving for. 
> Some very popular things are bad lifestyle choices, like smoking, a diet 
> high in sugary foods, and writing JavaScript.
>
> Conversely some very, very good things can die from even the perception of 
> being unpopular. We often get people asking on the subreddit why they find 
> so many "abandoned" libraries in Clojure. The fact a piece of software 
> might have been written years ago, and still be perfectly usable, is such 
> an anomaly in more "popular" languages that people assume we've all curled 
> up and died. I recently had a project steered away from Clojure (suffice to 
> say it was a very good fit, I thought) due to concerns around the 
> availability of Clojure programmers in the long term. In Silicon Valley. 
> Where you can throw a rock in the air and be certain it will hit a 
> programmer on the way down.
>
> Anyway, my personal metric for Clojure success would be: "for projects 
> where Clojure is an appropriate technical fit, how often are you able to 
> choose Clojure?" It's a selfish metric but the higher it goes, the happier 
> I am ;)
>
> Luke.
>

-- 
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/d/optout.


What would be the easiest way for people's Rails app, PHP app, NodeJS app, etc, to ping my Clojure app on the same server?

2017-03-15 Thread piastkrakow
Not especially a Clojure question, though my app is in Clojure, so I have 
all the tools of the JVM to work with. 

Suppose I release a small Clojure app that people should run on the 
servers, and it releases some data over some port. Let's say port 4. 
The idea is that I want this data from them, and so I'm trying to make it 
easy for them to publish this data. I release this app as an open source, 
and I hope people will run in on their servers. I assume these people will 
be running all kinds of apps on their servers: PHP apps, Rails apps, NodeJS 
apps, Java apps, WordPress, Django, etc. 

What's the easiest way to let those apps ping my app? I don't want to 
assume port 80 because I assume they already have some app using port 80. 
And if we are talking about a typical WordPress developer, they might lack 
the skill to know how to establish a reverse proxy. So I thought perhaps 
the easiest thing would be to listen on a file socket? Because I think even 
a beginner PHP programmer would know how to write data to a file socket? 
There are lots of examples of 10 lines snippets teaching them how to do it. 

I could also ask them to simply send a HTTP request to my server, though 
I'm wondering if there is anything I can do that would be even easier and 
more automatic than that. I suppose I could write an app that watches their 
log files, though that would mean keeping in mind the different formats of 
Rails logs versus Apache logs, and knowing where the crucial data would 
appear. And even Apache and Nginix logs can be configured to show more or 
less data on different servers. 

But I am just guessing. Does anyone have a thought about this?  I'm trying 
to think of the most automatic way to get data about certain activities 
that happen on their server, which they may wish to advertise. 

I might just go with a traditional "they should ping my API" but if I could 
think of something even more automatic, that would be ideal. Watching their 
log files would be the easiest thing, though the logs are not 100% 
standard. 

-- 
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/d/optout.


Re: How to transform deeply nested map into a series of arrays?

2017-03-08 Thread piastkrakow

That is a great article. Possibly there is a solution to this using 
tree-seq. I hope to explore that at some point. 


On Wednesday, March 8, 2017 at 3:50:02 PM UTC-5, Erik Assum wrote:
>
> You've already gotten your answer, but since Alex mentioned postwalk, and 
> the problem looks like a flattening problem, I thought the following post 
> might be of interest:
>
> https://mwfogleman.github.io/posts/20-12-2014-flatcat.html
>
>
> Erik. 
> -- 
> i farta
>
> Den 8. mar. 2017 kl. 18.38 skrev piast...@gmail.com :
>
>
> Given this: 
>
> {:positive :true {30 {4 {50 43, 1000 32}, 6 {40 12, 90 2}, 8 {777 23, 9090 
> 1}}}
>
> I'd like a series of arrays that I can feed into (reduce) so I can easily 
> sum them:
>
> [ 30 4 50 43 ]
>
> [ 30 4 1000 32 ]
>
> [ 30 6 40 12 ]
>
> [ 30 6 90 2 ]
>
> [ 30 8 777 23 ]
>
> [ 30 8 9090 1 ]
>
> I've been trying to work this out using "walk" recursively, but then I 
> wondered if perhaps I am missing something obvious? Does Clojure offer a 
> straightforward way to do this?
>
>
>
>
>
> -- 
> 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/d/optout.
>
>

-- 
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/d/optout.


Re: How to transform deeply nested map into a series of arrays?

2017-03-08 Thread piastkrakow
Thank you, Alex. That makes sense. What is the main use case for walk?


On Wednesday, March 8, 2017 at 3:16:42 PM UTC-5, Alex Miller wrote:
>
> Usually the walk solution for transformation is easiest with postwalk:
>
> (require '[clojure.walk :refer [postwalk]])
>
> (defn m-to-v [m]
>   (if (map? m)
> (mapcat
>   (fn [[k v :as e]]
> (if (coll? v)
>   (mapv #(into [k] %1) v)
>   [e]))
>   m)
> m))
>
> (postwalk m-to-v data)
>
>
>
> On Wednesday, March 8, 2017 at 11:38:18 AM UTC-6, piast...@gmail.com 
>  wrote:
>>
>>
>> Given this: 
>>
>> {:positive :true {30 {4 {50 43, 1000 32}, 6 {40 12, 90 2}, 8 {777 23, 
>> 9090 1}}}
>>
>> I'd like a series of arrays that I can feed into (reduce) so I can easily 
>> sum them:
>>
>> [ 30 4 50 43 ]
>>
>> [ 30 4 1000 32 ]
>>
>> [ 30 6 40 12 ]
>>
>> [ 30 6 90 2 ]
>>
>> [ 30 8 777 23 ]
>>
>> [ 30 8 9090 1 ]
>>
>> I've been trying to work this out using "walk" recursively, but then I 
>> wondered if perhaps I am missing something obvious? Does Clojure offer a 
>> straightforward way to do this?
>>
>>
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/d/optout.


Re: How to transform deeply nested map into a series of arrays?

2017-03-08 Thread piastkrakow
Thank you so much! Your solution was almost perfect. It gave me: 

#{[[:positive :false 30 8 9090] 1] [[:negative :true 30 4 50] 43] 
[[:positive :false 30 4 1000] 32] [[:positive :true 30 8 9090] 1] 
[[:positive :false 30 4 50] 43] [[:negative :true 30 8 9090] 1] [[:negative 
:false 30 4 50] 43] [[:positive :true 30 4 50] 43] [[:negative :true 30 4 
1000] 32] [[:positive :true 30 6 90] 2] [[:negative :false 30 6 90] 2] 
[[:positive :false 30 6 40] 12] [[:positive :false 30 8 777] 23] 
[[:negative :false 30 4 1000] 32] [[:positive :true 30 8 777] 23] 
[[:negative :true 30 6 90] 2] [[:negative :true 30 6 40] 12] [[:positive 
:true 30 4 1000] 32] [[:positive :true 30 6 40] 12] [[:negative :true 30 8 
777] 23] [[:negative :false 30 8 777] 23] [[:positive :false 30 6 90] 2] 
[[:negative :false 30 6 40] 12] [[:negative :false 30 8 9090] 1]}

I changed this: 

[[ path v]]

to this:
[(conj path v)]

and got: 

#{[:positive :false 30 6 40 12] [:positive :false 30 4 50 43] [:negative 
:false 30 4 1000 32] [:negative :false 30 6 90 2] [:negative :true 30 8 777 
23] [:positive :false 30 6 90 2] [:negative :false 30 8 9090 1] [:negative 
:false 30 6 40 12] [:negative :true 30 6 90 2] [:positive :true 30 8 9090 
1] [:negative :true 30 4 50 43] [:positive :true 30 6 90 2] [:negative 
:true 30 6 40 12] [:positive :true 30 8 777 23] [:positive :true 30 4 1000 
32] [:negative :true 30 8 9090 1] [:positive :true 30 4 50 43] [:negative 
:false 30 8 777 23] [:positive :false 30 4 1000 32] [:positive :true 30 6 
40 12] [:positive :false 30 8 777 23] [:negative :false 30 4 50 43] 
[:positive :false 30 8 9090 1] [:negative :true 30 4 1000 32]}

You saved me many hours of stumbling around in the dark!

--- lawrence



On Wednesday, March 8, 2017 at 12:49:16 PM UTC-5, lvh ‌ wrote:
>
> Hi!
>
>
> Suggested recursive impl:
>
> (defn path-entries
>   ([obj]
>(path-entries [] obj))
>   ([prefix obj]
>(into #{}
>  (mapcat
>   (fn [[k v]]
> (let [path (conj prefix k)]
>   (if (map? v)
> (entries path v)
> [[path v]]
>  obj)))
>
>
> You could do this with an explicit stack, too, I'm sure.  For the size of 
> data you're suggesting it doesn't seem to matter much -- and I'm sure 
> someone clever could turn this into a TCO-able version too :)
>
>
> On Wed, Mar 8, 2017 at 11:38 AM,  wrote:
>
>>
>> Given this: 
>>
>> {:positive :true {30 {4 {50 43, 1000 32}, 6 {40 12, 90 2}, 8 {777 23, 
>> 9090 1}}}
>>
>> I'd like a series of arrays that I can feed into (reduce) so I can easily 
>> sum them:
>>
>> [ 30 4 50 43 ]
>>
>> [ 30 4 1000 32 ]
>>
>> [ 30 6 40 12 ]
>>
>> [ 30 6 90 2 ]
>>
>> [ 30 8 777 23 ]
>>
>> [ 30 8 9090 1 ]
>>
>> I've been trying to work this out using "walk" recursively, but then I 
>> wondered if perhaps I am missing something obvious? Does Clojure offer a 
>> straightforward way to do this?
>>
>>
>>
>>
>>
>> -- 
>> 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/d/optout.
>>
>
>

-- 
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/d/optout.


How to transform deeply nested map into a series of arrays?

2017-03-08 Thread piastkrakow

Given this: 

{:positive :true {30 {4 {50 43, 1000 32}, 6 {40 12, 90 2}, 8 {777 23, 9090 
1}}}

I'd like a series of arrays that I can feed into (reduce) so I can easily 
sum them:

[ 30 4 50 43 ]

[ 30 4 1000 32 ]

[ 30 6 40 12 ]

[ 30 6 90 2 ]

[ 30 8 777 23 ]

[ 30 8 9090 1 ]

I've been trying to work this out using "walk" recursively, but then I 
wondered if perhaps I am missing something obvious? Does Clojure offer a 
straightforward way to do this?





-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/d/optout.


Re: What is wrong with this simple Regex?

2017-03-08 Thread piastkrakow
Thank you.


On Wednesday, March 8, 2017 at 12:11:26 PM UTC-5, Sean Corfield wrote:
>
> Because you have a space in your regex, it is treated as a range, from 
> space to underscore which matches a lot of characters. Move the – to the 
> start:
>
>  
>
> (clojure.string/replace phone  #"[- _]"  garbage) 
>
>  
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> On 3/8/17, 9:01 AM, "clo...@googlegroups.com  on behalf of 
> piast...@gmail.com "  on behalf of piast...@gmail.com > wrote:
>
>  
>
> I built a string matching system, so when we get new records, from 
> crawling the web, we can find out if we already have the same information 
> in the database. There are many parameters to tune, and so I wanted to 
> generate the F1 score for the different parameters. I can easily test True 
> Positives and False Negatives by pulling all the data from the database and 
> firing it at my string matching system. Every record should be a True 
> Positive, since it is coming from our own database. But I also want to find 
> the True Negatives and False Positives, so I am trying to write some code 
> that will garble the database data. So at the REPL I do this: 
>
>  
>
> user> (def phone "+31-162-374000")
>
>  
>
> user> (def garbage "")
>
>  
>
> This does what I want:
>
>  
>
> user> (clojure.string/replace phone  #"[ -]"  garbage) 
>
> "+31162374000"
>
>  
>
>  
>
> This doesn't:
>
>  
>
> user> (clojure.string/replace phone  #"[ -_]"  garbage) 
>
> ""
>
>  
>
> and this doesn't:
>
>  
>
> user> (clojure.string/replace phone  #"[ -\_]"  garbage) 
>
> ""
>
>  
>
> What am I doing wrong here? How do I match against an underscore?
>
>  
>
> -- 
> 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/d/optout.
>
>

-- 
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/d/optout.


What is wrong with this simple Regex?

2017-03-08 Thread piastkrakow
I built a string matching system, so when we get new records, from crawling 
the web, we can find out if we already have the same information in the 
database. There are many parameters to tune, and so I wanted to generate 
the F1 score for the different parameters. I can easily test True Positives 
and False Negatives by pulling all the data from the database and firing it 
at my string matching system. Every record should be a True Positive, since 
it is coming from our own database. But I also want to find the True 
Negatives and False Positives, so I am trying to write some code that will 
garble the database data. So at the REPL I do this: 

user> (def phone "+31-162-374000")

user> (def garbage "")

This does what I want:

user> (clojure.string/replace phone  #"[ -]"  garbage) 
"+31162374000"


This doesn't:

user> (clojure.string/replace phone  #"[ -_]"  garbage) 
""

and this doesn't:

user> (clojure.string/replace phone  #"[ -\_]"  garbage) 
""

What am I doing wrong here? How do I match against an underscore?

-- 
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/d/optout.


Re: why doesn't java.lang.ArithmeticException have Exception as a parent?

2017-03-07 Thread piastkrakow
Thanks for that. I couldn't figure this one out. But using your suggestion, 
I finally get what I expected: 

(try (/ 4 0) (catch ArithmeticException e (println (ancestors (type e)
#{java.lang.Exception java.lang.Throwable java.lang.RuntimeException 
java.lang.Object java.io.Serializable}



On Tuesday, March 7, 2017 at 7:15:07 PM UTC-5, Gary Trakhman wrote:
>
> Turns out ancestors works on the class, not the instance:
> > (ancestors ArithmeticException)
> #{java.lang.Throwable java.io.Serializable java.lang.Exception 
> java.lang.RuntimeException java.lang.Object}
>
> > (ancestors (new ArithmeticException))
> nil
>
>
> On Tue, Mar 7, 2017 at 7:05 PM  wrote:
>
>> This gives me nil:
>>
>> (try (/ 4 0) (catch Exception e (println (parents e
>>
>> This too:
>>
>> (try (/ 4 0) (catch Exception e (println (ancestors e
>>
>> This too:
>>
>> (try (/ 4 0) (catch ArithmeticException e (println (ancestors e
>>
>> How is this possible? Shouldn't Exception be an ancestor? 
>>
>> Or, more generally, shouldn't something be a parent? 
>>
>>
>>
>> -- 
>> 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/d/optout.
>>
>

-- 
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/d/optout.


why doesn't java.lang.ArithmeticException have Exception as a parent?

2017-03-07 Thread piastkrakow
This gives me nil:

(try (/ 4 0) (catch Exception e (println (parents e

This too:

(try (/ 4 0) (catch Exception e (println (ancestors e

This too:

(try (/ 4 0) (catch ArithmeticException e (println (ancestors e

How is this possible? Shouldn't Exception be an ancestor? 

Or, more generally, shouldn't something be a parent? 



-- 
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/d/optout.


Re: Application silently shuts down by itself after running for some hours

2017-03-07 Thread piastkrakow
I asked the same question a year ago. The problem was that I was getting an 
OutOfMemoryError. This is an Error but it is not an Exception. If you catch 
all Exceptions, you will still not catch the OutOfMemoryError. You have to 
catch that too. 



On Tuesday, March 7, 2017 at 2:54:26 PM UTC-5, Kevin Corcoran wrote:
>
> On Mon, Mar 6, 2017 at 11:56 PM, JokkeB  
> wrote:
>
>> After adding this, I still can't see an exception before the app dies.
>>
>
> I've encountered this before when the Linux "OOM killer" kicks in, which 
> is especially likely if you are running your application on a 
> resource-constrained system (say, a VM with a low RAM allocation) or your 
> application is competing with other programs for memory.
>
>

-- 
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/d/optout.


NullPointerException on ManagementFactory/getThreadMXBean ???

2016-01-25 Thread piastkrakow
I've never had this problem before, but now I'm getting this:

in resource-usage there was this exception:  #

at startup, for this function: 

(defn- resource-usage []
  (let [my-pool (at/mk-pool)]
(at/every 6
  (fn []
(try
  (timbre/log :trace "Resource usage: "
  
(monitoring/show-stats-regarding-resources-used-by-this-app))
  (doseq [x (monitoring/thread-top)]
(timbre/log :trace x))
  (catch Exception e (println "in resource-usage there was 
this exception: " e
  my-pool)))


This line:

  (timbre/log :trace "Resource usage: "
  
(monitoring/show-stats-regarding-resources-used-by-this-app))

Correctly gives me:

Resource usage:  Memory in use (percentage/used/max-heap): ("9%" "43M" 
"444M")

So the problem comes here: 

  (doseq [x (monitoring/thread-top)]
(timbre/log :trace x))

Which relies on java.lang.management.ManagementFactory

(defn thread-top
  "Return a seq of threads sorted by their total userland CPU usage."
  []
  (let [mgr (ManagementFactory/getThreadMXBean)
cpu-times (map (fn [t]
 [(.getThreadCpuTime mgr (.getId t)) t])
(threads))]
(map
  (fn [[cpu t]] [cpu (.getName t) (.getId t) t])
  (reverse (sort-by first cpu-times)


With some code borrowed from here: 

http://lifeisagraph.com/2011/04/24/debugging-clojure.html

Does anyone see a place where a NullPointerException might get started? 

I assume this must be some circumstance unique to startup. I don't think 
this problem repeats. 



-- 
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/d/optout.


Re: NullPointerException on ManagementFactory/getThreadMXBean ???

2016-01-25 Thread piastkrakow

This error is also intermittent. It doesn't happen every time I start the 
app. I would guess this is some kind of timing issue, but I can't think 
where the issue of timing comes up. 


On Monday, January 25, 2016 at 4:04:50 PM UTC-5, piast...@gmail.com wrote:
>
> I've never had this problem before, but now I'm getting this:
>
> in resource-usage there was this exception:  # java.lang.NullPointerException>
>
> at startup, for this function: 
>
> (defn- resource-usage []
>   (let [my-pool (at/mk-pool)]
> (at/every 6
>   (fn []
> (try
>   (timbre/log :trace "Resource usage: "
>   
> (monitoring/show-stats-regarding-resources-used-by-this-app))
>   (doseq [x (monitoring/thread-top)]
> (timbre/log :trace x))
>   (catch Exception e (println "in resource-usage there was 
> this exception: " e
>   my-pool)))
>
>
> This line:
>
>   (timbre/log :trace "Resource usage: "
>   
> (monitoring/show-stats-regarding-resources-used-by-this-app))
>
> Correctly gives me:
>
> Resource usage:  Memory in use (percentage/used/max-heap): ("9%" "43M" 
> "444M")
>
> So the problem comes here: 
>
>   (doseq [x (monitoring/thread-top)]
> (timbre/log :trace x))
>
> Which relies on java.lang.management.ManagementFactory
>
> (defn thread-top
>   "Return a seq of threads sorted by their total userland CPU usage."
>   []
>   (let [mgr (ManagementFactory/getThreadMXBean)
> cpu-times (map (fn [t]
>  [(.getThreadCpuTime mgr (.getId t)) t])
> (threads))]
> (map
>   (fn [[cpu t]] [cpu (.getName t) (.getId t) t])
>   (reverse (sort-by first cpu-times)
> 
>
> With some code borrowed from here: 
>
> http://lifeisagraph.com/2011/04/24/debugging-clojure.html
>
> Does anyone see a place where a NullPointerException might get started? 
>
> I assume this must be some circumstance unique to startup. I don't think 
> this problem repeats. 
>
>
>
>

-- 
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/d/optout.


Any tutorials for setting up Ring/Jetty as HTTPS, reverse proxy through Apache?

2015-12-03 Thread piastkrakow
Can anyone point me to a good tutorial about setting up a Ring/Jetty app 
that works through a reverse proxy via Apache? 


-- 
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/d/optout.


Re: OOM error but Memory in use (percentage/used/max-heap): (6% 228M 3342M)

2015-08-11 Thread piastkrakow
This error seems related to Redis: 

http://stackoverflow.com/questions/18430324/redis-error-oom-command-not-allowed-when-used-memory-maxmemory


On Tuesday, August 11, 2015 at 1:09:03 PM UTC-4, piast...@gmail.com wrote:


 I do not know much about the JVM. I never worked with Java, though I am 
 now working with Clojure. I am getting this error:

 clojure.lang.ExceptionInfo: OOM command not allowed when used memory  
 'maxmemory'. {:prefix :oom} stack trace: {:class 
 clojure.lang.ExceptionInfo, :message \OOM command not allowed when used 
 memory  'maxmemory'.\

 We have a server that has 20 gigs of physical RAM, though the app itself 
 has these memory limits: 

   :jvm-opts [-Xms300m -Xmx2000m -XX:-UseCompressedOops]

 I saw that Sean Corfield posted this code to track memory use, so I have 
 been using this to keep track of my app's memory usage: 

 (defn- memory-bean
   Return the MemoryMXBean.
   []
   (java.lang.management.ManagementFactory/getMemoryMXBean))

 (defn- heap-usage
   Given a MemoryMXBean, return the heap memory usage.
   [^java.lang.management.MemoryMXBean bean]
   (.getHeapMemoryUsage bean))

 (defn- heap-used-max
   Given heap memory usage, return a pair of used/max values.
   [^java.lang.management.MemoryUsage usage]
   [(.getUsed usage) (.getMax usage)])

 (defn memory-usage
   Return percentage, used, max heap as strings.
   []
   (let [used-max (- (memory-bean) (heap-usage) (heap-used-max))]
 (cons (as-percentage used-max)
   (as-megabytes used-max


 Right now I have this run every 60 seconds, so I can keep track of what is 
 happening in my app. In my logs, a few seconds after I get the OOM error, I 
 see this output: 

 Resource usage:  
 Memory in use (percentage/used/max-heap): (\6%\ \228M\ \3342M\)
 CPU usage (how-many-cpu's/load-average):  [6 1.81]
 Free memory in jvm: [363319552]

 Perhaps I am reading this wrong? It looks like the app is not using much 
 RAM, yet I get an OOM error? This leaves me confused. 

 In the stacktrace, the line that triggers the OOM error is a line where I 
 write a string into Redis, using the Carmine library: 

 (carmine/hset document-id alert alert-as-string)

 But the string alert-as-string is very small, only about 200 characters, 
 so I can not imagine how that puts any strain on memory. 





-- 
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/d/optout.


OOM error but Memory in use (percentage/used/max-heap): (6% 228M 3342M)

2015-08-11 Thread piastkrakow

I do not know much about the JVM. I never worked with Java, though I am now 
working with Clojure. I am getting this error:

clojure.lang.ExceptionInfo: OOM command not allowed when used memory  
'maxmemory'. {:prefix :oom} stack trace: {:class 
clojure.lang.ExceptionInfo, :message \OOM command not allowed when used 
memory  'maxmemory'.\

We have a server that has 20 gigs of physical RAM, though the app itself 
has these memory limits: 

  :jvm-opts [-Xms300m -Xmx2000m -XX:-UseCompressedOops]

I saw that Sean Corfield posted this code to track memory use, so I have 
been using this to keep track of my app's memory usage: 

(defn- memory-bean
  Return the MemoryMXBean.
  []
  (java.lang.management.ManagementFactory/getMemoryMXBean))

(defn- heap-usage
  Given a MemoryMXBean, return the heap memory usage.
  [^java.lang.management.MemoryMXBean bean]
  (.getHeapMemoryUsage bean))

(defn- heap-used-max
  Given heap memory usage, return a pair of used/max values.
  [^java.lang.management.MemoryUsage usage]
  [(.getUsed usage) (.getMax usage)])

(defn memory-usage
  Return percentage, used, max heap as strings.
  []
  (let [used-max (- (memory-bean) (heap-usage) (heap-used-max))]
(cons (as-percentage used-max)
  (as-megabytes used-max


Right now I have this run every 60 seconds, so I can keep track of what is 
happening in my app. In my logs, a few seconds after I get the OOM error, I 
see this output: 

Resource usage:  
Memory in use (percentage/used/max-heap): (\6%\ \228M\ \3342M\)
CPU usage (how-many-cpu's/load-average):  [6 1.81]
Free memory in jvm: [363319552]

Perhaps I am reading this wrong? It looks like the app is not using much 
RAM, yet I get an OOM error? This leaves me confused. 

In the stacktrace, the line that triggers the OOM error is a line where I 
write a string into Redis, using the Carmine library: 

(carmine/hset document-id alert alert-as-string)

But the string alert-as-string is very small, only about 200 characters, so 
I can not imagine how that puts any strain on memory. 



-- 
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/d/optout.


When is [] a vector?

2015-06-02 Thread piastkrakow
I don't know how to read this: 

http://www.leonardoborges.com/writings/2012/12/02/monads-in-small-bites-part-ii-applicative-functors/

(defmulti pure (fn [f _] f))(defmethod pure List [_ v]Wraps value v in a 
list(List. [v]))


Is this a List followed by a vector of 2 elements, or this a List object 
whose constructor is being called with 2 arguments? 

List [_ v]


Also, am I correct to say that _ is used instead of f purely to 
communicate intent to the next human developer who looks at this? It can 
not be indicating a type or a signature to the JVM, yes? 



-- 
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/d/optout.


Re: Education on Dynamic Binding

2015-05-29 Thread piastkrakow
What blog posts did you find useful?


On Tuesday, May 26, 2015 at 10:01:29 PM UTC-4, andy.c...@fundingcircle.com 
wrote:

 This page on Jira says that dynamic binding should be documented as The 
 Clojure Way to do error handling. Was this ever done? I managed to find a 
 few blog posts discussing approach but nothing official.

 http://dev.clojure.org/display/design/Error+Handling

 Cheers,
 Andy


-- 
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/d/optout.


Re: Advice when running java -jar rather than a managed server like tomcat?

2015-05-29 Thread piastkrakow
Stuart, about the JSVC, I am curious if you have an opinion about the 
argument made in the comments of this blog post: 

Great post, but in reality you should never write app that daemonize them 
self. Always use supervisors that your system provides.

http://www.rkn.io/2014/02/06/clojure-cookbook-daemons/





On Wednesday, May 27, 2015 at 3:53:24 AM UTC-4, Stuart Sierra wrote:

 JSVC (Apache Commons daemon for Unix) is excellent for this sort of thing. 
 There's a Windows Services version too.
 –S


 On Tuesday, May 26, 2015 at 12:38:30 PM UTC+1, Colin Yates wrote:

 Hi,

 I am venturing into new territory using http-kit, as I usually use a 
 'managed' web server container like tomcat and have a few questions about 
 packing and running a JAR file:

  - are there are convenient service wrappers for windows and/or Linux
  - any best practice around managing class path for things like 
 logback.xml

 I have a jar created from lein uberjar and java -jar the.jar works, but 
 this seems a long way away from automated deployment :).

 Any advice welcome - 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/d/optout.


Re: How can I remove this nil? check from my code?

2015-05-29 Thread piastkrakow

Thank you all. I especially like the use of reduce-kv and the 2 fnils. I 
looked at reduce-kv, but I was too stupid to figure out how to apply it 
here. 


On Tuesday, May 26, 2015 at 12:27:16 PM UTC-4, Francis Avila wrote:

 Your two functions can be written more succinctly (and with fewer explicit 
 conditionals) like these, but they will be harder for a beginner to 
 understand. (The nested update-in with fnil in particular may cause 
 confusion.)


 (defn add-placeholder-to-history [users]
   (reduce-kv (fn [users uk {:keys [history]}]
(assoc-in users [uk :history]
  (into [{}] (take 2 history
 users users))


 (defn update-history [users {:keys [category prize-money winner]}]
   (update-in users [winner]
 (fnil update-in {:history [{}]}) [:history 0 category]
 (fnil + 0) prize-money))


 You may have a good pedagogical reason for your current implementation, 
 but I would take a different approach: build the new history entries first, 
 then add them to the users.


 (defn winnings-by-user [contests]
   (reduce
 (fn [user+winning {:keys [category winner prize-money]}]
   (update-in user+winning [winner category] (fnil + 0) prize-money))
 {} contests))

 (defn update-histories [users new-winnings]
   (let [all-user-keys (set (concat (keys users) (keys new-winnings)))]
 (reduce (fn [users ukey]
   (update-in users [ukey :history]
 #(into [(get new-winnings ukey {})] (take 2 %
   users all-user-keys)))


 (update-histories users (winnings-by-user contests))







 On Tuesday, May 26, 2015 at 12:37:34 AM UTC-5, Chris Freeman wrote:

 It seems like, if you don't mind doing the assoc all the time, you could 
 replace the whole if with something like:

 (assoc nu (:winner c) (or ((:winner c) nu) {:history [{}]}))

 You might want to wrap that in a let so you don't repeat (:winner c). 

 Also, it looks like add-placeholder-to-history could be a map over an 
 update-in instead of a loop, like:

 (defn prepend-hash [x]
   (into [{}] x))

 (defn add-placeholder-to-history [us]
   (into {} (map #(update-in % [1 :history] prepend-hash) us)))

 Chris



 On Mon, May 25, 2015 at 5:07 PM, lawr...@waleup.com wrote:


 I started to write an essay, aimed at those programmers who are 
 experienced with highly mutable languages such as Javascript, Ruby, PHP, 
 etc, to demonstrate how one's code style changes when one switches to a 
 mostly immutable language such as Clojure. However, my Clojure code is not 
 nearly as terse as I wanted. In particular, I have this nil check: 

   (if (nil? ((:winner c) nu))
   (assoc nu (:winner c) {:history [{}]})
 nu) 

 which I assume I am writing because I am ignorant. I'm guessing there 
 might be something clever I can do to avoid this? 

 For my code examples, I'm working with these 2 data structures: 

 (def users  {
  :henry {
:history 
[
  {:housing  25, :restaurants 40, :theater 930},
  {:restaurants  30, :crisis  220}
]
   },
   :lisa  {
:history 
[
  {:theater  80},
  {:housing  445, :restaurants  15, :theater  35}
]
   },
   :pasha  {
:history 
[
  {:restaurants  5},
  {:restaurants  40, :theater  60}
]
   },
   :eli  {
:history 
[
  {:crisis  135, :restaurants  440, :theater  65},
  {:theater  95}
]
   }
 })

 (def contests [{:category :housing, :prize-money 100, :winner :eli},
{:category :housing, :prize-money 30, :winner :henry},
{:category :housing, :prize-money 340, :winner :henry},
{:category :housing, :prize-money 45, :winner :susan},
{:category :housing, :prize-money 15, :winner :henry},
{:category :housing, :prize-money 10, :winner :pasha},
{:category :housing, :prize-money 25, :winner :pasha},
{:category :crisis, :prize-money 100, :winner :eli},
{:category :crisis, :prize-money 2330, :winner :henry},
{:category :crisis, :prize-money 90, :winner :henry},
{:category :restaurants, :prize-money 1130, :winner :eli},
{:category :restaurants, :prize-money 130, :winner 
 :pasha},
{:category :theater, :prize-money 60, :winner :eli},
{:category :theater, :prize-money 90, :winner :pasha},
{:category :theater, :prize-money 130, :winner :pasha},
{:category :theater, :prize-money 830, :winner :susan},
{:category :theater, :prize-money 90, :winner :susan},
{:category 

Re: what demonstrates Stuart Sierra's State/Event Pattern

2015-05-25 Thread piastkrakow
Stuart Sierra,

Thank you for the response. I won't take that talk as encyclopedic. 
The 'chain-consequences' function is very interesting, though it is 
unfamiliar to me. I am still learning about Clojure. 

You mention that the State/Event pattern is a common one. If you were 
talking about architectures, I would say your description reminds me of 
Kafka (events are data structures, replaying events can replay the whole 
history of state in the app, etc) but I am curious where you feel this 
pattern shows up as a design pattern? I assume you mean to broadly define 
this to include those situations where we might use pure functions in loop 
or reduce to iterate over a message where the message is some data 
structure, perhaps a JSON document, or some other kind of seq generated by 
an event? 






On Monday, May 25, 2015 at 9:36:39 AM UTC-4, Stuart Sierra wrote:

 This is a pattern I have used **occasionally**.

 That whole talk is just patterns that were in my head at the time. Take 
 whatever you find useful from it, but don't treat it as a universal or 
 complete list.

 If you squint, that 'chain-consequences' function behaves sort of like a 
 monad, but I won't claim it's properly monadic according to anyone's 
 definition.

 –S


-- 
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/d/optout.


Re: what demonstrates Stuart Sierra's State/Event Pattern

2015-05-24 Thread piastkrakow
Thank you for that. I'm curious, when Stuart Sierra mentions a sequence 
monad, does he offer this example simply to keep the Haskell programmers 
happy, or is he suggesting that Clojure programmers sometimes use this 
pattern? I am especially puzzled by this code that he offers, since this 
does not resemble anything that I am familiar with: 


(defn chain-consequences [initial-state consequence-fns]
  (loop [state   initial-state
 fs  consequense-fns
 output  []]
(if (seq fs)
  (let [events ((first fs) state)
new-state  (reduce update-state state events)]
(recur new-state (rest fs) (into output events)))
output)))
 





On Sunday, May 24, 2015 at 11:11:03 AM UTC-4, tbc++ wrote:

 Almost any event-sourcing system is built like this. Datomic is 
 (more-or-less) an example of this as it tracks all past transactions and 
 keeps indexes that are aggregates of the entire state of the DB. 

 In addition, Greg Young introduced a event store at CodeMesh 2013 that 
 uses this model: https://vimeo.com/84314441

 Timothy

 On Sat, May 23, 2015 at 10:15 PM, piast...@gmail.com javascript: 
 wrote:

 I am watching this video, Stuart Sierra's 2012 talk about Functional 
 Design Patterns: 

 http://www.infoq.com/presentations/Clojure-Design-Patterns

 His description of event sourcing for functional programming emphasizes: 
  recreate past states
  recreate any past state by reducing over events
  just store the inputs
  cache any intermediate state
  lost of flexibility
  every event to the system is a data structure
  problem: perhaps too many data structures


 I'm curious where is this pattern actually used? 




  -- 
 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 
 javascript:
 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 javascript:
 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 javascript:.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 “One of the main causes of the fall of the Roman Empire was that–lacking 
 zero–they had no way to indicate successful termination of their C 
 programs.”
 (Robert Firth) 
  

-- 
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/d/optout.


what demonstrates Stuart Sierra's State/Event Pattern

2015-05-23 Thread piastkrakow
I am watching this video, Stuart Sierra's 2012 talk about Functional Design 
Patterns: 

http://www.infoq.com/presentations/Clojure-Design-Patterns

His description of event sourcing for functional programming emphasizes: 
 recreate past states
 recreate any past state by reducing over events
 just store the inputs
 cache any intermediate state
 lost of flexibility
 every event to the system is a data structure
 problem: perhaps too many data structures


I'm curious where is this pattern actually used? 




-- 
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/d/optout.


are there any real examples on Github of how to use reducers?

2015-05-21 Thread piastkrakow

Can anyone point me to a project on Github that is using Clojure 1.5 
reducerers? 



-- 
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/d/optout.


a record that implements the iFn protocol can itself be called as a function?

2015-05-14 Thread piastkrakow


The docs offer this example: 

https://clojuredocs.org/clojure.core/defrecord

user= (defrecord Someone [nick-name preffered-drink] Fun-Time (drinky-drinky 
[_] (str nick-name (having  preffered-drink ): uuumm)))
user.Someone

user= (def dude (-Someone belun daiquiri))
#'user/dude

user= (drinky-drinky dude)
belun(having daiquiri): uuumm

But if a record implements clojure.lang.IFn it can be called directly? Do I 
understand this correctly? When I run macroexpand-all on defrecord-ifn, as 
defined here: 

https://github.com/overtone/overtone/blob/e200075da27375727db1f5ce342e2e1c22ea1dbd/src/overtone/helpers/lib.clj

I see that it extends clojure.lang.IFn as in: 

clojure.lang.IFn 
(invoke [this__1446__auto__] 
  ((fn [this  args] 
(apply synth-player sdef params this [:tail instance-group] args)) 
this__1446__auto__)) 
(invoke [this__1447__auto__ arg0] 
  ((fn [this  args] 
(apply synth-player sdef params this [:tail instance-group] args)) 
this__1447__auto__ arg0)) 
// etc, all 20 arities are defined

So, that means I could call the record as a function? 


-- 
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/d/optout.


is destructuring implemented as a macro?

2015-05-13 Thread piastkrakow
 

Maybe I should have already known this, but I am struck by this, and I'd 
like to confirm it. If I'm working with this code:


https://github.com/drewr/postal/blob/389162cafab08224e50bd6721cac93fe14ca3257/src/postal/support.clj


and if, at the REPL, I do this: 


user= (require '[postal.support :refer :all])


 user= (clojure.walk/macroexpand-all '(defn make-props [sender {:keys 
[host port user tls]}]

#_= (doto (Properties.)

#_= (.put mail.smtp.host (or host not.provided))

#_= (.put mail.smtp.port (or port 25))

#_= (.put mail.smtp.auth (if user true false))

#_= (do-when sender (.put mail.smtp.from sender))

#_= (do-when user (.put mail.smtp.user user))

#_= (do-when tls (.put mail.smtp.starttls.enable true)

 (def make-props 

(fn* 

([sender p__1201] 

(let* [map__1202 p__1201 

map__1202 (if (clojure.core/seq? map__1202) 

(. clojure.lang.PersistentHashMap create (clojure.core/seq map__1202))

map__1202) 

tls (clojure.core/get map__1202 :tls) 

user (clojure.core/get map__1202 :user) 

port (clojure.core/get map__1202 :port) 

host (clojure.core/get map__1202 :host)] 

 (let* [G__1203 (new Properties)] 

(. G__1203 put mail.smtp.host 

(let* [or__3943__auto__ host] 

(if or__3943__auto__ 

or__3943__auto__ 

not.provided))) 

 (. G__1203 put mail.smtp.port 

(let* [or__3943__auto__ port] 

(if or__3943__auto__ 

or__3943__auto__ 

25))) 

(. G__1203 put mail.smtp.auth (if user true false)) 

 (if sender 

(do (let* [G__1204 G__1203] (. G__1204 put mail.smtp.from sender) 
G__1204))) 

(if user 

(do (let* [G__1205 G__1203] (. G__1205 put mail.smtp.user user) 
G__1205))) 

(if tls 

(do (let* [G__1206 G__1203] (. G__1206 put mail.smtp.starttls.enable 
true) G__1206))) 

G__1203)



I see this:


defn make-props [sender {:keys [host port user tls]}]


re-written as: 


(fn*

([sender p__1201]

(let* [map__1202 p__1201

map__1202 (if (clojure.core/seq? map__1202)

(. clojure.lang.PersistentHashMap create (clojure.core/seq map__1202))

map__1202)

tls (clojure.core/get map__1202 :tls)

user (clojure.core/get map__1202 :user)

port (clojure.core/get map__1202 :port)

host (clojure.core/get map__1202 :host)]


So, if the destructuring is re-written by macroexpand, then I can 
reasonably assume that destructuring is implemented as a macro, yes? 





-- 
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/d/optout.


load a namespace at repl?

2015-05-12 Thread piastkrakow
If I: 

git clone https://github.com/overtone/overtone.git

cd overtone

lein repl

and then at the REPL, I try to load Overtone: 


user= (all-ns)
(#Namespace clojure.set #Namespace clojure.tools.nrepl.ack #Namespace 
clojure.stacktrace #Namespace clojure.string #Namespace 
clojure.java.browse #Namespace clojure.tools.nrepl.middleware.load-file 
#Namespace clojure.uuid #Namespace complete.core #Namespace 
clojure.main #Namespace clojure.tools.nrepl.middleware.session 
#Namespace user #Namespace clojure.test #Namespace 
clojure.java.javadoc #Namespace clojure.tools.nrepl #Namespace 
clojure.repl #Namespace clojure.tools.nrepl.bencode #Namespace 
clojure.tools.nrepl.server #Namespace clojure.java.io #Namespace 
clojure.tools.nrepl.middleware #Namespace clojure.template #Namespace 
clojure.java.shell #Namespace clojure.core.protocols #Namespace 
clojure.tools.nrepl.transport #Namespace 
clojure.tools.nrepl.middleware.interruptible-eval #Namespace 
clojure.pprint #Namespace clojure.core #Namespace 
clojure.tools.nrepl.misc #Namespace 
clojure.tools.nrepl.middleware.pr-values #Namespace clojure.walk 
#Namespace reply.exports #Namespace clojure.instant)

user= (resolve 'overtone.studio.inst)

ClassNotFoundException overtone.studio.inst  java.net.URLClassLoader$1.run 
(URLClassLoader.java:372)
user= (ns-resolve *ns* 'overtone.studio.inst)

ClassNotFoundException overtone.studio.inst  java.net.URLClassLoader$1.run 
(URLClassLoader.java:372)
user= (ns-resolve *ns* overtone.studio.inst)
CompilerException java.lang.ClassNotFoundException: overtone.studio.inst, 
compiling:(/private/var/folders/85/50nmp8fx3q72pxv4zlh_74pmgn/T/form-init5181314797293724962.clj:1:1)
 

user= *ns*
#Namespace user
user= (namespace 'overtone.studio.inst)
nil
user= (namespace overtone.studio.inst)

CompilerException java.lang.ClassNotFoundException: overtone.studio.inst, 
compiling:(/private/var/folders/85/50nmp8fx3q72pxv4zlh_74pmgn/T/form-init5181314797293724962.clj:1:1)
 


What am I doing wrong? 




-- 
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/d/optout.


Re: how goeth the STM experiment?

2015-05-10 Thread piastkrakow


 An other thing when I have used with agents is implement an async 
interface for jdbc 
 like applications. I have a little explication on how it is done 
 here: http://funcool.github.io/suricatta/latest/#_async_interface 


That is an impressive bit of documentation. Thank you. 





On Saturday, May 9, 2015 at 3:33:15 AM UTC-4, Andrey Antukh wrote:

 Hi!

 Personally, I do not have the opportunity to use refs, but atoms and agens 
 I have used it in different ways

 I have used agents for logging system, thanks to its guarantees of 
 execution functions in a serial way. This allows heavy multithreading 
 applications put logs to stdout (or any other destination) and have as 
 result a consistent log.

 An other thing when I have used with agents is implement an async 
 interface for jdbc like applications. I have a little explication on how it 
 is done here: http://funcool.github.io/suricatta/latest/#_async_interface 

 I hope you find it useful.

 Cheers.
 Andrey

 2015-05-09 3:56 GMT+02:00 piast...@gmail.com javascript::

 This seems to be true:

 I would have to say that the biggest surprise is how little they're 
 needed in Clojure.

 Run this search on Google: 

 agent send clojure site:github.com

 The first 5 pages point me to examples from several years ago, or error 
 reports, or unit tests. Nothing substantial or recent. I think it is 
 interesting how many of the results are blog posts or gists -- people talk 
 about agents much more then they actually use them. 

 Still, there are some examples: 


 https://github.com/aphyr/riemann/blob/302cff942f308771b1d8d837cdf9ce2c9090daed/src/riemann/pool.clj

 (defmacro with-pool Evaluates body in a try expression with a symbol 
 'thingy claimed from the given pool, with specified claim timeout. 
 Releases thingy at the end of the body, or if an exception is thrown, 
 invalidates them and rethrows. Example: ; With client, taken from 
 connection-pool, waiting 5 seconds to claim, send ; client a message. 
 (with-pool [client connection-pool 5] (send client a-message)) [[thingy 
 pool timeout]  body] ; Destructuring bind could change nil to a, say, 
 vector, and cause ; unbalanced claim/release. `(let [thingy# (claim ~pool 
 ~timeout) ~thingy thingy#] (try (let [res# (do ~@body)] (release ~pool 
 thingy#) res#) (catch Throwable t# (invalidate ~pool thingy#) (throw 
 t#)



 And:


 https://github.com/clojure/java.jmx/blob/master/src/main/clojure/clojure/java/jmx.clj


 (deftype Bean [state-ref] DynamicMBean (getMBeanInfo [_] (MBeanInfo. (.. 
 _ getClass getName) ; class name Clojure Dynamic MBean ; description (
 map-attribute-infos @state-ref) ; attributes nil ; constructors nil ; 
 operations nil)) (getAttribute [_ attr] (@state-ref (keyword attr))) (
 getAttributes [_ attrs] (let [result (AttributeList.)] (doseq [attr attrs] 
 (.add result (Attribute. attr (.getAttribute _ attr result)) (
 setAttribute [_ attr] (let [attr-name (.getName attr) attr-value (
 .getValue attr) state-update {(keyword attr-name) attr-value}] (condp = (
 type state-ref) clojure.lang.Agent (await (send state-ref (fn [state 
 state-update] (merge state state-update)) state-update)) clojure.lang.Atom 
 (swap! state-ref merge state-update) clojure.lang.Ref (dosync (ref-set 
 state-ref (merge @state-ref state-update)) (setAttributes [_ attrs] (
 let [attr-names (map (fn [attr] (.setAttribute _ attr) (.getName attr)) 
 attrs)] (.getAttributes _ (into-array attr-names)



 I would love to see some other examples.




  

 On Wednesday, May 6, 2015 at 9:49:47 PM UTC-4, Surgo wrote:

 I'm not saying this is everyone's experience o

 ...

-- 
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/d/optout.


What does ^:internal mean?

2015-05-10 Thread piastkrakow
Sadly, Google seems to think I am search for internal when I search for 
^:internal so that makes it hard to find the documentation. I am curious 
about this code:

;;; Capture the standard def forms' arglists
(def ^:internal defn-arglists (vec (:arglists (meta #'defn
(def ^:internal fn-arglists (vec (:arglists (meta #'fn
(def ^:internal defmulti-arglists (vec (:arglists (meta #'defmulti
(def ^:internal def-arglists '[[symbol doc-string? init?]])

From here: 

https://github.com/palletops/api-builder/blob/4d82355bec1ebdf7c501be71e2f3d156ae84ad2c/src/com/palletops/api_builder/impl.clj

What does ^:internal mean in this context? 







-- 
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/d/optout.


Re: What is best practice regarding transducers

2015-05-10 Thread piastkrakow

That is interesting. What is xempty for? 


On Friday, May 8, 2015 at 4:09:53 PM UTC-4, miner wrote:

 I wouldn’t make any claims about “best practices” but I’ve been playing 
 with transducers in my little project: 

 https://github.com/miner/transmuters 

 I have a blog post about how to “chain” transducers.  (Not sure that’s the 
 best term.)  Basically, I wanted to use a transducer that might terminate 
 (as with ‘take’), and then have another transducer pick up the input from 
 there.  The “chain” transducer is like a sequential combination of 
 transducers.  Of course, you can mix ‘chain’ and ‘comp’ to make work flows. 

 http://conjobble.velisco.com/blog_posts/transducer-chain 

 In any case, it was a fun experiment for me. 

 Steve Miner 
 steve...@gmail.com javascript: 


  On May 6, 2015, at 11:15 AM, larry google groups lawrenc...@gmail.com 
 javascript: wrote: 
  
  I would like to write a detailed blog post about how developers are 
 actually using transducers. If you have a public project on Github that is 
 using transducers, would you please point me to it? I would like to see 
 what you did. 
  
  If you are not using transducers, but you plan to in the near future, I 
 would be curious to see the code where you think they could help you. 



-- 
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/d/optout.


Re: how goeth the STM experiment?

2015-05-08 Thread piastkrakow
This seems to be true:

I would have to say that the biggest surprise is how little they're needed 
in Clojure.

Run this search on Google: 

agent send clojure site:github.com

The first 5 pages point me to examples from several years ago, or error 
reports, or unit tests. Nothing substantial or recent. I think it is 
interesting how many of the results are blog posts or gists -- people talk 
about agents much more then they actually use them. 

Still, there are some examples: 

https://github.com/aphyr/riemann/blob/302cff942f308771b1d8d837cdf9ce2c9090daed/src/riemann/pool.clj

(defmacro with-pool Evaluates body in a try expression with a symbol 
'thingy claimed from the given pool, with specified claim timeout. Releases 
thingy at the end of the body, or if an exception is thrown, invalidates 
them and rethrows. Example: ; With client, taken from connection-pool, 
waiting 5 seconds to claim, send ; client a message. (with-pool [client 
connection-pool 5] (send client a-message)) [[thingy pool timeout]  body] ; 
Destructuring bind could change nil to a, say, vector, and cause ; 
unbalanced claim/release. `(let [thingy# (claim ~pool ~timeout) ~thingy 
thingy#] (try (let [res# (do ~@body)] (release ~pool thingy#) res#) (catch 
Throwable t# (invalidate ~pool thingy#) (throw t#)



And:

https://github.com/clojure/java.jmx/blob/master/src/main/clojure/clojure/java/jmx.clj


(deftype Bean [state-ref] DynamicMBean (getMBeanInfo [_] (MBeanInfo. (.. _ 
getClass getName) ; class name Clojure Dynamic MBean ; description (
map-attribute-infos @state-ref) ; attributes nil ; constructors nil ; 
operations nil)) (getAttribute [_ attr] (@state-ref (keyword attr))) (
getAttributes [_ attrs] (let [result (AttributeList.)] (doseq [attr attrs] (
.add result (Attribute. attr (.getAttribute _ attr result)) (
setAttribute [_ attr] (let [attr-name (.getName attr) attr-value (.getValue 
attr) state-update {(keyword attr-name) attr-value}] (condp = (type 
state-ref) clojure.lang.Agent (await (send state-ref (fn [state 
state-update] (merge state state-update)) state-update)) clojure.lang.Atom (
swap! state-ref merge state-update) clojure.lang.Ref (dosync (ref-set 
state-ref (merge @state-ref state-update)) (setAttributes [_ attrs] (let 
[attr-names (map (fn [attr] (.setAttribute _ attr) (.getName attr)) attrs)] 
(.getAttributes _ (into-array attr-names)



I would love to see some other examples.




 

On Wednesday, May 6, 2015 at 9:49:47 PM UTC-4, Surgo wrote:

 I'm not saying this is everyone's experience or anything, but at times I 
 have at times considered some deeper STM-work with agents but I could not 
 seem to penetrate the documentation at the time. I do not know if it's 
 different now

 -- Morgon

 On Wednesday, May 6, 2015 at 5:38:08 PM UTC-4, James Reeves wrote:

 On 6 May 2015 at 21:58, Alex Miller al...@puredanger.com wrote:

 I would have to say that the biggest surprise is how little they're 
 needed in Clojure. The combination of immutable data, functions to update 
 complex data structures, and fast pure function updates with atoms actually 
 satisfies a large percentage of real use cases.


 I'll echo this. I've been using Clojure for years, and I can't recall 
 ever needing refs (or agents for that matter).

 - 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/d/optout.


What is the use-case for create-ns?

2015-05-07 Thread piastkrakow
I am curious about something that Michael Drogalis did here:

(defn- load-support [support-file]
  (let [support-ns (create-ns 'support-ns)
support-text (slurp (.getPath support-file))]
(binding [*ns* support-ns]
  (eval '(clojure.core/refer 'clojure.core))
  (eval '(refer 'janus.support))
  (load-string support-text

https://github.com/gga/janus/blob/master/src/janus/support.clj

So, we create a namespace ex-nihilo, and then we load-string our 
supporting/contract code in that namespace. Is this being done mostly for 
hygiene? Or security? Am I correct if I say this is done because it might 
be a mess if we loaded the contents of that external file in our current 
namespace? 












-- 
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/d/optout.