Re: [ANN] silc - a tiny entity database for clojure (games)

2014-12-03 Thread Daniel Kersten
Is it possible to retrieve all entities with a set of attributes,
regardless of the attribute values?

On Wed, 3 Dec 2014 06:19 Atamert Ölçgen mu...@muhuk.com wrote:

 I don't feed trolls.

 On Wed, Dec 3, 2014 at 10:10 AM, Atamert Ölçgen mu...@muhuk.com wrote:

 Why are you using BigDecimal's for indices? If you want to go big, isn't
 BigInt a better choice?

 Actually, I would just use Long's. (MAX_VALUE = 9223372036854775807)

 On Wed, Dec 3, 2014 at 10:04 AM, Atamert Ölçgen mu...@muhuk.com wrote:

 This is a very nice example of abstraction. Using a hash-map is just an
 implementation detail.

 However I'd be very interested to hear if there are any other compelling
 use cases for this.


 Sparsely populated tables, unstructured anything... We used an EAV
 abstraction (over SQL) to build a product database. Different product types
 have very different fields, even same types of product might have different
 fields sometimes. In hindsight normalized relational tables would have been
 a better fit (the decision was made before I joined).

 In your README, the change and delete examples give the impression that
 they're mutating the db, but they actually return an updated db if I'm not
 mistaken.


 On Wed, Dec 3, 2014 at 6:37 AM, dan.stone16...@gmail.com wrote:

 I have put together a quick library http://github.com/danstone/silc
 that allows you to manage many entities and their attributes in a pure way
 with indexing for performance, include composite indexes.

 The intention of the library is certainly as the basis for an entity
 component system for games, that is how I am using it. However I'd be very
 interested to hear if there are any other compelling use cases for this.

 Pull requests welcome!

 Thanks,

 Dan

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




 --
 Kind Regards,
 Atamert Ölçgen

 -+-
 --+
 +++

 www.muhuk.com




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


-- 
You 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] silc - a tiny entity database for clojure (games)

2014-12-03 Thread dan . stone16321
Yes I should probably not be using BigDecimals :)

I'll fix this as soon as I can.

On Wednesday, December 3, 2014 2:10:53 AM UTC, Atamert Ölçgen wrote:

 Why are you using BigDecimal's for indices? If you want to go big, isn't 
 BigInt a better choice?

 Actually, I would just use Long's. (MAX_VALUE = 9223372036854775807)

 On Wed, Dec 3, 2014 at 10:04 AM, Atamert Ölçgen mu...@muhuk.com 
 javascript: wrote:

 This is a very nice example of abstraction. Using a hash-map is just an 
 implementation detail.

 However I'd be very interested to hear if there are any other compelling 
 use cases for this.


 Sparsely populated tables, unstructured anything... We used an EAV 
 abstraction (over SQL) to build a product database. Different product types 
 have very different fields, even same types of product might have different 
 fields sometimes. In hindsight normalized relational tables would have been 
 a better fit (the decision was made before I joined).

 In your README, the change and delete examples give the impression that 
 they're mutating the db, but they actually return an updated db if I'm not 
 mistaken.


 On Wed, Dec 3, 2014 at 6:37 AM, dan.sto...@gmail.com javascript: 
 wrote:

 I have put together a quick library http://github.com/danstone/silc 
 that allows you to manage many entities and their attributes in a pure way 
 with indexing for performance, include composite indexes.

 The intention of the library is certainly as the basis for an entity 
 component system for games, that is how I am using it. However I'd be very 
 interested to hear if there are any other compelling use cases for this.

 Pull requests welcome!

 Thanks,

 Dan

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




 -- 
 Kind Regards,
 Atamert Ölçgen

 -+-
 --+
 +++

 www.muhuk.com
  



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


Re: [ANN] silc - a tiny entity database for clojure (games)

2014-12-03 Thread dan . stone16321


  Is it possible to retrieve all entities with a set of attributes, 
 regardless of the attribute values?

 
Not yet, I haven't indexed for it. You could approximate it using the ave 
index if you just concat any set of entities under any value. However it 
would require the attributes you are interested in participating in the ave 
index.

It would be a worthy edition though so I'll look at it unless somebody 
wants to submit a pull request.

Cool project! Did you try using the pldb built into core.logic? I have a 
 similar system built atop pldb backing one of my side projects and I'm very 
 happy with it.


I do like pldb and core.logic and have used them in the past - I would very 
much like to introduce an optional core.logic front-end to this, however it 
was important to me that the primary interface was perhaps less declarative 
but with stronger performance guarantees as my use case for this is for 
game development.

-- 
You 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 there a tool to display all the references to a symbol in a project?

2014-12-03 Thread Yehonathan Sharvit
Is there a tool to display all the references to a symbol in a project?

Preferably without using emacs.

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: Is there a tool to display all the references to a symbol in a project?

2014-12-03 Thread Gary Trakhman
I use grep or ack. It's not exact, but it works.

On Wednesday, December 3, 2014, Yehonathan Sharvit vie...@gmail.com wrote:

 Is there a tool to display all the references to a symbol in a project?

 Preferably without using emacs.

 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
 javascript:_e(%7B%7D,'cvml','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
 javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@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: Is there a tool to display all the references to a symbol in a project?

2014-12-03 Thread Ashton Kemerling
I would recommend the silver searcher (ag) if the project is large, as it is 
much faster. 

--Ashton

Sent from my iPhone

 On Dec 3, 2014, at 8:34 AM, Gary Trakhman gary.trakh...@gmail.com wrote:
 
 I use grep or ack. It's not exact, but it works.
 
 On Wednesday, December 3, 2014, Yehonathan Sharvit vie...@gmail.com wrote:
 Is there a tool to display all the references to a symbol in a project?
 
 Preferably without using emacs.
 
 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.
 -- 
 You 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: Is there a tool to display all the references to a symbol in a project?

2014-12-03 Thread Francis Avila
Cursive Clojure can do this: alt-f7 the symbol. (But it's not a lightweight 
tool if that's what you mean by not emacs.)

On Wednesday, December 3, 2014 9:16:52 AM UTC-6, Yehonathan Sharvit wrote:

 Is there a tool to display all the references to a symbol in a project?

 Preferably without using emacs.

 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: Dynamic args in delayed function calls

2014-12-03 Thread Fluid Dynamics
The last group of examples reminds me of spreadsheet formula cells.

-- 
You 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: Is there a tool to display all the references to a symbol in a project?

2014-12-03 Thread Alex Hammel
If you're OK with using an editor that's not emacs, most of them have some
kind of ctags plugin these days. There's a decent looking ctags config for
clojure here http://andrew.stwrt.ca/posts/vim-ctags (haven't tried it
myself).

On Wed, Dec 3, 2014 at 7:40 AM, Ashton Kemerling ashtonkemerl...@gmail.com
wrote:

 I would recommend the silver searcher (ag) if the project is large, as it
 is much faster.

 --Ashton

 Sent from my iPhone

 On Dec 3, 2014, at 8:34 AM, Gary Trakhman gary.trakh...@gmail.com wrote:

 I use grep or ack. It's not exact, but it works.

 On Wednesday, December 3, 2014, Yehonathan Sharvit vie...@gmail.com
 wrote:

 Is there a tool to display all the references to a symbol in a project?

 Preferably without using emacs.

 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.

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


a library for writing and loading database fixtures - would love feedback

2014-12-03 Thread Daniel Higginbotham
I wrote a little (52 lines) library for writing and loading database 
fixtures: https://github.com/flyingmachine/vern

I'd love any feedback. Could the code be more succinct? Is there a name for 
this kind of pattern? Do the names make sense?

Thanks!
Daniel

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


Sharable custom reader macros in Clojurescript?

2014-12-03 Thread Hoang Minh Thang
Hi all, how do I add custom reader macros in Clojurescript (like 
data_readers.clj in Clojure)? I want to deliver them in libraries.

-- 
You 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: Getting sick and tired of [trace missing]

2014-12-03 Thread Paul L. Snyder
On Wed, 03 Dec 2014, Fluid Dynamics wrote:

 It's a giant pain to debug exceptions without stack traces. This seems to 
 be a problem specific to CCW, as I don't encounter it using other 
 development environments.
 
 Is this going to be fixed anytime soon?

Pseudonymous obnoxious person:

You have many options.

(a) Submit a (polite) issue to the CCW tracker with sufficient information
to reproduce the behavior. If an issue already exists, comment (politely)
on the issue to register that it's one toward which you would like the
project's volunteers to consider allocating their efforts.

(b) If the issue is of sufficient importance to you, offer a bounty
(payable in actual money) for an implementation of your desired behavior.
If you ask (politely), someone may be willing to implement it for you in
exchange for cash.

(c) Determine the source of the undesired behavior and implement a fix
yourself. I'd suspect the project's maintainers would happily entertain
a pull request. If you do not have sufficient knowledge to understand
how to approach an implementation, others may be willing to guide you if
you ask. Politely.

(d) Stop whinging and use the free software.

(e) Stop whinging and don't use the free software.

(f) Take your whinging somewhere else.

Moderators:

Many, many people sincerely attempted to help this person during the last
round of self-obsessed, abusive entitlement. May I request that you step in
if it looks like this thread is going down the same path?

I do not wish this community to become one that tolerates incivility.

  http://jacobian.org/writing/assholes/

Thanks to all of those on this list and behind the scenes who work to
support this great programming language, its tooling, and the vibrant
ecosystem of libraries.

Paul

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


Need advice on algorithm performance

2014-12-03 Thread Dmitriy Morozov
Hi, guys!

I have an issue with my function where I use zippers to modify data 
structure. The function modifies a tree (parsed grammar tree) to replace 
expressions with values from a given map. Sadly, the algorithm I came up 
with is pretty slow. I would appreciate if anyone can give me a hint on 
what would be the right approach to do what I'm trying to accomplish. 
Thanks!

(defn- transform-values [parse-tree values-map]
  Replaces all expressions in parsed tree with values from a given map.
  (loop [loc (zip/vector-zip parse-tree)]
(if (zip/end? loc)
(zip/root loc)
  (if (zip/branch? loc)
  (let [id (last (zip/children loc))]
(if (contains? values-map id)
(recur (zip/next (zip/replace loc (zip/node [(get 
values-map id)]
  (recur (zip/next (zip/edit loc #(into [] (butlast %)))
(recur (zip/next loc)))
  )))
(time
 (dotimes
 [_ 10]
   (transform-values
[:DIV [:ADD [:ID P1 exp_1] [:ID P2 exp_2] exp_2419] [:ID P3 
exp_3] exp_2418]
{exp_1 100 exp_2 20 exp_3 5})))
 
Elapsed time: 2317.491 msecs 



-- 
You 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: perform action after events stop for some period

2014-12-03 Thread Dylan Butman


Erik that's pretty! But be careful about go-loops and closed channels. This 
will recur infinitely if events-ch is closed (it will continuously return 
nil)


(defn invoke-after-uninterrupted-delay
  ([period events-ch f]
(invoke-after-uninterrupted-delay period events-ch f []))
  ([period events-ch f  args]
(async/go-loop []
  (let [[v p] (async/alts! [(async/timeout period) events-ch])]
(when v(if (= p events-ch)  (recur)
  (apply f args))


On Monday, December 1, 2014 8:33:10 PM UTC-5, Erik Price wrote:

 Coincidentally, we recently wrote code to do something very similar. The 
 following function will invoke f after period milliseconds, unless a 
 value is sent on events-ch, in which case the timeout is reset (and 
 starts counting down again):

 (defn invoke-after-uninterrupted-delay
   ([period events-ch f]
 (invoke-after-uninterrupted-delay period events-ch f []))
   ([period events-ch f  args]
 (async/go-loop []
   (let [[_ p] (async/alts! [(async/timeout period) events-ch])]
 (if (= p events-ch)
   (recur)
   (apply f args))

 e
 ​

 On Mon, Dec 1, 2014 at 6:50 PM, Brian Craft craft...@gmail.com 
 javascript: wrote:

 That version has the unfortunate behavior that (func) can be interrupted 
 if (event) is called while it is running. Here's another version using an 
 agent:

 (defn queue-with-delay2 [period func]
   (let [q (agent nil)]
 (fn []
   (send-off q (fn [t]
 (when t
   (future-cancel t))
 (future (Thread/sleep period) (send-off q (fn [_] 
 (func) nil

 Running with a sleep to see that (func) is not canceled by subsequence 
 (event) calls:

 (def event (queue-with-delay2 2000 #(do (println running) (Thread/sleep 
 2000) (println ending

 Oddly, if calling (event) between running and ending messages, the 
 repl will stack-overflow on the return value. No idea what that's about. 
 But, running like this is fine:

 (do (event) nil)





 On Monday, December 1, 2014 1:37:56 PM UTC-8, Brian Craft wrote:

 I have need to perform an action when a series of events is quiet for 
 some period. That is, if one event arrives an action is queued to execute 
 after some timeout. If a second event arrives the timeout is reset, and 
 so-forth.

 The following code seems to work, however I'm wondering if calling 
 'future' from 'swap!' is a bad idea (side effecting), and if there's a 
 better way.

 (defn queue-with-delay [period func]
   (let [f (atom nil)]
 (fn []
   (when @f
 (future-cancel @f))
   (swap! f (fn [_] (future (Thread/sleep period) (func)))


 Use like

 (def event (queue-with-delay 2000 #(println running)))
 (event)
 (event)
 (event)  ; pause 2 sec
 running



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




-- 
You 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: perform action after events stop for some period

2014-12-03 Thread Dylan Butman
 

Erik that's pretty! But be careful about go-loops and closed channels. This 
will recur infinitely if events-ch is closed (it will continuously return 
nil)

(defn invoke-after-uninterrupted-delay

  ([period events-ch f]

(invoke-after-uninterrupted-delay period events-ch f []))

  ([period events-ch f  args]

(async/go-loop []

  (let [[v p] (async/alts! [(async/timeout period) events-ch])]

(when v

  (if (= p events-ch)

(recur)

(apply f args)))
will allow the go-loop to return when the channel is closed.


On Monday, December 1, 2014 8:33:10 PM UTC-5, Erik Price wrote:

 Coincidentally, we recently wrote code to do something very similar. The 
 following function will invoke f after period milliseconds, unless a 
 value is sent on events-ch, in which case the timeout is reset (and 
 starts counting down again):

 (defn invoke-after-uninterrupted-delay
   ([period events-ch f]
 (invoke-after-uninterrupted-delay period events-ch f []))
   ([period events-ch f  args]
 (async/go-loop []
   (let [[_ p] (async/alts! [(async/timeout period) events-ch])]
 (if (= p events-ch)
   (recur)
   (apply f args))

 e
 ​

 On Mon, Dec 1, 2014 at 6:50 PM, Brian Craft craft...@gmail.com 
 javascript: wrote:

 That version has the unfortunate behavior that (func) can be interrupted 
 if (event) is called while it is running. Here's another version using an 
 agent:

 (defn queue-with-delay2 [period func]
   (let [q (agent nil)]
 (fn []
   (send-off q (fn [t]
 (when t
   (future-cancel t))
 (future (Thread/sleep period) (send-off q (fn [_] 
 (func) nil

 Running with a sleep to see that (func) is not canceled by subsequence 
 (event) calls:

 (def event (queue-with-delay2 2000 #(do (println running) (Thread/sleep 
 2000) (println ending

 Oddly, if calling (event) between running and ending messages, the 
 repl will stack-overflow on the return value. No idea what that's about. 
 But, running like this is fine:

 (do (event) nil)





 On Monday, December 1, 2014 1:37:56 PM UTC-8, Brian Craft wrote:

 I have need to perform an action when a series of events is quiet for 
 some period. That is, if one event arrives an action is queued to execute 
 after some timeout. If a second event arrives the timeout is reset, and 
 so-forth.

 The following code seems to work, however I'm wondering if calling 
 'future' from 'swap!' is a bad idea (side effecting), and if there's a 
 better way.

 (defn queue-with-delay [period func]
   (let [f (atom nil)]
 (fn []
   (when @f
 (future-cancel @f))
   (swap! f (fn [_] (future (Thread/sleep period) (func)))


 Use like

 (def event (queue-with-delay 2000 #(println running)))
 (event)
 (event)
 (event)  ; pause 2 sec
 running



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




-- 
You 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: perform action after events stop for some period

2014-12-03 Thread Erik Price
Thank you for calling my attention to this possibility!

e

On Wed, Dec 3, 2014 at 2:49 PM, Dylan Butman dbut...@gmail.com wrote:

 Erik that's pretty! But be careful about go-loops and closed channels.
 This will recur infinitely if events-ch is closed (it will continuously
 return nil)

 (defn invoke-after-uninterrupted-delay

   ([period events-ch f]

 (invoke-after-uninterrupted-delay period events-ch f []))

   ([period events-ch f  args]

 (async/go-loop []

   (let [[v p] (async/alts! [(async/timeout period) events-ch])]

 (when v

   (if (= p events-ch)

 (recur)

 (apply f args)))
 will allow the go-loop to return when the channel is closed.


 On Monday, December 1, 2014 8:33:10 PM UTC-5, Erik Price wrote:

 Coincidentally, we recently wrote code to do something very similar. The
 following function will invoke f after period milliseconds, unless a
 value is sent on events-ch, in which case the timeout is reset (and
 starts counting down again):

 (defn invoke-after-uninterrupted-delay
   ([period events-ch f]
 (invoke-after-uninterrupted-delay period events-ch f []))
   ([period events-ch f  args]
 (async/go-loop []
   (let [[_ p] (async/alts! [(async/timeout period) events-ch])]
 (if (= p events-ch)
   (recur)
   (apply f args))

 e
 ​

 On Mon, Dec 1, 2014 at 6:50 PM, Brian Craft craft...@gmail.com wrote:

 That version has the unfortunate behavior that (func) can be interrupted
 if (event) is called while it is running. Here's another version using an
 agent:

 (defn queue-with-delay2 [period func]
   (let [q (agent nil)]
 (fn []
   (send-off q (fn [t]
 (when t
   (future-cancel t))
 (future (Thread/sleep period) (send-off q (fn [_]
 (func) nil

 Running with a sleep to see that (func) is not canceled by subsequence
 (event) calls:

 (def event (queue-with-delay2 2000 #(do (println running)
 (Thread/sleep 2000) (println ending

 Oddly, if calling (event) between running and ending messages, the
 repl will stack-overflow on the return value. No idea what that's about.
 But, running like this is fine:

 (do (event) nil)





 On Monday, December 1, 2014 1:37:56 PM UTC-8, Brian Craft wrote:

 I have need to perform an action when a series of events is quiet for
 some period. That is, if one event arrives an action is queued to execute
 after some timeout. If a second event arrives the timeout is reset, and
 so-forth.

 The following code seems to work, however I'm wondering if calling
 'future' from 'swap!' is a bad idea (side effecting), and if there's a
 better way.

 (defn queue-with-delay [period func]
   (let [f (atom nil)]
 (fn []
   (when @f
 (future-cancel @f))
   (swap! f (fn [_] (future (Thread/sleep period) (func)))


 Use like

 (def event (queue-with-delay 2000 #(println running)))
 (event)
 (event)
 (event)  ; pause 2 sec
 running



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


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

Re: Need advice on algorithm performance

2014-12-03 Thread Jony Hudson
If I understand right, I think you might be able to use the existing 
replace functions in clojure.walk. I find that this is about twice as fast:

(time
 (dotimes
   [_ 10]
   (walk/postwalk-replace
 {exp_1 100 exp_2 20 exp_3 5}
 [:DIV [:ADD [:ID P1 exp_1] [:ID P2 exp_2] exp_2419] [:ID 
P3 exp_3] exp_2418])))


Jony

On Wednesday, 3 December 2014 18:49:01 UTC, Dmitriy Morozov wrote:

 Hi, guys!

 I have an issue with my function where I use zippers to modify data 
 structure. The function modifies a tree (parsed grammar tree) to replace 
 expressions with values from a given map. Sadly, the algorithm I came up 
 with is pretty slow. I would appreciate if anyone can give me a hint on 
 what would be the right approach to do what I'm trying to accomplish. 
 Thanks!

 (defn- transform-values [parse-tree values-map]
   Replaces all expressions in parsed tree with values from a given map.
   (loop [loc (zip/vector-zip parse-tree)]
 (if (zip/end? loc)
 (zip/root loc)
   (if (zip/branch? loc)
   (let [id (last (zip/children loc))]
 (if (contains? values-map id)
 (recur (zip/next (zip/replace loc (zip/node [(get 
 values-map id)]
   (recur (zip/next (zip/edit loc #(into [] (butlast %)))
 (recur (zip/next loc)))
   )))
 (time
  (dotimes
  [_ 10]
(transform-values
 [:DIV [:ADD [:ID P1 exp_1] [:ID P2 exp_2] exp_2419] [:ID P3 
 exp_3] exp_2418]
 {exp_1 100 exp_2 20 exp_3 5})))
  
 Elapsed time: 2317.491 msecs 





-- 
You 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: Getting sick and tired of [trace missing]

2014-12-03 Thread Niels van Klaveren
This isn't a CCW exclusive issue, but the Oracle JVM 'optimizing away' 
stacktraces.

It can be remedied by adding the '-XX:-OmitStackTraceInFastThrow' flag to 
the JVM startup parameters of the process you're starting.
If Leiningen is used to start the JVM, add the following setting to your 
lein project.clj map:


:jvm-opts ^:replace [-XX:-OmitStackTraceInFastThrow]

Oh, and you're welcome..



On Wednesday, December 3, 2014 6:29:23 PM UTC+1, Fluid Dynamics wrote:

 It's a giant pain to debug exceptions without stack traces. This seems to 
 be a problem specific to CCW, as I don't encounter it using other 
 development environments.

 Is this going to be fixed anytime soon?


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


Facebook Graph API via CLS

2014-12-03 Thread Sam Ritchie

Hey all,

I'm working on a Clojurescript wrapper of Facebook's JS SDK, using 
Prismatic's schema for documentation / types. Here's the code:


https://gist.github.com/sritchie/b517d67f9507aca36399

If anyone here's interested I'd be happy to put a little library up on 
github with this and the rest of the API.


Cheers,
Sam
--
Sam Ritchie (@sritchie)
Paddleguru Co-Founder
703.863.8561
www.paddleguru.com http://www.paddleguru.com/
Twitter http://twitter.com/paddleguru// Facebook 
http://facebook.com/paddleguru


--
You 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] silc - a tiny entity database for clojure (games)

2014-12-03 Thread dan . stone16321
I have released an update to the lib with a new index the 
`attribute-entity` index, and improved the readme (I hope). Check it out!

Regards,

Dan

-- 
You 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: Getting sick and tired of [trace missing]

2014-12-03 Thread Sam Ritchie

The first result of googling

jvm [trace missing]

is really helpful here.


Fluid Dynamics mailto:a2093...@trbvm.com
December 3, 2014 at 10:29 AM
It's a giant pain to debug exceptions without stack traces. This seems 
to be a problem specific to CCW, as I don't encounter it using other 
development environments.


Is this going to be fixed anytime soon?
--
You 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 
mailto:clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Sam Ritchie (@sritchie)
Paddleguru Co-Founder
703.863.8561
www.paddleguru.com http://www.paddleguru.com/
Twitter http://twitter.com/paddleguru// Facebook 
http://facebook.com/paddleguru


--
You 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] silc - a tiny entity database for clojure (games)

2014-12-03 Thread James Reeves
Coincidentally, I put together a similar library a few months ago (
https://github.com/weavejester/ittyon), but I didn't think anyone else
would find it useful. It looks like there are more people experimenting
with games in Clojure than I thought.

- James


On 3 December 2014 at 21:30, dan.stone16...@gmail.com wrote:

 I have released an update to the lib with a new index the
 `attribute-entity` index, and improved the readme (I hope). Check it out!

 Regards,

 Dan

 --
 You 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: Getting sick and tired of [trace missing]

2014-12-03 Thread Niels van Klaveren
I'm sure first thing in the morning there'll be someone at Larry Ellison's 
door clamoring for removal of hotspot optimization from the JVM..

On Wednesday, December 3, 2014 10:41:34 PM UTC+1, Sam Ritchie wrote:

 The first result of googling

 jvm [trace missing]

 is really helpful here.


-- 
You 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: Getting sick and tired of [trace missing]

2014-12-03 Thread Laurent PETIT
2014-12-03 22:20 GMT+01:00 Niels van Klaveren niels.vanklave...@gmail.com:

 This isn't a CCW exclusive issue, but the Oracle JVM 'optimizing away'
 stacktraces.

 It can be remedied by adding the '-XX:-OmitStackTraceInFastThrow' flag to
 the JVM startup parameters of the process you're starting.
 If Leiningen is used to start the JVM, add the following setting to your
 lein project.clj map:


 :jvm-opts ^:replace [-XX:-OmitStackTraceInFastThrow]


Hello Niels,

that's interesting. Would it deserve that CCW adds this option
automatically when asked to start a REPL ? I could probably easily do this
in both cases : when the REPL start is delegated to Leiningen, or when the
REPL is created by ccw by using whatever is in the project's java build
path.

Do you know if there would be e.g. performance impacts that would be
annoying for certain kinds of projects?



 Oh, and you're welcome..



 On Wednesday, December 3, 2014 6:29:23 PM UTC+1, Fluid Dynamics wrote:

 It's a giant pain to debug exceptions without stack traces. This seems to
 be a problem specific to CCW, as I don't encounter it using other
 development environments.

 Is this going to be fixed anytime soon?

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




-- 
Laurent Petit

-- 
You 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] encors: CORS middleware for Ring apps

2014-12-03 Thread David Dossot

Just to let everyone know that we've just released version 2.0 of encors, 
with these suggested changes in place.

The middleware should now feel more Clojure-ish and Ring-ish :)

Thanks James for the great feedback.

On Wednesday, November 26, 2014 4:31:37 PM UTC-8, Román González wrote:

 Good points...

 So possible changes:

 * Replace the get-policy-for-req argument with a just policy-options map

 This makes it easier to validate options just once. I guess all the 
 validations done on a simple
 Request - CorsPolicy function can be done by composing middleware 
 together (e.g. Middleware that check certain header or route + cors 
 middleware). I like this.

 * Remove the CorsPolicy type and just do the schema validation at the 
 beginning of the middleware.

 I believe this actionables are feasible. I discuss this internally and 
 develop of all this make sense.

 Thanks for your feedback James, highly appreciated.

 Roman.- 


 On Wed, Nov 26, 2014 at 3:43 PM, James Reeves ja...@booleanknot.com 
 javascript: wrote:

 On 26 November 2014 at 23:08, ro...@unbounce.com javascript: wrote:

 map-CorsPolicy enforces correctness of input, this way the wrap-cors 
 functions doesn't need to validate data. Probably we can add a call to 
 map-CorsPolicy as the first thing of wrap-cors function and keep this 
 function private.


 In Clojure, types and validation are orthogonal concepts. You don't need 
 to use deftype in order to validate a map.

 For instance, you could write your middleware function instead as:

 (defn wrap-cors [handler options]
   (s/validate cors-schema options)
   (fn [request]
 ...))

 Or better yet, perhaps just use s/defn instead.

 Given that we are returning a Policy per request call, calling a 
 map-CorsPolicy every time we call warp-cors sounds a bit overkill 
 performance wise... Instead of validating development settings once when 
 the namespaces is loaded, it is being validated every time a request comes 
 in. 


 Even though the function wrap-cors returns will be evaluated many times, 
 the wrap-cors function itself will likely only be evaluated once when your 
 handler is created. For instance:

 (def handler
   (wrap-cors my-routes cors-options))

 This means that there's no performance benefit to creating a type to just 
 contain the option map, particularly since you're not using type hints, so 
 you're accessing the type via reflection.

 By convention, Ring middleware also takes the handler as the first 
 argument, allowing it to be more easily threaded.

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


more colloquial do x n times

2014-12-03 Thread Sam Raker
I've got a decent-sized corpus of tweets, organized by hashtag, in a 
CouchDB db. I'm doing some initial explorations of my data, and was curious 
about which hashtags show up together in tweets. I want to do a NSA-style 
hops kind of algorithm--get all the hashtags that show up in the same 
tweets as hashtags that show up in the same tweets as hashtags that show up 
in the same tweets as my target hashtag, to an arbitrary depth. I wrote 
this:

(defn co-ocs [db ht  [s]] 
(reduce into (or s #{})
  (map #(map :text %)
 (map #(get-in % [:entities :hashtags])
  (:tweets (clutch/get-document db ht))

(defn co-occurrences [db ht depth]
(loop [tags (co-ocs db 5sos) i 1]
(if (= i depth) (recur
(reduce into tags
(map (partial co-ocs db) tags))
(inc i))
tags)))

It works, but loop + incrementing a counter seems profoundly un-clojuric. I 
suppose I could use `dotimes` + an atom, but that doesn't seem much better. 
Any suggestions?

-- 
You 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: more colloquial do x n times

2014-12-03 Thread Sam Raker
EDIT

On Wednesday, December 3, 2014 10:45:33 PM UTC-5, Sam Raker wrote:

 I've got a decent-sized corpus of tweets, organized by hashtag, in a 
 CouchDB db. I'm doing some initial explorations of my data, and was curious 
 about which hashtags show up together in tweets. I want to do a NSA-style 
 hops kind of algorithm--get all the hashtags that show up in the same 
 tweets as hashtags that show up in the same tweets as hashtags that show up 
 in the same tweets as my target hashtag, to an arbitrary depth. I wrote 
 this:

 (defn co-ocs [db ht  [s]] 
 (reduce into (or s #{})
   (map #(map :text %)
  (map #(get-in % [:entities 
 :hashtags])
   (:tweets (clutch/get-document db ht))

 (defn co-occurrences [db ht depth]
 (loop [tags (co-ocs db ht) i 1]
 (if (= i depth) (recur
 (reduce into tags
 (map (partial co-ocs db) tags))
 (inc i))
 tags)))

 It works, but loop + incrementing a counter seems profoundly un-clojuric. 
 I suppose I could use `dotimes` + an atom, but that doesn't seem much 
 better. Any suggestions?


-- 
You 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: Getting sick and tired of [trace missing]

2014-12-03 Thread Fluid Dynamics


On Wednesday, December 3, 2014 4:20:00 PM UTC-5, Niels van Klaveren wrote:

 This isn't a CCW exclusive issue, but the Oracle JVM 'optimizing away' 
 stacktraces.

 It can be remedied by adding the '-XX:-OmitStackTraceInFastThrow' flag to 
 the JVM startup parameters of the process you're starting.
 If Leiningen is used to start the JVM, add the following setting to your 
 lein project.clj map:


 :jvm-opts ^:replace [-XX:-OmitStackTraceInFastThrow]

 Thanks. Some googling had turned up something about that JVM option, but 
it was by no means obvious how to apply that anywhere but a commandline 
java -jar ... invocation. 

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


pack200 unknown attributes

2014-12-03 Thread Brian Craft
Experimenting with pack200, I get very many warnings like so:

Dec 04, 2014 5:11:31 AM com.sun.java.util.jar.pack.Utils$Pack200Logger 
warning
WARNING: Passing class file uncompressed due to unrecognized attribute: 
clojure/core$long.class

Without having any real understanding of what it's doing, it looks like 
something about the clojure code is defeating compression? Anyone have a 
clue?

-- 
You 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: help with my inefficient instaparse grammar

2014-12-03 Thread Zack Maril
Use :optimize :memory maybe? Section 10 here seems like your use 
case: https://github.com/Engelberg/instaparse/blob/master/docs/Performance.md
Watch htop and see if you have a process that is hitting swap without the 
optimization.
-Zack

On Wednesday, December 3, 2014 1:29:23 AM UTC-5, Sunil Nandihalli wrote:

 The file I tried it on is here 
 https://gist.github.com/8c0daef5b832b58c86fa

 On Wed, Dec 3, 2014 at 10:28 AM, Sunil S Nandihalli sunil.na...@gmail.com 
 javascript: wrote:

 Hi Everybody,
  https://gist.github.com/cced1cf377ed49005704  *instaparse_question.clj* 
 https://gist.github.com/anonymous/cced1cf377ed49005704#file-instaparse_question-clj
 Raw 
 https://gist.github.com/anonymous/cced1cf377ed49005704/raw/220ff32218839db388261fd8e2489288a0093606/instaparse_question.clj
 12345678910111213141516171819202122232425

 (ns lua-map-parser.instaparse-question
   (:require [instaparse.core :as insta]))
  
 (let [parser (insta/parser
  lua-file = {map-decl|return-statement}
   map-decl = 'local' identifier '='  '{' { map-entry} 
 '}' ;
   identifier =  #'[a-zA-Z\\_][0-9a-zA-Z\\-\\_]*' ;
   map-entry = '['  (string|number) ']' '=' 
 (string|number) ;
   string =  '\\\' #'([^\]|.)*' '\\\' ;
   number = integer | decimal ;
   decimal = #'-?[0-9]+\\.[0-9]+' ;
   integer = #'-?[0-9]+' ;
   return-statement = 'return' identifier
:auto-whitespace :comma)]
   (defn lua-map-parser [str]
 (parser str)))
  
 (lua-map-parser local CTRData = {
 [1]=2 ,
  [\3\]=4 }
 local MYData = { [\hello\] = \world\
 [\sunil\] = 1 [\satish\] = \office\
 [\dad\]=\home\ }
 return CTRData
 )

 The above grammar simply parses a map in lua-syntax. It works for the 
 above case. However, when I try to use it on a file that is about 1 MB in 
 size, it fails(not sure didn't wait longer than 2 minutes).  I would love 
 to hear if there is something that is grossly inefficient in the way I have 
 represented my grammar. The lua interpreter loads the file in no time (well 
 0.06 sec) . I would love any feedback on improving the grammar. Thanks
 Sunil.




-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.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.