Re: A faster clojure startup

2014-03-07 Thread Víctor R . Escobar
That are very great news! do you think this change in the design could have 
any side effect? For me this lazy concept is quite new and until today I 
only have read posts about the possitive effects it brings.

Do you think it could require that much of more memory that in some 
situations the OS would kill the process? (I am sorry if it sounds 
extreme... it's a side effect after work on clompex firmware scenarios). If 
some side effects are detected perhaps would be desiderable an activation 
flag for this patch (e.g. someone who prefers a full initialization at 
first).



-- 
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: A faster clojure startup

2014-03-07 Thread Víctor R . Escobar
That are very great news! do you think this change in the design could have
any side effect? For me this lazy concept is quite new and until today I
only have read posts about the possitive effects it brings.

Do you think it could require that much of more memory that in some
situations the OS would kill the process? (I am sorry if it sounds
extreme... it's a side effect after work on clompex firmware scenarios). If
some side effects are detected perhaps would be desiderable an activation
flag for this patch (e.g. someone who prefers a full initialization at
first).

El viernes, 28 de febrero de 2014 16:16:44 UTC+1, Gal Dolber escribió:

 Here're some notes on the lean compiler I've been working on for 
 clojure-objc

 http://galdolber.tumblr.com/post/78110050703/reduce-startup

 Feedback's welcome


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


Getting started - overcoming my first obstacles

2014-03-07 Thread Florian Salihovic


I am working on my first real Clojure application. I started building tools 
and looking use cases for my daily work, so i would
have a direct benefit from using Clojure. The first application would be an 
unpacking of an edn definition of access control lists
for Apache JackRabbit. The edn-acls vector represents such lists.

Privileges (:privilege i.e. jcr:read, jcr:all) to a path (:path i.e.  
/content) can be granted or denied (:primaryType rep:GrantACE, 
rep:DenyACE) for principals (:principalName i.e. admin workflow-editors).

I am currently stuck at the following questions:

   1. How to (efficiently - that would be ) accumulate the data. It seems like 
i am not getting the data returned from unpack-aces-for-path into a list or 
vector. I tried to pass an accumulator to edn-acl-unpack but that didn't work 
out.
   2. There are a bunch of zip methods already available, but i didn't find one 
which transforms a list/vector from a map {jcr:read [anonymous 
workflow-users] into [[jcr:read anonymous] [jcr:read 
workflow-users]]. I didn't find an implementation in core, but i wonder if 
there was something like that already.
   3. Getting more idiomatic ...

The code ...

(def edn-acls [{/content
[{rep:GrantACE
  [{jcr:read [anonymous workflow-users]}
   {jcr:all [admin workflow-editors]}]}]}
   {/etc
[{rep:DenyACE
  [{jcr:all [anonymous workflow-users]}]}
 {rep:GrantACE
  [{jcr:read [anonymous workflow-users]}]}
 {rep:GrantACE
  [{jcr:all [admin workflow-editors]}]}]}])
 (defn map-privileges-to-principals
  [primary-type
   privileges]
  (for [privilege-for-principals privileges
[privilege principals] privilege-for-principals]
(for [principal principals]
  (hash-map :primaryType primary-type
:privilege privilege
:principalName principal
 (defn unpack-aces
  [aces]
  (flatten
(for [ace aces]
  (for [[primary-type privileges] ace]
(map-privileges-to-principals primary-type privileges)
 (defn unpack-aces-for-path
  [aces-for-path]
  (for [[path aces] aces-for-path]
(hash-map :path path
  :acls (unpack-aces aces
 (defn edn-acl-unpack
  [policies]
  (let [head (first policies)
tail (rest policies)]
(when (not (empty? head))
  (let [entry (unpack-aces-for-path head)]
(when (not (empty? tail))
  (recur tail))
 (edn-acl-unpack edn-acls)

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


printing vals from a static hashmap

2014-03-07 Thread d0nski
Hi,

Newish to clojure and been wrecking my head the last while trying to figure 
this one out.

I have a series of similar xmls which I need to parse through and print out 
the results as a csv to file.

I call the below function at the correct level for the xml parsing, and it 
does parse the xml and create a csv.  If I just write to file at this stage 
it works fine, but I want to add the map to a static hashmap for parallel 
processing, so the below fucntion is called as part of the processing for 
pmap on the xmls.

(defn- parse [ measures id ]
(let [

result(for [measure measures
  :when (= (zf/xml1- measure :measureID zf/text) Samsung)
  entry (zf/xml- measure :MeasureEntry)]
   (into {} (for [measure-value-set (zf/xml- entry 
:MeasureValueSet)]
 {
  :Benchmark (zf/xml1- measure-value-set :Benchmark 
zf/text)
  :Value (zf/xml1- measure-value-set :Value zf/text)
  ;:Tenor (last (clojure.string/split (zf/xml1- 
measure-value-set :Benchmark zf/text) #\.))
 ;:Currency (for [dimension (zf/xml- entry :Dimension)
   ;:when (= (zf/xml1- dimension :type 
zf/text) Currency)]
;(zf/xml1- dimension :value zf/text))
   :Currency (first (zf/xml- entry :Dimension 
:value zf/text))}
   )))

measures2(distinct result)

  
Benchmark(map :Benchmark measures2)
Value(map :Value measures2)
Currency(map :Currency measures2)

mapfinal(map #(str %1 , %2 , %3  \n ) Benchmark Value 
Currency)
_(error mapfinal mapfinal)

]
(.put staticMeasureMap id mapfinal)
))


I am having trouble outputting the final static hashmap results though.


(spit (str /tmp/final.txt) (doall (vals staticMeasureMap)))

or

(spit (str /tmp/final.txt) (apply str (vals staticMeasureMap)))

But all it is returning is clojure.lang.LazySeq@ repeatedly.

Can someone advise on the best way to print out this hashmap to file?

-- 
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: Solving allocation problems; code review and core.logic

2014-03-07 Thread Laurens Van Houtven
On Fri, Mar 7, 2014 at 3:50 AM, Mark Engelberg mark.engelb...@gmail.comwrote:

 On Thu, Mar 6, 2014 at 4:56 AM, Laurens Van Houtven _...@lvh.cc wrote:

 Hm. I realize we're unlikely to change the nature of the problem, but
 would it help if we limit the search space? For example, if we only care
 about grants in increments of $50 or $100? Instead of working with dollars,
 working with grant tokens each worth $50 or $100 or so?


 Not really.  Let's do a little back-of-the-napkin estimate.
 Let's say you have 3000 attendees, each of whom can be granted $0, $50,
 $100, $150, ..., or $500. (That's 30,000 possible $50 bins to put money
 in).  Then let's say that you have $20,000 of funds to parcel out in
 increments of $50 (a total of 4000 parcels to give out).  So the number of
 possible ways to divvy this up is 30,000 take 4000 which is nearly 10^5114
 possibilities.


Eek! When you said slow, I was thinking ten minutes, not you're gonna
need a bigger universe :-D

It does appear the numerator is the big culprit; so even constraints like
all people get between zero and two thousand dollars with 100 increments
only don't fix it.

I apologize for getting your hopes up about Loco as a tool for this
 problem.  I've been using it a lot lately, and when I saw you describe your
 problem, and saw David Nolen suggest JaCoP for consideration, I immediately
 thought, Oh, I know how to model that in Loco.  And yes, I did know how
 to model it, but I just didn't properly think through the ramifications of
 whether it would work for the size problem you're talking about.  With
 further thought, I don't think any constraint solver would be able to
 tackle this.


No worries, it was fun :-)


 LP solvers exploit the linearity of the math constraints and the lack of
 any need for the result to be an integer in order to much more rapidly
 converge on a solution.

 Local search exploits the fact that you don't really care to prove that
 you have the optimal solution, you just need to find a solution that's
 really good.  So, for example, you would start by divvying up the money in
 a greedy way, and then randomly shift around money looking for ways to
 improve the situation, occasionally taking a suboptimal choice in order to
 avoid getting stuck in a local optimum.

 Honestly, I do think that the greedy approach, based on the linear model
 we discussed at the beginning, will give you a good, practical solution
 that's close enough to optimal to be worthwhile.


I don't know if you saw my original code; it's something I would describe
as greedy + linear. I can use that as a starting point for tabu search
maybe :-)

hth
lvh

-- 
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: printing vals from a static hashmap

2014-03-07 Thread Jim


On 07/03/14 09:39, d0nski wrote:


Can someone advise on the best way to print out this hashmap to file?

for dumping the entire map:

(spit /tmp/final.txt (pr-str staticMeasureMap))

for just the values:

(spit /tmp/final.txt (pr-str (vals staticMeasureMap)))

HTH,

Jim




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

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting started - overcoming my first obstacles

2014-03-07 Thread Walter van der Laan
Hi Florian,

To unpack your edn-acls I entered these expressions in a repl. Each 
expression goes one step deeper, so it is only the last expression that you 
need to unpack the acls. The other steps are included to illustrate the 
process.

(for [acl edn-acls]
  {:acl acl})

(for [acl edn-acls
  [path rep-maps] acl
  rep-map rep-maps]
  {:path path :rep-map rep-map})

(for [acl edn-acls
  [path rep-maps] acl
  rep-map rep-maps
  [rep privs] rep-map]
  {:path path :rep rep :privs privs})

(for [acl edn-acls
  [path rep-maps] acl
  rep-map rep-maps
  [rep privs] rep-map
  priv privs]
  {:path path :rep rep :priv priv})

(for [acl edn-acls
  [path rep-maps] acl
  rep-map rep-maps
  [rep privs] rep-map
  priv privs
  [jcr groups] priv]
  {:path path :rep rep :jcr jcr :groups groups})

(for [acl edn-acls
  [path rep-maps] acl
  rep-map rep-maps
  [rep privs] rep-map
  priv privs
  [jcr groups] priv
  group groups]
  {:path path :rep rep :jcr jcr :group group})

Succes with your application.

On Friday, March 7, 2014 9:44:32 AM UTC+1, Florian Salihovic wrote:

 I am working on my first real Clojure application. I started building tools 
 and looking use cases for my daily work, so i would
 have a direct benefit from using Clojure. The first application would be an 
 unpacking of an edn definition of access control lists
 for Apache JackRabbit. The edn-acls vector represents such lists.

 Privileges (:privilege i.e. jcr:read, jcr:all) to a path (:path i.e.  
 /content) can be granted or denied (:primaryType rep:GrantACE, 
 rep:DenyACE) for principals (:principalName i.e. admin 
 workflow-editors).

 I am currently stuck at the following questions:

1. How to (efficiently - that would be ) accumulate the data. It seems 
 like i am not getting the data returned from unpack-aces-for-path into a list 
 or vector. I tried to pass an accumulator to edn-acl-unpack but that didn't 
 work out.
2. There are a bunch of zip methods already available, but i didn't find 
 one which transforms a list/vector from a map {jcr:read [anonymous 
 workflow-users] into [[jcr:read anonymous] [jcr:read 
 workflow-users]]. I didn't find an implementation in core, but i wonder if 
 there was something like that already.
3. Getting more idiomatic ...

 The code ...

 (def edn-acls [{/content
 [{rep:GrantACE
   [{jcr:read [anonymous workflow-users]}
{jcr:all [admin workflow-editors]}]}]}
{/etc
 [{rep:DenyACE
   [{jcr:all [anonymous workflow-users]}]}
  {rep:GrantACE
   [{jcr:read [anonymous workflow-users]}]}
  {rep:GrantACE
   [{jcr:all [admin workflow-editors]}]}]}])
  (defn map-privileges-to-principals
   [primary-type
privileges]
   (for [privilege-for-principals privileges
 [privilege principals] privilege-for-principals]
 (for [principal principals]
   (hash-map :primaryType primary-type
 :privilege privilege
 :principalName principal
  (defn unpack-aces
   [aces]
   (flatten
 (for [ace aces]
   (for [[primary-type privileges] ace]
 (map-privileges-to-principals primary-type privileges)
  (defn unpack-aces-for-path
   [aces-for-path]
   (for [[path aces] aces-for-path]
 (hash-map :path path
   :acls (unpack-aces aces
  (defn edn-acl-unpack
   [policies]
   (let [head (first policies)
 tail (rest policies)]
 (when (not (empty? head))
   (let [entry (unpack-aces-for-path head)]
 (when (not (empty? tail))
   (recur tail))
  (edn-acl-unpack edn-acls)



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


Mock db data for unit tests

2014-03-07 Thread Mark Watson
I have a web service that uses Korma for interacting with my db. To mock 
data for unit tests I want to re-bind korma.core/select to return known 
data and not hit a db.

Currently I have a db ns:

(nsservices.db
  (:require [korma.core :refer :all]
   [korma.db :refer :all]))


With a function 'func-select' that calls korma.core/select

And a test ns:

(ns ad-gallery-services.core-test
  (:require [clojure.test :refer :all]
[ad-gallery-services.db :refer :all]
[ad-gallery-services.web :refer :all]))

(deftest func-select-test
  (testing Return nil if select returns empty
(with-redefs [korma.core/select (fn [ _] [])]
  (require 'ad-gallery-services.db :reload)
  (is (= (func-select 1)
 nil)


However, it keeps throwing the exception:

ArityException Wrong number of args (1) passed to: core$where

Why is it even evaluating 'where', and (most importantly) how can I mock 
this data?

-- 
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: Mock db data for unit tests

2014-03-07 Thread Alex Robbins
It looks like the issue is that korma.core/select is a macro, and has
already expanded by the time you redef it.

https://github.com/korma/Korma/blob/master/src/korma/core.clj#L113


On Fri, Mar 7, 2014 at 12:59 PM, Mark Watson mkw5...@gmail.com wrote:

 I have a web service that uses Korma for interacting with my db. To mock
 data for unit tests I want to re-bind korma.core/select to return known
 data and not hit a db.

 Currently I have a db ns:

 (nsservices.db
   (:require [korma.core :refer :all]
[korma.db :refer :all]))


 With a function 'func-select' that calls korma.core/select

 And a test ns:

 (ns ad-gallery-services.core-test
   (:require [clojure.test :refer :all]
 [ad-gallery-services.db :refer :all]
 [ad-gallery-services.web :refer :all]))

 (deftest func-select-test
   (testing Return nil if select returns empty
 (with-redefs [korma.core/select (fn [ _] [])]
   (require 'ad-gallery-services.db :reload)
   (is (= (func-select 1)
  nil)


 However, it keeps throwing the exception:

 ArityException Wrong number of args (1) passed to: core$where

 Why is it even evaluating 'where', and (most importantly) how can I mock
 this data?

 --
 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] durable-queue: an in-process disk-backed queue

2014-03-07 Thread Zach Tellman
I added the above-described features a few weeks back, but only got around 
to marking 0.1.1 today.  Fsync batching is described at the end of the 
README, let me know if you have any questions.

On Friday, February 7, 2014 11:52:11 AM UTC-8, Zach Tellman wrote:

 Hi Bob,

 Right now the API only allows for single puts, and fsyncing is 
 all-or-nothing.  However, this is just an artifact of my major use case for 
 the library, which relies on upstream batching of tasks.  I'm planning an 
 0.1.1 release which has an explicit `sync` method, and support for 
 sync-intervals (i.e. sync twice a second) and sync-thresholds (i.e. sync 
 every ten puts or takes).  The use case you describe could be achieved by 
 disabling automatic syncing, and doing a series of puts and takes followed 
 by a call to `sync`.

 If you have thoughts or suggestions on how this can be more useful for 
 you, please let me know.

 Zach


 On Fri, Feb 7, 2014 at 5:26 AM, Bob Hutchison 
 hutch...@recursive.cajavascript:
  wrote:


 On Feb 6, 2014, at 6:45 PM, Zach Tellman za...@factual.com javascript: 
 wrote:

 At Factual we get a lot of data thrown at us, and often don't have 
 control over the rate at which it comes in.  As such, it's preferable that 
 our buffer isn't bounded by the process' memory, since a temporary blip in 
 throughput may cause GC pauses, OOM exceptions, and other things that will 
 only exacerbate the problem.  It's also preferable that if the process 
 dies, we won't lose any data which hasn't yet escaped the process.  A 
 disk-backed queue satisfies both of these requirements.

 As such, I'm happy to announce that we're open sourcing 'durable-queue': 
 https://github.com/Factual/durable-queue.  It's a small, fast, 
 pure-Clojure implementation that in our production systems is responsible 
 for processing billions of entries daily.  We believe it has broad 
 applications, and are excited to see how others will use it.


 What excellent timing! I’ve been looking at ZeroMQ, RabbitMQ, and Kafka 
 for the last week or so. ZMQ is awfully attractive for what I’m trying to 
 do, but there are a few things it doesn’t do that I need done. I had begun 
 thinking of building something similar on top of Redis.

 You mention the idea of batching to reduce the impact of fsync. Is there 
 an API for batching puts? Is there a way to batch a complete! and put! new 
 tasks to the queue?

 One pattern that keeps coming up is:
- take a single task from the queue
- execute the task, which might generate a set of new tasks to be 
 queued on the same queue (and likely on other queues too)
- signal completion, and put the new tasks

 Cheers,
 Bob


 Zach

 P.S. If this sort of work is interesting to you, Factual is hiring: 
 https://groups.google.com/forum/#!searchin/clojure/factual/clojure/8bPIEnNpfyQ/lvv-9gkVozAJ

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 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/groups/opt_out.


  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 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 a topic in the 
 Google Groups Clojure group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/clojure/4tZFWdMKvjw/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




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

Re: Getting started - overcoming my first obstacles

2014-03-07 Thread Florian Salihovic
Hi Walter,

... i was actually thinking too complicated. I was actually working myself 
deeper and deeper by extracting methods, but i completely overlooked to 
simply destructure the data ...

Thanx a lot :)



Am Freitag, 7. März 2014 18:14:33 UTC+1 schrieb Walter van der Laan:

 Hi Florian,

 To unpack your edn-acls I entered these expressions in a repl. Each 
 expression goes one step deeper, so it is only the last expression that you 
 need to unpack the acls. The other steps are included to illustrate the 
 process.

 (for [acl edn-acls]
   {:acl acl})

 (for [acl edn-acls
   [path rep-maps] acl
   rep-map rep-maps]
   {:path path :rep-map rep-map})

 (for [acl edn-acls
   [path rep-maps] acl
   rep-map rep-maps
   [rep privs] rep-map]
   {:path path :rep rep :privs privs})

 (for [acl edn-acls
   [path rep-maps] acl
   rep-map rep-maps
   [rep privs] rep-map
   priv privs]
   {:path path :rep rep :priv priv})

 (for [acl edn-acls
   [path rep-maps] acl
   rep-map rep-maps
   [rep privs] rep-map
   priv privs
   [jcr groups] priv]
   {:path path :rep rep :jcr jcr :groups groups})

 (for [acl edn-acls
   [path rep-maps] acl
   rep-map rep-maps
   [rep privs] rep-map
   priv privs
   [jcr groups] priv
   group groups]
   {:path path :rep rep :jcr jcr :group group})

 Succes with your application.

 On Friday, March 7, 2014 9:44:32 AM UTC+1, Florian Salihovic wrote:

 I am working on my first real Clojure application. I started building 
 tools and looking use cases for my daily work, so i would
 have a direct benefit from using Clojure. The first application would be an 
 unpacking of an edn definition of access control lists
 for Apache JackRabbit. The edn-acls vector represents such lists.

 Privileges (:privilege i.e. jcr:read, jcr:all) to a path (:path i.e.  
 /content) can be granted or denied (:primaryType rep:GrantACE, 
 rep:DenyACE) for principals (:principalName i.e. admin 
 workflow-editors).

 I am currently stuck at the following questions:

1. How to (efficiently - that would be ) accumulate the data. It seems 
 like i am not getting the data returned from unpack-aces-for-path into a 
 list or vector. I tried to pass an accumulator to edn-acl-unpack but that 
 didn't work out.
2. There are a bunch of zip methods already available, but i didn't find 
 one which transforms a list/vector from a map {jcr:read [anonymous 
 workflow-users] into [[jcr:read anonymous] [jcr:read 
 workflow-users]]. I didn't find an implementation in core, but i wonder if 
 there was something like that already.
3. Getting more idiomatic ...

 The code ...

 (def edn-acls [{/content
 [{rep:GrantACE
   [{jcr:read [anonymous workflow-users]}
{jcr:all [admin workflow-editors]}]}]}
{/etc
 [{rep:DenyACE
   [{jcr:all [anonymous workflow-users]}]}
  {rep:GrantACE
   [{jcr:read [anonymous workflow-users]}]}
  {rep:GrantACE
   [{jcr:all [admin workflow-editors]}]}]}])
  (defn map-privileges-to-principals
   [primary-type
privileges]
   (for [privilege-for-principals privileges
 [privilege principals] privilege-for-principals]
 (for [principal principals]
   (hash-map :primaryType primary-type
 :privilege privilege
 :principalName principal
  (defn unpack-aces
   [aces]
   (flatten
 (for [ace aces]
   (for [[primary-type privileges] ace]
 (map-privileges-to-principals primary-type privileges)
  (defn unpack-aces-for-path
   [aces-for-path]
   (for [[path aces] aces-for-path]
 (hash-map :path path
   :acls (unpack-aces aces
  (defn edn-acl-unpack
   [policies]
   (let [head (first policies)
 tail (rest policies)]
 (when (not (empty? head))
   (let [entry (unpack-aces-for-path head)]
 (when (not (empty? tail))
   (recur tail))
  (edn-acl-unpack edn-acls)



-- 
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 G.Closure lib release 0.0-20140226-71326067

2014-03-07 Thread Stuart Sierra
Hi ClojureScript fans,

At last, we have a new Google Closure Library release!

For now, it's in a temporary *staging* repository. Here is a
sample project.clj file to get it:

https://gist.github.com/stuartsierra/9419597

Please try it out and report back.

If everything works, I will release this version to the
Maven Central repository.

   * * *

I'm asking for extra testing because this is a new build
process. Google used to make release ZIPs but they haven't
for over a year, so we have to go straight to the Git
repository. The new build script is here:

https://github.com/clojure/clojurescript/blob/gclosure-lib-release-from-git/script/closure-library-release/make-closure-library-jars.sh

This is separate from the Google Closure *Compiler*. Google
used make Maven releases for the compiler but has not done
so recently. See these mailing list threads for details:

https://groups.google.com/d/topic/closure-compiler-discuss/NXokuM4gpws/discussion
https://groups.google.com/d/topic/closure-compiler-discuss/G9y8oUGnZ58/discussion

Thanks,
-Stuart Sierra

-- 
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: ace / codemirror in cljs

2014-03-07 Thread Santiago Pelufo
Hi. Yes, Light Table uses codemirror. I would know very little about 
writting an editor in cljs, and it's a little late for a response but I 
just wanted to recommend reading some of this 
http://marijnhaverbeke.nl/blog/#codemirror about the implementation of 
codemirror, if case you are interested.



On Saturday, March 1, 2014 9:49:34 AM UTC-2, t x wrote:

 No, it appears lighttable uses CodeMIrror. 

 See: 
   * 
 https://github.com/LightTable/LightTable/search?q=codemirrorref=cmdform 
   * http://www.chris-granger.com/2012/04/15/light-tables-numbers/ 


 On Sat, Mar 1, 2014 at 3:02 AM, Dave Sann dave...@gmail.com javascript: 
 wrote: 
  have you considered reading the LightTable code? There is probably some 
 cljs 
  and editor in there 
  
  
  On Saturday, 1 March 2014 17:26:18 UTC+11, t x wrote: 
  
  Hi, 
  
Is there anything like http://codemirror.net/ or 
  http://ace.c9.io/#nav=about in cljs ? 
  
The goal is not to use codemirror/ace in a cljs project. The goal is 
  to read some interesting cljs code on how to write an editor. 
  
  Thanks! 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  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/groups/opt_out. 


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


Re: [ANN] loco 0.1.0

2014-03-07 Thread Alex Engelberg
Loco is now on version 0.2.0. The only major change is that I renamed 
$all-different? to $distinct (now takes a list of args instead of a 
variable number of args), and renamed $circuit? to $circuit. This is 
mostly because I wanted to provide more consistency throughout the function 
names by eliminating question marks. I realize that this is a small set of 
changes to push so early, but I figured it was best to get it out there as 
early as possible so people won't get too attached to the old functions.

--Alex

On Tuesday, March 4, 2014 1:46:51 PM UTC-8, Alex Engelberg wrote:

 Hi everyone.

 About 6 months ago, I created a Constraint Programming library called 
 CloCoP https://github.com/aengelberg/clocop. It was a Clojure wrapper 
 for a Java library, and it mostly maintained the imperative propagation 
 style. However, I was recently inspired to rework the library to have a 
 more declarative, functional taste.

 You can visit the github page https://github.com/aengelberg/loco for 
 more details, but here is some sample code.
 (use 'loco.core)
 (use 'loco.constraints)
 (defn solve-problem []
   (solution
 [($in :x 1 5)   ; x is between 1 and 5
  ($in :y 1 5)   ; y is between 1 and 5
  ($= ($+ :x 4) :y)] ; x + 4 = y
   ))
 (solve-problem)
 = {:x 1, :y 5}

 When you call a constraint function (that begins with a dollar sign), 
 Clojure data is returned instead of a mysterious Java object.. The Java 
 library underneath is now only accessed when the entire problem is passed 
 to the solution function.

 Loco is a good choice for speedily solving integer-domain problems. Let me 
 know what you think of the new problem model; I believe that it allows for 
 easier construction and manipulation of a model before solving it.

 --Alex


-- 
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] Kria, an async driver for Riak 2

2014-03-07 Thread dgrnbrg
This is really exciting! One question I have is how mature is Kria? Given that 
riak 2 isn't yet out, I'm still curious as to what kinds of testing/burn in 
you've done?

-- 
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] loco 0.1.0

2014-03-07 Thread Olli Piepponen
Hi,

Looks very interesting.

I was playing around with it yesterday at REPL, and I could not figure out 
how to do constraints with floats. Are all domains limited to integers at 
the moment, and if so do you have plans to add support for floating point 
domains in the future?

- Olli

On Saturday, March 8, 2014 6:41:43 AM UTC+7, Alex Engelberg wrote:

 Loco is now on version 0.2.0. The only major change is that I renamed 
 $all-different? to $distinct (now takes a list of args instead of a 
 variable number of args), and renamed $circuit? to $circuit. This is 
 mostly because I wanted to provide more consistency throughout the function 
 names by eliminating question marks. I realize that this is a small set of 
 changes to push so early, but I figured it was best to get it out there as 
 early as possible so people won't get too attached to the old functions.

 --Alex

 On Tuesday, March 4, 2014 1:46:51 PM UTC-8, Alex Engelberg wrote:

 Hi everyone.

 About 6 months ago, I created a Constraint Programming library called 
 CloCoP https://github.com/aengelberg/clocop. It was a Clojure wrapper 
 for a Java library, and it mostly maintained the imperative propagation 
 style. However, I was recently inspired to rework the library to have a 
 more declarative, functional taste.

 You can visit the github page https://github.com/aengelberg/loco for 
 more details, but here is some sample code.
 (use 'loco.core)
 (use 'loco.constraints)
 (defn solve-problem []
   (solution
 [($in :x 1 5)   ; x is between 1 and 5
  ($in :y 1 5)   ; y is between 1 and 5
  ($= ($+ :x 4) :y)] ; x + 4 = y
   ))
 (solve-problem)
 = {:x 1, :y 5}

 When you call a constraint function (that begins with a dollar sign), 
 Clojure data is returned instead of a mysterious Java object.. The Java 
 library underneath is now only accessed when the entire problem is passed 
 to the solution function.

 Loco is a good choice for speedily solving integer-domain problems. Let 
 me know what you think of the new problem model; I believe that it allows 
 for easier construction and manipulation of a model before solving it.

 --Alex



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