Re: using atoms as logs for channels in core.async

2014-05-14 Thread Gary Verhaegen
The function map> takes a channel and a function, and returns a new
channel; every time an element is sent through that new channel, it
first goes through the given function (and it is the result of that
function that is actually sent through the original channel).

The function map< is similar, except it applies the given function to
each element that exits the channel.

So in my function, (as/map< (fn [x] (swap! at pop) x) chan) creates a
new channel that will remove an element from the sequence referenced
by the atom at every time a value is sent through it.

The result of the function is thus a new channel that conjes all of
its input to the atom, and pops an element from the atom every time
someone takes from it. But from an external point of view, thanks to
both functions returning the element unchanged, it acts exactly like a
normal channel.

Note that it essentially wraps the original channel within two other
channels, so the original channel is unchanged and should therefore
not be used anymore.

I have to leave now; if you still have any question after playing with
the following code, I'll be glad to answer them when I come back (in
~10 hours or so)

;; project.clj

(defproject async "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME";
  :license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
 [org.clojure/core.async "0.1.303.0-886421-alpha"]]
  :main ^:skip-aot async.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

;; src/async/core.clj

(ns async.core
  (:require [clojure.core.async :as as :refer [go ! chan]]))

(defn decorate-channel
  [chan at]
  (as/map> (fn [x] (swap! at conj x) x)
   (as/map< (fn [x] (swap! at pop) x)
chan)))

(defn some-fn-using-a-channel
  [ch]
  (go (dotimes [_ 10] (! ch 1)))
  (go (dotimes [_ 10] ( wrote:
> Hi Gary,
>
> Your function looks interesting and succinct, but I am still new to this
> subject so am not sure how it would be used. Could you give some examples?
>
> Jesse
>
>
> On Wednesday, May 14, 2014 3:34:17 AM UTC+9, Gary Verhaegen wrote:
>>
>> What about the following? (as is bound to clojure.core.async ns)
>>
>> (defn decorate-channel
>>   [chan at]
>>   (as/map> (fn [x] (swap! at conj x) x)
>>(as/map< (fn [x] (swap! at pop) x)
>>chan)))
>>
>> As far as I can tell, it should do what you want, without introducing
>> global vars. It also returns a "normal" async channel that can be used
>> anywhere a channel is expected, without special handling. This could
>> be very handy for debugging.
>>
>>
>> On 13 May 2014 06:02, gamma235  wrote:
>> >
>> > Hey guys, I took your suggestions and just wanna deliver the finished
>> > product. I included the macro in there for practice, but agree it is
>> > probably not necessary. Thanks for all your help.
>> >
>> > p is for pretty :)
>> >
>> >>
>> >> (defn pchan [ch]
>> >>
>> >>   {:channel ch, :buffer (atom [])})
>> >
>> >
>> >>
>> >> (defn pbuff [{:keys [ch buffer]}]
>> >>(println @buffer))
>> >
>> >
>> >>
>> >> (defn pput [{:keys [channel buffer]} v]
>> >>   (do
>> >> (go
>> >>  (>! channel v))
>> >> (swap! buffer conj v)
>> >> (println "put " v)))
>> >
>> >
>> >>
>> >> (defn ptake [{:keys [channel buffer]}]
>> >> (go
>> >>  (let [v (> >>(if-not (empty? @buffer)
>> >> (do
>> >>(swap! buffer pop)
>> >>(println "took " v)
>> >> (println "take pending ..."))
>> >
>> >
>> >>
>> >> (defmacro def-pchan
>> >>   ([name]
>> >>`(def ~name (pchan (chan
>> >>   ([name buff]
>> >>`(def ~name (pchan (chan ~buff)
>> >
>> >
>> >>
>> >> (defn clear-buffer [{:keys [buffer]}]
>> >>   (reset! buffer []))
>> >>
>> > it works!
>> >>
>> >> (def-pchan pc)
>> >> (:buffer pc)
>> >> (pbuff pc)
>> >> (ptake pc)
>> >> (pput pc 42)
>> >> (clear-buffer pc)
>> >
>> > --
>> > 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 patien

Re: [ANN] Clojure RETE implementation - CLIPS-like expert system shell. New version 4.3

2014-05-14 Thread ru
Dave. It is a very good advice. Initially I tried to do as simple as 
possible. Now I will try to follow your advice and check what performance 
impact it may has.

Ryan. RETE algorithm is a very basic and can be applied to a broad spectrum 
of tasks not only to expert systems. For example, I use it in one 
application to execute a set of special parallel processes. So, 
requirements to implementations may be different. Here would be useful to 
have universal set of benchmarks to compare different implementations. I 
selected Manners and Waltz because they are in CLIPS distribution. It will 
be very appreciated if someone point out other good examples as candidates 
on benchmark tests.

Sincerely,
  Ru

понедельник, 12 мая 2014 г., 17:47:44 UTC+4 пользователь ru написал:
>
> New feature: added Java interface. Eclipse project example.
>
> Home: https://github.com/rururu/rete4frames
>
> Have fun!
>
> Sincerely,
>   Ru
>

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


test.check

2014-05-14 Thread Maciej Jaśkowski
Hi there,

I would like to create a generator generating a list of ints with each 
value repeated a number of times e.g.

(gen/sample gen-repeater [ 1 1 1 2 2 2 -1 -1 -1 9 9 9])

this 
(gen/sample (gen/bind gen/int (fn [i] (gen/return (take 5 (repeat i))
returns e.g. ((0 0 0 0 0) (-1 -1 -1 -1 -1) (0 0 0 0 0))
which is of no interest to me :-(

Is that even possible under test.check to have a generator like that?

Best,
Maciej Jaśkowski

-- 
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: [ANN] Clojure RETE implementation - CLIPS-like expert system shell. New version 4.3

2014-05-14 Thread Ryan Brush
Hey Ru,

I avoided Miss Manners simply because it doesn't represent the usage patterns I 
have or expect, so I just have been profiling against the data I have for my 
use case.

Of course, Ms Manners may be a a better reflection of your needs, in which case 
it could be a good benchmark. Micro-benchmarking is full of pitfalls, so your 
mileage may vary.

-Ryan

-- 
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: test.check

2014-05-14 Thread Michał Marczyk
Sure, here's a possible approach:

user> (gen/sample (gen/fmap (partial apply concat) (gen/list (gen/fmap
#(repeat 3 %) gen/int
(()
 ()
 (0 0 0)
 (3 3 3 3 3 3 2 2 2)
 (3 3 3 2 2 2 0 0 0 3 3 3)
 (2 2 2)
 (-4 -4 -4 -6 -6 -6)
 (4 4 4 5 5 5)
 (7 7 7 3 3 3)
 (3 3 3 7 7 7 9 9 9 7 7 7 4 4 4 -4 -4 -4))

Cheers,
Michał


On 14 May 2014 08:50, Maciej Jaśkowski  wrote:
> Hi there,
>
> I would like to create a generator generating a list of ints with each value
> repeated a number of times e.g.
>
> (gen/sample gen-repeater [ 1 1 1 2 2 2 -1 -1 -1 9 9 9])
>
> this
> (gen/sample (gen/bind gen/int (fn [i] (gen/return (take 5 (repeat i))
> returns e.g. ((0 0 0 0 0) (-1 -1 -1 -1 -1) (0 0 0 0 0))
> which is of no interest to me :-(
>
> Is that even possible under test.check to have a generator like that?
>
> Best,
> Maciej Jaśkowski
>
> --
> 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.

-- 
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: [ANN] Clojure RETE implementation - CLIPS-like expert system shell. New version 4.3

2014-05-14 Thread ru
Hello Ryan,

Have you look at Waltz test? You may be interested of this. Its CLIPS 
source is in examples folder of rete4frames.

-Ru

понедельник, 12 мая 2014 г., 17:47:44 UTC+4 пользователь ru написал:
>
> New feature: added Java interface. Eclipse project example.
>
> Home: https://github.com/rururu/rete4frames
>
> Have fun!
>
> Sincerely,
>   Ru
>

-- 
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: [ANN] Automat: better FSMs through combinators

2014-05-14 Thread Jason Felice
Wow, this library looks very useful!

Thanks!
-Jason


On Tue, May 13, 2014 at 5:55 PM, Colin Fleming
wrote:

> I'm also very excited about Automat, although I haven't had time to look
> at it closely yet. Ragel is one of my favourite pieces of software. Here's
> an article from Zed Shaw about using state charts for networked apps:
> http://www.zedshaw.com/essays/ragel_state_charts.html. I read an article
> (or an interview, I can't remember) where he discussed the state machines
> in Mongrel in more depth, it was fascinating and quite amazing how much it
> simplified the code, made it much more robust and consistently handled
> tricky corners of HTTP while easily supporting things like websockets.
>
> I'll take a look when I get a moment and provide some feedback - in
> particular I'm excited about the possibility of compiling state machines
> without the build time precompile step, I think there are a lot of
> interesting possibilities with this.
>
> Cheers,
> Colin
>
>
> On 14 May 2014 07:27, Zach Tellman  wrote:
>
>> https://github.com/ztellman/automat
>>
>> This has been languishing in my Github for a while, for lack of a few
>> finishing touches on the code and documentation.  I think this is one of
>> cooler libraries I've written, and beyond the obvious use for parsers, the
>> set theoretic operators could be a powerful way to specify actions in
>> response to complex browsing behaviors on a site, or any other number of
>> things.  I'm excited to see how it's used.
>>
>> I'm happy to answer any questions.  Suggestions on how to improve the
>> documentation are encouraged.
>>
>> Zach
>>
>> --
>> 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.
>>
>
>  --
> 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.
>

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


clojurescript: modifying function definitions

2014-05-14 Thread Mike Haney
There's a library for that - https://github.com/technomancy/robert-hooke/

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


[ANN] clojure.test.check 0.5.8

2014-05-14 Thread Reid Draper
I'm please to announce clojure.test.check 0.5.8 [1], which is primarily a 
bugfix release. As usual, the release notes are available in the repository 
[2]. I've duplicated them here for convenience:

* 0.5.8
* Limit the number of retries for gen/such-that. A two-arity version is
  provided if you need to retry more than 10 times. This should be a
  code-smell, though.
* Return random seed used on test failure
* Fix keyword generator to conform to reader specs
* Correct documentation mentions of namespaces
* Add more detailed contributing instructions
* Internal: use a record internally for generators. This is meant to help
  convey the fact that generators are opaque
* Extract rose-tree code into a separate namespace


Please don't hesitate to reach out with any questions or issues.


Reid


[1] https://github.com/clojure/test.check/tree/v0.5.8
[2] https://github.com/clojure/test.check/blob/v0.5.8/CHANGELOG.markdown

-- 
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: [ANN] Clojure RETE implementation - CLIPS-like expert system shell. New version 4.3

2014-05-14 Thread Ryan Brush
I'm less familiar with Waltz. It looks like a good way to exercise some 
worst-case scenarios in the rule engines as well. Like Ms Manners I don't 
think this is a very representative usage pattern but it could expose 
problems in extreme cases.

-Ryan

On Wednesday, May 14, 2014 8:28:41 AM UTC-5, ru wrote:
>
> Hello Ryan,
>
> Have you look at Waltz test? You may be interested of this. Its CLIPS 
> source is in examples folder of rete4frames.
>
> -Ru
>
> понедельник, 12 мая 2014 г., 17:47:44 UTC+4 пользователь ru написал:
>>
>> New feature: added Java interface. Eclipse project example.
>>
>> Home: https://github.com/rururu/rete4frames
>>
>> Have fun!
>>
>> Sincerely,
>>   Ru
>>
>

-- 
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: Joy of Clojure question

2014-05-14 Thread Gary Johnson
Bridget and Guru are both right about the reason that \3 is found at 
position 13 in the string. However, the code you typed isn't valid Clojure, 
since the pos function expects pred to be a function of v. Thus, your pos 
call would need to look like this:

(pos #(= % \3) ":a 4 :b 1 :c 3 :d 4") => (13)  ;; note that pos returns a 
list of all indeces matching pred

Alternatively, you could have defined pos to simply perform equality 
matching on its first argument like so:

(defn pos [val coll]
  (for [[i v] (index coll) :when (= val v)] i))

(pos \3 ":a 4 :b 1 :c 3 :d 4") => (13)

-- 
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: Joy of Clojure question

2014-05-14 Thread kurofune
Haha, right on Gary! I used the later version of the original function, but 
the earlier call to the original function. Here is what it looked like in 
the beginning. This was an example of how not to write a function that 
looks up indices by value.  The example code I posted above was the 
supposed better way. 

(defn pos [e coll]
>   (let [cmp (if (map? coll)
>   #(= (second %1) %2)
>   #(= %1 %2))]
> (loop [s coll idx 0]
>   (when (seq s)
> (if (cmp (first s) e)
>   (if (map? coll)
> (first (first s))
> idx)
>   (recur (next s) (inc idx)))




On Thursday, May 15, 2014 1:31:34 AM UTC+9, Gary Johnson wrote:
>
> Bridget and Guru are both right about the reason that \3 is found at 
> position 13 in the string. However, the code you typed isn't valid Clojure, 
> since the pos function expects pred to be a function of v. Thus, your pos 
> call would need to look like this:
>
> (pos #(= % \3) ":a 4 :b 1 :c 3 :d 4") => (13)  ;; note that pos returns a 
> list of all indeces matching pred
>
> Alternatively, you could have defined pos to simply perform equality 
> matching on its first argument like so:
>
> (defn pos [val coll]
>   (for [[i v] (index coll) :when (= val v)] i))
>
> (pos \3 ":a 4 :b 1 :c 3 :d 4") => (13)
>

-- 
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: [ANN] clojure.test.check 0.5.8

2014-05-14 Thread Steve Miner

On May 14, 2014, at 10:44 AM, Reid Draper  wrote:
> * Limit the number of retries for gen/such-that. A two-arity version is
>   provided if you need to retry more than 10 times. This should be a
>   code-smell, though.

I think the limit is a good idea, but it's an extra wrinkle and maybe too tight.

I had a such-that that failed due to the new limit.  Unfortunately, the error 
message didn't help much in tracking it down.  I ended up changing all my 
such-that calls to use a unique number of retries so I could figure which one 
was failing.

I suppose my situation is unusual in that I generate generators and tests from 
schemas and data.  The stack traces aren't very pretty when there are errors.

It might help if you added the 'pred' and 'tries' to the ex-info data in 
such-that-helper.  Might as well put something in the ex-info data.

By the way, it turns out 25 was a sufficient number of retries for my test.  
Works fine now.


Steve Miner

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


[ANN] Throttler: a library for rate limiting

2014-05-14 Thread Bruno Vecchi
Throttler[1] is a little library I wrote out of need for one of my personal 
projects. It lets you control the maximum rate of function calls or message 
transmissions through core.async channels.

It supports bursty traffic shaping via the Token-Bucket algorithm and is 
fully asynchronous.

I just published a [blog post][1] on it, expanding a little bit on the 
project's README[1].

This is my first Clojure library! I would greatly appreciate any feedback.

Thanks,

Bruno Vecchi

-- 
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: [ANN] Throttler: a library for rate limiting

2014-05-14 Thread Bruno Vecchi
Hm, apparently I forgot to post the links to the actual things I wanted to 
share.

Here they go:

Github: https://github.com/brunoV/throttle
Blog Post: http://brunov.org/clojure/2014/05/14/throttler/

Bruno

On Wednesday, May 14, 2014 1:43:34 PM UTC-3, Bruno Vecchi wrote:
>
> Throttler[1] is a little library I wrote out of need for one of my 
> personal projects. It lets you control the maximum rate of function calls 
> or message transmissions through core.async channels.
>
> It supports bursty traffic shaping via the Token-Bucket algorithm and is 
> fully asynchronous.
>
> I just published a [blog post][1] on it, expanding a little bit on the 
> project's README[1].
>
> This is my first Clojure library! I would greatly appreciate any feedback.
>
> Thanks,
>
> Bruno Vecchi
>

-- 
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: [ANN] Throttler: a library for rate limiting

2014-05-14 Thread Bruno Vecchi
Hm, apparently I forgot to post the links to the actual things I wanted to 
share.

Here they go:

Github: 
https://github.com/brunoV/throttle
r
Blog Post: http://brunov.org/clojure/2014/05/14/throttler/

Bruno

On Wednesday, May 14, 2014 1:43:34 PM UTC-3, Bruno Vecchi wrote:
>
> Throttler[1] is a little library I wrote out of need for one of my 
> personal projects. It lets you control the maximum rate of function calls 
> or message transmissions through core.async channels.
>
> It supports bursty traffic shaping via the Token-Bucket algorithm and is 
> fully asynchronous.
>
> I just published a [blog post][1] on it, expanding a little bit on the 
> project's README[1].
>
> This is my first Clojure library! I would greatly appreciate any feedback.
>
> Thanks,
>
> Bruno Vecchi
>

-- 
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: [ANN] Throttler: a library for rate limiting

2014-05-14 Thread Bruno Vecchi
Hm, apparently I forgot to post the links to the actual things I wanted to 
share.

Here they go:

Github: https://github.com/brunoV/throttler
Blog Post: http://brunov.org/clojure/2014/05/14/throttler/

Bruno

On Wednesday, May 14, 2014 1:43:34 PM UTC-3, Bruno Vecchi wrote:
>
> Throttler[1] is a little library I wrote out of need for one of my 
> personal projects. It lets you control the maximum rate of function calls 
> or message transmissions through core.async channels.
>
> It supports bursty traffic shaping via the Token-Bucket algorithm and is 
> fully asynchronous.
>
> I just published a [blog post][1] on it, expanding a little bit on the 
> project's README[1].
>
> This is my first Clojure library! I would greatly appreciate any feedback.
>
> Thanks,
>
> Bruno Vecchi
>

-- 
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: [ANN] Automat: better FSMs through combinators

2014-05-14 Thread Alex Hammel
This looks really, really cool. Good work!


On Wed, May 14, 2014 at 6:41 AM, Jason Felice wrote:

> Wow, this library looks very useful!
>
> Thanks!
> -Jason
>
>
> On Tue, May 13, 2014 at 5:55 PM, Colin Fleming <
> colin.mailingl...@gmail.com> wrote:
>
>> I'm also very excited about Automat, although I haven't had time to look
>> at it closely yet. Ragel is one of my favourite pieces of software. Here's
>> an article from Zed Shaw about using state charts for networked apps:
>> http://www.zedshaw.com/essays/ragel_state_charts.html. I read an article
>> (or an interview, I can't remember) where he discussed the state machines
>> in Mongrel in more depth, it was fascinating and quite amazing how much it
>> simplified the code, made it much more robust and consistently handled
>> tricky corners of HTTP while easily supporting things like websockets.
>>
>> I'll take a look when I get a moment and provide some feedback - in
>> particular I'm excited about the possibility of compiling state machines
>> without the build time precompile step, I think there are a lot of
>> interesting possibilities with this.
>>
>> Cheers,
>> Colin
>>
>>
>> On 14 May 2014 07:27, Zach Tellman  wrote:
>>
>>> https://github.com/ztellman/automat
>>>
>>> This has been languishing in my Github for a while, for lack of a few
>>> finishing touches on the code and documentation.  I think this is one of
>>> cooler libraries I've written, and beyond the obvious use for parsers, the
>>> set theoretic operators could be a powerful way to specify actions in
>>> response to complex browsing behaviors on a site, or any other number of
>>> things.  I'm excited to see how it's used.
>>>
>>> I'm happy to answer any questions.  Suggestions on how to improve the
>>> documentation are encouraged.
>>>
>>> Zach
>>>
>>> --
>>> 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.
>>>
>>
>>  --
>> 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.
>>
>
>  --
> 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.
>

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


setting environment variables for all repls?

2014-05-14 Thread Christopher Howard
Hey all, I want

(set! *print-length* 40)

to be run each time I open "lein repl" (regardless of the project,
preferably). I thought that is what the ~/.lein/init.clj file was for,
but apparently not.

-- 
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: setting environment variables for all repls?

2014-05-14 Thread guns
On Wed 14 May 2014 at 02:41:39PM -0800, Christopher Howard wrote:

> Hey all, I want
>
> (set! *print-length* 40)
>
> to be run each time I open "lein repl" (regardless of the project,
> preferably). I thought that is what the ~/.lein/init.clj file was for,
> but apparently not.

Set {:repl-options {:init (set! *print-length* 40)}} in your :user
profile in ~/.lein/profiles.clj.

https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L311

guns


pgpSx2dX6LKDq.pgp
Description: PGP signature


Re: [ANN] Throttler: a library for rate limiting

2014-05-14 Thread Atamert Ölçgen
Awesome! Thanks.


On Thu, May 15, 2014 at 1:58 AM, Bruno Vecchi  wrote:

> Hm, apparently I forgot to post the links to the actual things I wanted to
> share.
>
> Here they go:
>
> Github: https://github.com/brunoV/throttler
> Blog Post: http://brunov.org/clojure/2014/05/14/throttler/
>
> Bruno
>
> On Wednesday, May 14, 2014 1:43:34 PM UTC-3, Bruno Vecchi wrote:
>
>> Throttler[1] is a little library I wrote out of need for one of my
>> personal projects. It lets you control the maximum rate of function calls
>> or message transmissions through core.async channels.
>>
>> It supports bursty traffic shaping via the Token-Bucket algorithm and is
>> fully asynchronous.
>>
>> I just published a [blog post][1] on it, expanding a little bit on the
>> project's README[1].
>>
>> This is my first Clojure library! I would greatly appreciate any feedback.
>>
>> Thanks,
>>
>> Bruno Vecchi
>>
>  --
> 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.
>



-- 
Kind Regards,
Atamert Ölçgen

-+-
--+
+++

www.muhuk.com

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


Asynchronous socket communication with agents

2014-05-14 Thread Dylan Gleason


I have a TCP socket connection in which I need to process several requests 
and conj each request and it's corresponding response to a vector for 
logging purposes. I need to transmit and receive via two asynchronous 
threads, where a transmit function is responsible for sending requests and 
a receive function is responsible for receiving responses from a server.

My understanding is that for asynchronous transmission, I need to use agent in 
Clojure to accomplish this. However, I also need to ensure serial access to 
the vector, since both threads are trying to modify it at any given time.

I tried to get something working, but my agent ends up in a failed state 
after making a few requests and processing a few responses. Below is the 
code showing what I am attempting to do. If anyone could give me some 
guidance, it would be greatly appreciated.

;; the shared resource


(def async-log (agent []))


;; I thought this needed to be synchronized for serial access, so I 
used 

;; dosync, but I am not sure if this is right. In any case, it doesn't 

;; seem to make a difference


(defn add-entry

  [coll entry]

  (dosync (conj coll entry)))


;; transmit function


(defn transmit

  [log writer socket request]

  (let [request   (request->String request socket)

bytes-out (request->bytes request)

length(count bytes-out)]

(.writeShort writer length)

(.write writer bytes-out 0 length)

(add-entry log request)))


;; Receive function


(defn receive

  [log reader socket]

  (let [length   (read-length reader)

bytes-in (byte-array request/max-message-size)]

(.read reader bytes-in 0 length)

(add-entry log (to-string bytes-in


;; process each request, n times


(defn process-requests

  [request socket iters]

  (with-open [reader (DataInputStream. (.getInputStream socket))

  writer (DataOutputStream. (.getOutputStream socket))]

(dotimes [x iters]

  (send-off async-log transmit writer socket request)

  (send-off async-log receive reader socket)

  (Thread/sleep 50

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


Save map contentns to external file?

2014-05-14 Thread Steven Jones
Hi

I am developing an Overtone MIDI application and wish to save/read the
state of a map to an external file.  The map keys are always integers,
specifically MIDI program numbers. The map values however have one of two
forms. They are either explicit association list of key/value
pairs or functions which return assoc list. 

I could handle the task if the map values where always explicit list. My
real problem is how do I write out a Clojure function to an external
file and later reconstruct it? Ideally the file would be pure text but
that's not an absolute requirement.  Are there any standard methods for
doing such a thing? 


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.