Clojure Group

2013-07-06 Thread Michael Sadler

Hello,

I came across the Clojure group via a blog and didn't want to spam it and 
decided to contact you directly. 

I'm wondering if this can be posted to the group:

#Metricata makes the software engineering process measurable and repeatable.
ses.newventurewebsites.com

Looking forward,

Michael Sadler, B. Comm., Web Developer
http://www.newventurewebsites.com/
@NewVentureFunds

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




Domain modelling question

2013-07-06 Thread Marc Schneider
Hello,

I'm trying to implement some business model in Clojure. I have several 
years of experience developing OO systems in Java. So it's still very hard 
to wrap my head to functional thinking. I hope you can help me with 
following questions.

I need a domain model for customers, contracts and features. 

Customers need to be created and modified.

You can add one or more contracts to customers. But only one contract can 
be active at a given time for a customer.

Within a contract you can add or remove features. Doing this should create 
a bill. A bill is not modifiable after creation.

The business rules are more complex in reality but I would be happy to get 
some inspirations how to implement such a thing with Clojure.

Functional programming has these immutability building block. But the 
domain model I'm thinking of has lots of mutable things that change over 
time when I execute the business actions.

Of course the history is also required in the solution. It must be 
possible to answer the question what feature was booked 2 months ago.

I started a solution where a customer was a map that had some refs to other 
maps. Then I had functions to alter the content of the refs. But code looks 
ugly and using it doesn't feel functional.

How should I structure data? Where are the functions? Do I have a bunch of 
customer functions that all get a customer map or defrecord as first 
parameter and maybe other required parameters to do the business work? And 
another similar bunch of functions for contracts, features and bills? But 
these structures are somehow nested, aren't they?

If structure will become more clear to me, then the next questions will go 
to the how can I persist and load all my state direction. I would be very 
glad if you could give me hints how I can solve this in a Clojure / 
functional way. I want to abstract it so that I can use some placeholder 
code in tests without the need for a real database.

That's quite a lot my brain is thinking about. I hope it's not too much to 
find any help here. Maybe there are some example applications out there 
where I can find some ideas? All I found yet are only small snippets but no 
working in the field with business meat :-)

Thanks a lot in advance for your help. If anything is unclear to you please 
tell me and I will try to describe my problems more clearly.

Marc

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




Re: [ANN] clojure-sql 0.1.0: relational algebra in clojure

2013-07-06 Thread Sean Corfield
On Fri, Jul 5, 2013 at 8:53 PM, Carlo Zancanaro
carlozancan...@gmail.com wrote:
 Is there a
 reason you don't use the database's table/column name quoting? It means that
 keywords like :first-name cannot be used as table names without a fair bit
 of trouble.

The DSL in java.jdbc supports :entities and :identifiers to deal with
quoting. Sounds like a reasonable enhancement to extend that
functionality to third-party libraries as well... feel free to create
issues in JIRA.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

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




Re: Clojure Group

2013-07-06 Thread Marcus Lindner


If it uses clojure or is for clojure and with more information about the 
product I think there speak nothing agianst it, if you post it.


It is not so good to register before you can get any information about 
the product, so more infos are needed.



VG
Marcus

Am 05.07.2013 19:37, schrieb Michael Sadler:


Hello,

I came across the Clojure group via a blog and didn't want to spam it 
and decided to contact you directly.


I'm wondering if this can be posted to the group:

#Metricata makes the software engineering process measurable and 
repeatable.

ses.newventurewebsites.com http://ses.newventurewebsites.com

Looking forward,

Michael Sadler, B. Comm., Web Developer
http://www.newventurewebsites.com/
@NewVentureFunds

--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient 
with your first post.

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google 
Groups Clojure group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com.

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




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

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




Re: Domain modelling question

2013-07-06 Thread Chris Ford
I find the modelling Clojure data structures very similar to working out
what your aggregates roots are for domain-driven design or using a document
data store.

I would suggest avoiding using refs in a customer map. In this case, it
sounds like customer is your natural aggregate root, so you should embed
your subordinate domain objects e.g. contracts directly in the customer
map. When you want to add or modify a contract, do it by making a whole new
customer map e.g. by using the update-in fn. That way your customer's
timeline is a progression of immutable customer states.

I would try and reserve references and mutability for multi-threaded
situations.

My two UGX,

Chris


On 6 July 2013 02:26, Marc Schneider snr@gmail.com wrote:

 Hello,

 I'm trying to implement some business model in Clojure. I have several
 years of experience developing OO systems in Java. So it's still very hard
 to wrap my head to functional thinking. I hope you can help me with
 following questions.

 I need a domain model for customers, contracts and features.

 Customers need to be created and modified.

 You can add one or more contracts to customers. But only one contract can
 be active at a given time for a customer.

 Within a contract you can add or remove features. Doing this should create
 a bill. A bill is not modifiable after creation.

 The business rules are more complex in reality but I would be happy to get
 some inspirations how to implement such a thing with Clojure.

 Functional programming has these immutability building block. But the
 domain model I'm thinking of has lots of mutable things that change over
 time when I execute the business actions.

 Of course the history is also required in the solution. It must be
 possible to answer the question what feature was booked 2 months ago.

 I started a solution where a customer was a map that had some refs to
 other maps. Then I had functions to alter the content of the refs. But code
 looks ugly and using it doesn't feel functional.

 How should I structure data? Where are the functions? Do I have a bunch of
 customer functions that all get a customer map or defrecord as first
 parameter and maybe other required parameters to do the business work? And
 another similar bunch of functions for contracts, features and bills? But
 these structures are somehow nested, aren't they?

 If structure will become more clear to me, then the next questions will go
 to the how can I persist and load all my state direction. I would be very
 glad if you could give me hints how I can solve this in a Clojure /
 functional way. I want to abstract it so that I can use some placeholder
 code in tests without the need for a real database.

 That's quite a lot my brain is thinking about. I hope it's not too much to
 find any help here. Maybe there are some example applications out there
 where I can find some ideas? All I found yet are only small snippets but no
 working in the field with business meat :-)

 Thanks a lot in advance for your help. If anything is unclear to you
 please tell me and I will try to describe my problems more clearly.

 Marc

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




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




Re: Domain modelling question

2013-07-06 Thread Alex Baranosky
Hi Marc,

But the domain model I'm thinking of has lots of mutable things that
change over time when I execute the business actions.
In your case, you don't need any STM to model any of your domain.  I'd go
so far as to say that to use refs for this is almost certainly a mistake.

Of course the history is also required in the solution. It must be
possible to answer the question 'what feature was booked 2 months ago'.
You can get by swimmingly by passing an immutable data structure around for
this, and amending it as you go.

Do I have a bunch of customer functions that all get a customer map or
defrecord as first parameter and maybe other required parameters to do the
business work
Yes, this is a good approach in my experience.  (You likely don't need to
use defrecords, plain hash maps work great here)

To persist your state you can store it in some DB and have a namespace that
acts as a storage layer for it.  Then you can stub the storage layer
functions in unit tests.  Some people might use a protocol for the storage
layer, and have an in-memory version for tests and another that uses an DB
for use in production.

But these structures are somehow nested, aren't they?
You can always have nested maps.  Maybe I misunderstood your question here?

Best,
Alex

On Sat, Jul 6, 2013 at 4:02 AM, Chris Ford christophertf...@gmail.comwrote:

 I find the modelling Clojure data structures very similar to working out
 what your aggregates roots are for domain-driven design or using a document
 data store.

 I would suggest avoiding using refs in a customer map. In this case, it
 sounds like customer is your natural aggregate root, so you should embed
 your subordinate domain objects e.g. contracts directly in the customer
 map. When you want to add or modify a contract, do it by making a whole new
 customer map e.g. by using the update-in fn. That way your customer's
 timeline is a progression of immutable customer states.

 I would try and reserve references and mutability for multi-threaded
 situations.

 My two UGX,

 Chris


 On 6 July 2013 02:26, Marc Schneider snr@gmail.com wrote:

 Hello,

 I'm trying to implement some business model in Clojure. I have several
 years of experience developing OO systems in Java. So it's still very hard
 to wrap my head to functional thinking. I hope you can help me with
 following questions.

 I need a domain model for customers, contracts and features.

 Customers need to be created and modified.

 You can add one or more contracts to customers. But only one contract can
 be active at a given time for a customer.

 Within a contract you can add or remove features. Doing this should
 create a bill. A bill is not modifiable after creation.

 The business rules are more complex in reality but I would be happy to
 get some inspirations how to implement such a thing with Clojure.

 Functional programming has these immutability building block. But the
 domain model I'm thinking of has lots of mutable things that change over
 time when I execute the business actions.

 Of course the history is also required in the solution. It must be
 possible to answer the question what feature was booked 2 months ago.

 I started a solution where a customer was a map that had some refs to
 other maps. Then I had functions to alter the content of the refs. But code
 looks ugly and using it doesn't feel functional.

 How should I structure data? Where are the functions? Do I have a bunch
 of customer functions that all get a customer map or defrecord as first
 parameter and maybe other required parameters to do the business work? And
 another similar bunch of functions for contracts, features and bills? But
 these structures are somehow nested, aren't they?

 If structure will become more clear to me, then the next questions will
 go to the how can I persist and load all my state direction. I would be
 very glad if you could give me hints how I can solve this in a Clojure /
 functional way. I want to abstract it so that I can use some placeholder
 code in tests without the need for a real database.

 That's quite a lot my brain is thinking about. I hope it's not too much
 to find any help here. Maybe there are some example applications out there
 where I can find some ideas? All I found yet are only small snippets but no
 working in the field with business meat :-)

 Thanks a lot in advance for your help. If anything is unclear to you
 please tell me and I will try to describe my problems more clearly.

 Marc

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

core.async go - out of memory

2013-07-06 Thread MikeM
Got an out of memory when experimenting with core.async channels in go 
blocks. The following is a simple example.
 
(defn go-loop
[]
(let [c0 (chan)]
 (while true
  (go
(! c0 1))
  (go
(println (! c0))
 
;(.start (Thread. go-loop))
 
Clojure 1.5.1, Java 1.7.0_25 32-bit running under Win7 x64.

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




Ring's session cookie-store

2013-07-06 Thread Alexander Solovyov
Hi all,

I wrote a small site using compojure and friend and naturally I used ring's
own wrap-session to handle sessions. My code looks like this:

(def app
  (- app-routes
  (friend/authenticate {:credential-fn (partial
creds/bcrypt-credential-fn
db/get-user)
:workflows [(workflows/interactive-form)]
:login-uri /login/})
  (handler/site {:session {:store (cookie-store TRULY SECRET KEY)}})
  (permacookie ring-session)))

And I discovered two problems with how session cookie was handled. First
one was that expiration was always set to session, while I want my users to
stay logged in for some longer period of time. I fixed that by writing my
own middleware (permacookie).

Second one is that if I restart my app, cookie's store never decrypts the
cookie. I guess that's something to do with cryptography, since when I
encrypt same data in repl, I get different result from what I have in
cookie.

Now I'm confused - why do have cookie store at all if memory storage will
provide exactly same persistency? Or am I doing something wrong? How do I
make cookie store decrypt and check cookies between server restarts?

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




Re: [ANN] clojure-sql 0.1.0: relational algebra in clojure

2013-07-06 Thread r0man
Composing queries is done via compose.

Take a look here: 
https://github.com/r0man/sqlingvo/blob/master/test/sqlingvo/test/core.clj#L16

On Saturday, July 6, 2013 5:46:06 AM UTC+2, Carlo wrote:

 Hey Roman,

 The issue that I see with `sqlingvo`, and the thing which I was trying to 
 solve for myself, is that it doesn't compose well. Unless I'm missing 
 something, you have to generate the entire query in the one `sql` form. To 
 me, this is a big restriction and was the number one thing I was trying to 
 fix with `clojure-sql`.

 The basic sort of thing I want to be able to do is this:

 (def users (- (table :users) (project [:id :person :username])))
 (def people (- (table :people) (project [:id :first-name])))

 (def combined-query (- people
 (rename {:id :person})
 (join users)
 (project [:username :first-name])))

 So now in queries I can use `people`, `users` and `combined-query` in the 
 same way. The only difference in terms of how I can compose them is that 
 they expose different fields (`users` exposes [:id, :person, :username], 
 `people` exposes [:id :first-name], `combined-query` exposes [:username 
 :first-name]). In this example it's not completely obvious why this would 
 be beneficial, but it means that I can change `users`, for instance, to 
 also have a `(select '(= :deleted false)` in its definition and no other 
 code has to change. They will all join/query against the users where 
 `deleted` is false without any other modifications of code.

 This freedom of composition is what you have in relational algebra, and 
 what I was trying to get in Clojure as well. All the naming of tables and 
 field aliases and everything is handled by the library, so you only have to 
 worry about constructing the queries. Unfortunately SQL provides a number 
 of operations outside of the relational algebra model (grouping, sorting, 
 take/drop), so they've been tacked on as a bit of an afterthought and 
 could probably use some improvement.

 Looking at `sqlingvo` did show up a mistake that I made in how I was 
 dealing with sorts, though, so thanks for that! I think our libraries just 
 have fairly different concerns at the moment.

 Carlo


 On 5 July 2013 20:59, r0man roman@burningswell.com javascript:wrote:

 Hi Carlo,

 if you'are looking for generating more complex SQL there's also:

 https://github.com/r0man/sqlingvo

 Roman.

 On Wednesday, July 3, 2013 10:48:07 AM UTC+2, Carlo wrote:

 Hey guys!

 I've been working on a small library to make writing SQL queries a 
 little bit easier. It's along the same lines as ClojureQL, but takes a 
 different approach and compiles into quite different SQL in the end.

 At the moment it's quite immature, but it should be able to support any 
 queries which can be expressed in relational algebra. There will be some 
 SQL queries which can't be expressed in clojure-sql, but hopefully there 
 won't be too many of those. A greater limitation is that at the moment the 
 SQL generation is specific to the PostgresSQL database (although any 
 contributions for other databases are welcome!).

 Dependency vector: [clojure-sql 0.1.0]
 Repository: 
 https://bitbucket.org/czan/**clojure-sqlhttps://bitbucket.org/czan/clojure-sql
 Clojars link: 
 https://clojars.org/clojure-**sqlhttps://clojars.org/clojure-sql

 Let me know what you think!

 Carlo

  -- 
 -- 
 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/groups/opt_out.




Re: New CSS library - Garden

2013-07-06 Thread Steven Degutis
So far, I really like Garden.

There's one thing though that's making it difficult. It's hard to see that
nested rules are nested.

;; hard to see nesting[:footer {:color red
  :background-color blue}
 [:a {:color green}]]
;; much easier(:footer {:color red
  :background-color blue}
 [:a {:color green}])

(That's a bad example because it's so short. In the real world, much longer
and deeper-nested rules show it clearer.)

Technically I'm using emacs with clojure-mode.el, which indents vectors by
only 1 char. But I don't think that's the problem. Normally it's good to
indent them by only 1 char, but there's no way to differentiate between
[:some [:random :data]], which should be indented like that, and a vector
of garden-rules which should be indented more obviously. So I don't think
this is something that changing our editors/plugins will fix.

One solution is to use
defrulehttps://github.com/noprompt/garden/issues/5#issuecomment-19848873more
often. But if I have 3 elements with 3 children each, and each child
has 3 children, that's already 27 defrules I have to stick above it.
That'll get pretty unruly quick.

So I was thinking of just using a dummy macro like this:

(defmacro rule [ body] `[~@body])
(def footer
  (rule :footer {:color red
 :background-color blue}
(rule :a {:color green})))

But you can imagine my discomfort at writing/using a macro just to make
indentation easier.

Are there any better solutions to this?

-Steven


On Tue, Apr 9, 2013 at 2:58 PM, Joel Holdbrooks cjholdbro...@gmail.comwrote:

 Nobel Clojurians,

 I am pleased to announce the alpha version of 
 *Garden*https://github.com/noprompt/garden,
 a new library for writing CSS in Clojure.

 The project weds the best ideas from Hiccup, gaka, and cssgen and aims to
 provide a clean and conventional way to author stylesheets without being
 too simple or too complex.

 Currently the list of notable features include:

- Nestable rules
- Nestable declarations (this my change)
- A builtin set of tools for working with CSS unit values
- Convenient multiple selector syntax (IE. h1, h2, h3 { ... })
- Output formatting options

 What's planned for the near future:

- The ability to use Clojure meta as a media query
- A builtin set of tools for working with CSS color values
-  selector syntax for nested rules

 For those of you who are interested in this sort of thing, please have a
 look at the *project's repository* https://github.com/noprompt/garden.
 There is still quite a bit of ground to do cover and any
 help/criticism/contribution would be greatly appreciated.

 Please feel free to offer suggestions, ask questions, open issues, or send
 pull requests. I would love nothing more than to see this library succeed
 where other's have not.


 Truly,

 Joel Holdbrooks (aka noprompt)

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




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




Re: [ANN] clojure-sql 0.1.0: relational algebra in clojure

2013-07-06 Thread Carlo Zancanaro
This is a fairly restricted composition, though:

(def triangles (compose (select [:color :num_sides] (from :shapes))
(where '(= :num_sides 3
(def green-triangles (compose triangles
  (where '(= :color green
(sql green-triangles)
;= [SELECT color, num_sides FROM shapes WHERE (color = ?) green]

We've lost our `num_sides` selection, so now our query is wrong. Last
clause wins means you have to be aware of the previous ones to ensure you
don't obliterate them when composing.

The same example in `clojure-sql`:

(def triangles (- (table :shapes)
   (project [:color :num_sides])
   (select '(= :num_sides 3
(def green-triangles (select triangles '(= :color :green)))
(deref green-triangles)
;= [SELECT \shapes2142\.\color\ AS \color\,
\shapes2142\.\num_sides\ AS \num_sides\ FROM \shapes\ AS
\shapes2142\ WHERE ((\shapes2142\.\num_sides\ = 3) AND
(\shapes2142\.\color\ = ?)) green]

On 6 July 2013 22:37, r0man roman.sche...@burningswell.com wrote:

 Composing queries is done via compose.

 Take a look here:
 https://github.com/r0man/sqlingvo/blob/master/test/sqlingvo/test/core.clj#L16


 On Saturday, July 6, 2013 5:46:06 AM UTC+2, Carlo wrote:

 Hey Roman,

 The issue that I see with `sqlingvo`, and the thing which I was trying to
 solve for myself, is that it doesn't compose well. Unless I'm missing
 something, you have to generate the entire query in the one `sql` form. To
 me, this is a big restriction and was the number one thing I was trying to
 fix with `clojure-sql`.

 The basic sort of thing I want to be able to do is this:

 (def users (- (table :users) (project [:id :person :username])))
 (def people (- (table :people) (project [:id :first-name])))

 (def combined-query (- people
 (rename {:id :person})
 (join users)
 (project [:username :first-name])))

 So now in queries I can use `people`, `users` and `combined-query` in the
 same way. The only difference in terms of how I can compose them is that
 they expose different fields (`users` exposes [:id, :person, :username],
 `people` exposes [:id :first-name], `combined-query` exposes [:username
 :first-name]). In this example it's not completely obvious why this would
 be beneficial, but it means that I can change `users`, for instance, to
 also have a `(select '(= :deleted false)` in its definition and no other
 code has to change. They will all join/query against the users where
 `deleted` is false without any other modifications of code.

 This freedom of composition is what you have in relational algebra, and
 what I was trying to get in Clojure as well. All the naming of tables and
 field aliases and everything is handled by the library, so you only have to
 worry about constructing the queries. Unfortunately SQL provides a number
 of operations outside of the relational algebra model (grouping, sorting,
 take/drop), so they've been tacked on as a bit of an afterthought and
 could probably use some improvement.

 Looking at `sqlingvo` did show up a mistake that I made in how I was
 dealing with sorts, though, so thanks for that! I think our libraries just
 have fairly different concerns at the moment.

 Carlo


 On 5 July 2013 20:59, r0man roman@burningswell.**com wrote:

 Hi Carlo,

 if you'are looking for generating more complex SQL there's also:

 https://github.com/r0man/**sqlingvo https://github.com/r0man/sqlingvo

 Roman.

 On Wednesday, July 3, 2013 10:48:07 AM UTC+2, Carlo wrote:

 Hey guys!

 I've been working on a small library to make writing SQL queries a
 little bit easier. It's along the same lines as ClojureQL, but takes a
 different approach and compiles into quite different SQL in the end.

 At the moment it's quite immature, but it should be able to support any
 queries which can be expressed in relational algebra. There will be some
 SQL queries which can't be expressed in clojure-sql, but hopefully there
 won't be too many of those. A greater limitation is that at the moment the
 SQL generation is specific to the PostgresSQL database (although any
 contributions for other databases are welcome!).

 Dependency vector: [clojure-sql 0.1.0]
 Repository: 
 https://bitbucket.org/czan/**clo**jure-sqlhttps://bitbucket.org/czan/clojure-sql
 Clojars link: 
 https://clojars.org/clojure-**sq**lhttps://clojars.org/clojure-sql

 Let me know what you think!

 Carlo

  --
 --
 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=enhttp://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are 

Walking a tree

2013-07-06 Thread looselytyped
Good morning everyone! 

I have a problem that I have been struggling with for a few days now. I 
have a directed acyclic graph that I am trying to walk, and can't seem to 
figure out a to prevent my walking already visited branches. Here is the 
code 

(def values
  [{:v a :parent [b]}
   {:v b :parent [c]}
   {:v c :parent [d e]}
   {:v d :parent [f]}
   {:v e :parent [f]}
   {:v f}])

As you can see, I have a vector of records, each with a value and a 
vector of parents. A node can have more than zero or more parents.

 a o
   |
 b o
   |
 c o
   |\
 d o o e
   |/   
 f o

Here is the fruits of several attempts ... 

(defn walk-tree
  ([values]
 (letfn [(in?
   [seq elm]
   (some #(= elm %) seq))
 (walk [already id]
   (when-not (in? already id)
 (when-let [n (some #(if (= id (:v %)) %) values)]
   (lazy-seq
(cons (:v n)
  (mapcat #(walk (conj already (:v n)) %) (:parent 
n)))]
   (walk #{} (:v (first values))

I was hoping to use the set as a way to record which nodes have been 
visited. Unfortunately as you might be able to tell, that's not going to 
work. The result of running this is 

(a b c d f e f)

Notice that f gets in the list twice. One way to do it would be to make a 
set out of it, but that eliminates the laziness aspect.  

Can anyone point me in the right direction here? 

Thanks,

Raju

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




Re: Walking a tree

2013-07-06 Thread Stanislav Sedov

On Jul 6, 2013, at 9:33 AM, looselytyped raju.gan...@gmail.com wrote:

 Good morning everyone! 
 
 I have a problem that I have been struggling with for a few days now. I have 
 a directed acyclic graph that I am trying to walk, and can't seem to figure 
 out a to prevent my walking already visited branches. Here is the code 
 
 (def values
   [{:v a :parent [b]}
{:v b :parent [c]}
{:v c :parent [d e]}
{:v d :parent [f]}
{:v e :parent [f]}
{:v f}])

It sounds like what you have here is not a directed acyclic graph.  In DAGs all 
links
are directed and there are no cycles.

 
 As you can see, I have a vector of records, each with a value and a vector 
 of parents. A node can have more than zero or more parents.
 
  a o
|
  b o
|
  c o
|\
  d o o e
|/   
  f o
 

You might want to look at standard graph traversal algorithms, like DFS and
BFS [1]. I'd also suggest to store links to childs instead of links to parents, 
so
you don't have to traverse it backwards, though for undirected graph there's no
difference .

[1] http://en.wikipedia.org/wiki/Graph_traversal

--
ST4096-RIPE


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




Re: Offline Clojure docs

2013-07-06 Thread Tom Faulhaber
Sorry, my second method should have been:

$ curl  -L https://github.com/clojure/clojure/archive/gh-pages.tar.gz | tar 
xvzf -

Enjoy!

Tom

On Sunday, June 30, 2013 7:44:17 PM UTC-4, David Pollak wrote:

 Folks,

 Is there an offline package of Clojure docs (the full core.* api docs, 
 cheat sheets, etc.)?

 I'm traveling with intermittent Internet connectivity (I'm in China now 
 and it's marginal but I'm going to the UP in Michigan where there's no 
 Internet within 15 miles of where I'm staying).

 With all the travel and flying and such, it'd be great to have all the 
 docs without having to clone all the various source repositories.

 Thanks for your help.

 David


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




Re: New CSS library - Garden

2013-07-06 Thread Steven Degutis
Oh, two more things.

First, it would be really cool to have a tool to convert CSS to GardenCSS.
Michał Marczyk suggested using Instaparse with the CSS3 grammar, which
sounds like a really easy way to make this happen. Unfortunately I don't
have the time or skill to do it, but if anyone else does, it sounds like
too cool an idea to pass up!

Also, I have gotten into the habit of defining CSS rules like { margin:
0px; margin-top: 0px; } because I can never remember the order of {margin:
a b c d}. But this won't work in Garden, because maps have no order, and
this trick relies totally on ordering. So it's something to watch out for
if you have the same habit.

-Steven


On Sat, Jul 6, 2013 at 8:58 AM, Steven Degutis sbdegu...@gmail.com wrote:

 So far, I really like Garden.

 There's one thing though that's making it difficult. It's hard to see that
 nested rules are nested.

 ;; hard to see nesting[:footer {:color red
   :background-color blue}
  [:a {:color green}]]
 ;; much easier(:footer {:color red
   :background-color blue}
  [:a {:color green}])

 (That's a bad example because it's so short. In the real world, much
 longer and deeper-nested rules show it clearer.)

 Technically I'm using emacs with clojure-mode.el, which indents vectors by
 only 1 char. But I don't think that's the problem. Normally it's good to
 indent them by only 1 char, but there's no way to differentiate between
 [:some [:random :data]], which should be indented like that, and a vector
 of garden-rules which should be indented more obviously. So I don't think
 this is something that changing our editors/plugins will fix.

 One solution is to use 
 defrulehttps://github.com/noprompt/garden/issues/5#issuecomment-19848873more
  often. But if I have 3 elements with 3 children each, and each child
 has 3 children, that's already 27 defrules I have to stick above it.
 That'll get pretty unruly quick.

 So I was thinking of just using a dummy macro like this:

 (defmacro rule [ body] `[~@body])
 (def footer
   (rule :footer {:color red
  :background-color blue}
 (rule :a {:color green})))

 But you can imagine my discomfort at writing/using a macro just to make
 indentation easier.

 Are there any better solutions to this?

 -Steven


 On Tue, Apr 9, 2013 at 2:58 PM, Joel Holdbrooks cjholdbro...@gmail.comwrote:

 Nobel Clojurians,

 I am pleased to announce the alpha version of 
 *Garden*https://github.com/noprompt/garden,
 a new library for writing CSS in Clojure.

 The project weds the best ideas from Hiccup, gaka, and cssgen and aims to
 provide a clean and conventional way to author stylesheets without being
 too simple or too complex.

 Currently the list of notable features include:

- Nestable rules
- Nestable declarations (this my change)
- A builtin set of tools for working with CSS unit values
- Convenient multiple selector syntax (IE. h1, h2, h3 { ... })
- Output formatting options

 What's planned for the near future:

- The ability to use Clojure meta as a media query
- A builtin set of tools for working with CSS color values
-  selector syntax for nested rules

 For those of you who are interested in this sort of thing, please have a
 look at the *project's repository* https://github.com/noprompt/garden.
 There is still quite a bit of ground to do cover and any
 help/criticism/contribution would be greatly appreciated.

 Please feel free to offer suggestions, ask questions, open issues, or
 send pull requests. I would love nothing more than to see this library
 succeed where other's have not.


 Truly,

 Joel Holdbrooks (aka noprompt)

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






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

Re: Walking a tree

2013-07-06 Thread Carlo Zancanaro
Give this a go:

(defn ^:private walk-tree* [all seen to-do]
  (when-let [[curr  others] to-do]
(if (contains? seen curr)
  (recur all seen others)
  (lazy-seq
   (when-let [node (first (filter #(= (:v %) curr) all))]
 (println node)
 (cons curr
   (walk-tree* all
   (conj seen curr)
   (concat others
   (:parent node)

(defn walk-tree [all]
  (walk-tree* all #{} [(- all first :v)]))

I'm still not super happy with it, but it should solve your problem. The
basic trick is to not use things like `mapcat`, as you need to keep
updating some state (the `seen` map) between calls. The approach here is to
pass work to be done and work to be ignored together. Then both can be
kept up to date in sync with each other. Your recursion becomes a bit more
explicit, too.

I hope that helps!


On 7 July 2013 00:33, looselytyped raju.gan...@gmail.com wrote:

 Good morning everyone!

 I have a problem that I have been struggling with for a few days now. I
 have a directed acyclic graph that I am trying to walk, and can't seem to
 figure out a to prevent my walking already visited branches. Here is the
 code

 (def values
   [{:v a :parent [b]}
{:v b :parent [c]}
{:v c :parent [d e]}
{:v d :parent [f]}
{:v e :parent [f]}
{:v f}])

 As you can see, I have a vector of records, each with a value and a
 vector of parents. A node can have more than zero or more parents.

  a o
|
  b o
|
  c o
|\
  d o o e
|/
  f o

 Here is the fruits of several attempts ...

 (defn walk-tree
   ([values]
  (letfn [(in?
[seq elm]
(some #(= elm %) seq))
  (walk [already id]
(when-not (in? already id)
  (when-let [n (some #(if (= id (:v %)) %) values)]
(lazy-seq
 (cons (:v n)
   (mapcat #(walk (conj already (:v n)) %) (:parent
 n)))]
(walk #{} (:v (first values))

 I was hoping to use the set as a way to record which nodes have been
 visited. Unfortunately as you might be able to tell, that's not going to
 work. The result of running this is

 (a b c d f e f)

 Notice that f gets in the list twice. One way to do it would be to make
 a set out of it, but that eliminates the laziness aspect.

 Can anyone point me in the right direction here?

 Thanks,

 Raju

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




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




Re: Walking a tree

2013-07-06 Thread looselytyped
Dear Stanislav, 

Thank you. You got me going down the right path. Upon looking around for a 
BFS solution, I came across this blog post 
http://hueypetersen.com/posts/2013/06/25/graph-traversal-with-clojure/that 
had me going down the right direction. Which leads me to Carlo's response 
-- You are SO right. It was mapcat that was hurting me. 

Thank you all. I do appreciate this. I will keep digging, but Carlo's 
prompt response definitely got me past this rut. 

Warm regards, 

Raju

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




Re: [ANN] clojure-sql 0.1.0: relational algebra in clojure

2013-07-06 Thread r0man
You can do this with the second argument to the where function. I added an 
example here:
https://github.com/r0man/sqlingvo/blob/master/test/sqlingvo/test/core.clj#L24

On Saturday, July 6, 2013 4:02:23 PM UTC+2, Carlo wrote:

 This is a fairly restricted composition, though:

 (def triangles (compose (select [:color :num_sides] (from :shapes))
 (where '(= :num_sides 3
 (def green-triangles (compose triangles
   (where '(= :color green
 (sql green-triangles)
 ;= [SELECT color, num_sides FROM shapes WHERE (color = ?) green]

 We've lost our `num_sides` selection, so now our query is wrong. Last 
 clause wins means you have to be aware of the previous ones to ensure you 
 don't obliterate them when composing.

 The same example in `clojure-sql`:

 (def triangles (- (table :shapes)
(project [:color :num_sides])
(select '(= :num_sides 3
 (def green-triangles (select triangles '(= :color :green)))
 (deref green-triangles)
 ;= [SELECT \shapes2142\.\color\ AS \color\, 
 \shapes2142\.\num_sides\ AS \num_sides\ FROM \shapes\ AS 
 \shapes2142\ WHERE ((\shapes2142\.\num_sides\ = 3) AND 
 (\shapes2142\.\color\ = ?)) green]

 On 6 July 2013 22:37, r0man roman@burningswell.com javascript:wrote:

 Composing queries is done via compose.

 Take a look here: 
 https://github.com/r0man/sqlingvo/blob/master/test/sqlingvo/test/core.clj#L16


 On Saturday, July 6, 2013 5:46:06 AM UTC+2, Carlo wrote:

 Hey Roman,

 The issue that I see with `sqlingvo`, and the thing which I was trying 
 to solve for myself, is that it doesn't compose well. Unless I'm missing 
 something, you have to generate the entire query in the one `sql` form. To 
 me, this is a big restriction and was the number one thing I was trying to 
 fix with `clojure-sql`.

 The basic sort of thing I want to be able to do is this:

 (def users (- (table :users) (project [:id :person :username])))
 (def people (- (table :people) (project [:id :first-name])))

 (def combined-query (- people
 (rename {:id :person})
 (join users)
 (project [:username :first-name])))

 So now in queries I can use `people`, `users` and `combined-query` in 
 the same way. The only difference in terms of how I can compose them is 
 that they expose different fields (`users` exposes [:id, :person, 
 :username], `people` exposes [:id :first-name], `combined-query` exposes 
 [:username :first-name]). In this example it's not completely obvious why 
 this would be beneficial, but it means that I can change `users`, for 
 instance, to also have a `(select '(= :deleted false)` in its definition 
 and no other code has to change. They will all join/query against the users 
 where `deleted` is false without any other modifications of code.

 This freedom of composition is what you have in relational algebra, and 
 what I was trying to get in Clojure as well. All the naming of tables and 
 field aliases and everything is handled by the library, so you only have to 
 worry about constructing the queries. Unfortunately SQL provides a number 
 of operations outside of the relational algebra model (grouping, sorting, 
 take/drop), so they've been tacked on as a bit of an afterthought and 
 could probably use some improvement.

 Looking at `sqlingvo` did show up a mistake that I made in how I was 
 dealing with sorts, though, so thanks for that! I think our libraries just 
 have fairly different concerns at the moment.

 Carlo


 On 5 July 2013 20:59, r0man roman@burningswell.**com wrote:

 Hi Carlo,

 if you'are looking for generating more complex SQL there's also:

 https://github.com/r0man/**sqlingvo https://github.com/r0man/sqlingvo

 Roman.

 On Wednesday, July 3, 2013 10:48:07 AM UTC+2, Carlo wrote:

 Hey guys!

 I've been working on a small library to make writing SQL queries a 
 little bit easier. It's along the same lines as ClojureQL, but takes a 
 different approach and compiles into quite different SQL in the end.

 At the moment it's quite immature, but it should be able to support 
 any queries which can be expressed in relational algebra. There will be 
 some SQL queries which can't be expressed in clojure-sql, but hopefully 
 there won't be too many of those. A greater limitation is that at the 
 moment the SQL generation is specific to the PostgresSQL database 
 (although 
 any contributions for other databases are welcome!).

 Dependency vector: [clojure-sql 0.1.0]
 Repository: 
 https://bitbucket.org/czan/**clo**jure-sqlhttps://bitbucket.org/czan/clojure-sql
 Clojars link: 
 https://clojars.org/clojure-**sq**lhttps://clojars.org/clojure-sql

 Let me know what you think!

 Carlo

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

Jenkins/leiningen trigger build when a snapshot gets updated

2013-07-06 Thread Trevor Bernard
Hi,

Does there exist a Hudson/Jenkins plugin for leiningen to trigger a build 
when a SNAPSHOT dependency gets updated?

Warmest regards,

Trevor

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




Re: core.async go - out of memory

2013-07-06 Thread David Nolen
This isn't a bug, you're in a infinite loop constructing go blocks. You
should probably move the loops into the go blocks.

David


On Sat, Jul 6, 2013 at 7:31 AM, MikeM michael.messini...@invista.comwrote:

 Got an out of memory when experimenting with core.async channels in go
 blocks. The following is a simple example.

 (defn go-loop
 []
 (let [c0 (chan)]
  (while true
   (go
 (! c0 1))
   (go
 (println (! c0))

 ;(.start (Thread. go-loop))

 Clojure 1.5.1, Java 1.7.0_25 32-bit running under Win7 x64.

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




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




Re: core.async go - out of memory

2013-07-06 Thread MikeM

On Saturday, July 6, 2013 11:46:51 AM UTC-4, David Nolen wrote: 

 This isn't a bug, you're in a infinite loop constructing go blocks. You 
 should probably move the loops into the go blocks. 

  I assumed go blocks are garbage collected when they go out of scope, but 
maybe I don't understand the scope of a go block. You're saying every go 
block created in the loop should be expected to hang around indefinitely? 
My (possibly broken) thinking was that after the first iteration, whatever 
is constructed by the go blocks in the first iteration would be candidates 
for garbage collection.
 
 

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




Re: core.logic - Using featurec to describe relationships around keys in a map

2013-07-06 Thread Norman Richards
On Fri, Jul 5, 2013 at 1:06 PM, David Rocamora dro...@gmail.com wrote:


 I'm trying to use featurec to describe some relationships within a nested
 map. When I try to use it to find some keys in the map it returns nothing.
 Here is an example:


I don't believe you can match on the keys in a map - only the values.


One solution I have come up with is to massage the map into a vector like
 this:

...
 I would do this if the data I was dealing with was just the colors of
 food, but what I am really trying to do is use core.logic to create
 programs that understand relationships in AWS 
 CloudFormationhttp://aws.amazon.com/cloudformation/ templates.
 A CFN template is a JSON file that is a bunch of nested maps that describe
 cloud computing infrastructure. I feel there are risks to massaging the
 templates and featurec feels right. What am I missing? Any guidance is
 appreciated.


We do a similar type of JSON matching with core.logic at threatgrid.  The
approach we take (which was developed before core.logic had featurec or any
 map unification capabilities) is walk the JSON (we use zippers to
search/extract) and make observations (
https://github.com/threatgrid/observations) about the data into a pldb
dataset (https://github.com/threatgrid/observations) that our core.logic
programs run against.

Some of the advantages in my mind are:

makes core logic code more robust to data changes (we can change the input
in
allows for simple data type transforms to structures core.logic can work
with better (getting a year from a date, or splitting a string)
allows for structural tranformations into more relational structures

This has worked really well for us, so something in this direction would
probably work for you too if you are going beyond what core.logic has to
offer out of the box.

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




Most idiomatic way of splitting a string into sentences?

2013-07-06 Thread Denis Papathanasiou
I have a plain text file containing an English-language essay that I'd like 
to split into sentences, based on the presence of punctuation.

I wrote this function to determine if a given character is an English 
punctuation mark:

(defn ispunc? [c]
  ( (count (filter #(= % c) '(. ! ? ;))) 0))

I know that this method is not grammatically perfect, in that acronyms such 
as U.S. will get mis-parsed, etc., but this is just an experiment and 
does not need that level of precision.

Then, I tried applying it with partition-by on a file I've slurped:

(def my-text (slurp mytext.txt))
(def my-sentences (partition-by ispunc? my-text))

Unfortunately, this returns a sequence of 1, whose first and only element 
contains the entire text, since ispunc? depends on looking at a single 
character.

So I tried producing a list of chars from the string and passing it to 
partition-by with ispunc? like this:

(def my-text-chars (partition (count my-text) my-text))
(def my-sentences (partition-by ispunc? (first my-text-chars)))

That worked, in that it's logically correct, but when I try to access any 
of the elements in my-sentences I get a java.lang.OutOfMemoryError (the 
source text file, mytext.txt is 1.3 mb in size).

So is there a simpler and more idiomatic way of doing this without using up 
all the heap space?

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




Most idiomatic way to split a string into sentences by punctuation?

2013-07-06 Thread Denis Papathanasiou
I have a plain text file containing an English-language essay I want to 
split into sentences, based on common punctuation.

I wrote this function, which examines a character and determines if it's an 
end of sentence punctuation mark:

(defn ispunc? [c]
  ( (count (filter #(= % c) '(. ! ? ;))) 0))

I know this is no grammatically perfect, and that some text such as U.S., 
etc. will be mis-parsed, but this is just an experiment and I don't need 
that level of precision.

So I loaded my file using slurp and tried using the partition-by function 
with ispunc? like this:

(def my-text (slurp mytext.txt))
(def my-sentences (partition-by ispunc? my-text))

Unfortunately, this returns a sequence of 1, where the only element is the 
entire string.

So I tried splitting the string into a list of characters, and applying 
partition-by with ispunc? like this:

(def my-text-chars (partition (count my-text) my-text))
(def my-sentences (partition-by ispunc? (nth my-text-chars 0)))

This worked, because it is logically correct, but I get 
a java.lang.OutOfMemoryError when I try to access any of the elements in 
my-sentences (the plain text mytext.txt file is 1.3 mb in size).

So is there a way to do this more idiomatically, without splitting into 
single chars and recombining?

While 1.3 mb is not small, it's also not so large that it can't be slurped, 
so there must be a simpler way of splitting on punctuation into sentences.

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




Re: Most idiomatic way of splitting a string into sentences?

2013-07-06 Thread Lars Nilsson
On Sat, Jul 6, 2013 at 11:42 AM, Denis Papathanasiou
denis.papathanas...@gmail.com wrote:
 (def my-text (slurp mytext.txt))
 (def my-sentences (partition-by ispunc? my-text))

 Unfortunately, this returns a sequence of 1, whose first and only element
 contains the entire text, since ispunc? depends on looking at a single
 character.

 So I tried producing a list of chars from the string and passing it to
 partition-by with ispunc? like this:

 (def my-text-chars (partition (count my-text) my-text))
 (def my-sentences (partition-by ispunc? (first my-text-chars)))

 That worked, in that it's logically correct, but when I try to access any
 of the elements in my-sentences I get a java.lang.OutOfMemoryError (the
 source text file, mytext.txt is 1.3 mb in size).

 So is there a simpler and more idiomatic way of doing this without using up
 all the heap space?

If that kind of splitting is really all you require,
(clojure.string/split my-text #[.!?;]) or (re-seq #[^.!?;]+
my-text)

For fancier stuff look into an opennlp wrapper or something like it.

https://github.com/dakrone/clojure-opennlp

Lars Nilsson

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




Re: Most idiomatic way to split a string into sentences by punctuation?

2013-07-06 Thread Jim - FooBar();
I use this regex usually it's been a while since I last used it so I 
odn't remember how it performs...


#(?=[.!?]|[.!?][\\'\])(?!e\.g\.|i\.e\.|vs\.|p\.m\.|a\.m\.|Mr\.|Mrs\.|Ms\.|St\.|Fig\.|fig\.|Jr\.|Dr\.|Prof\.|Sr\.|[A-Z]\.)\s+)

and as Lars said all you need is clojure.string/split

Jim


On 06/07/13 16:56, Denis Papathanasiou wrote:
I have a plain text file containing an English-language essay I want 
to split into sentences, based on common punctuation.


I wrote this function, which examines a character and determines if 
it's an end of sentence punctuation mark:


(defn ispunc? [c]
  ( (count (filter #(= % c) '(. ! ? ;))) 0))

I know this is no grammatically perfect, and that some text such as 
U.S., etc. will be mis-parsed, but this is just an experiment and I 
don't need that level of precision.


So I loaded my file using slurp and tried using the partition-by 
function with ispunc? like this:


(def my-text (slurp mytext.txt))
(def my-sentences (partition-by ispunc? my-text))

Unfortunately, this returns a sequence of 1, where the only element is 
the entire string.


So I tried splitting the string into a list of characters, and 
applying partition-by with ispunc? like this:


(def my-text-chars (partition (count my-text) my-text))
(def my-sentences (partition-by ispunc? (nth my-text-chars 0)))

This worked, because it is logically correct, but I get 
a java.lang.OutOfMemoryError when I try to access any of the elements 
in my-sentences (the plain text mytext.txt file is 1.3 mb in size).


So is there a way to do this more idiomatically, without splitting 
into single chars and recombining?


While 1.3 mb is not small, it's also not so large that it can't be 
slurped, so there must be a simpler way of splitting on punctuation 
into sentences.

--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient 
with your first post.

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google 
Groups Clojure group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com.

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




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

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




Re: Ring's session cookie-store

2013-07-06 Thread Thomas Heller
Hey,

cookie-store does not expect a string but a map like (cookie-store {:key 
your-key}) otherwise it will generate a random new key each restart, which 
you observed.

You can also set some options for the cookie itself, see :cookie-attrs 
(http://clojuredocs.org/ring/ring.middleware.session/wrap-session) which 
should fix your expiration issues.

HTH,
/thomas

On Saturday, July 6, 2013 1:20:57 PM UTC+2, Alexander Solovyov wrote:

 Hi all,

 I wrote a small site using compojure and friend and naturally I used 
 ring's own wrap-session to handle sessions. My code looks like this:

 (def app
   (- app-routes
   (friend/authenticate {:credential-fn (partial 
 creds/bcrypt-credential-fn
 db/get-user)
 :workflows [(workflows/interactive-form)]
 :login-uri /login/})
   (handler/site {:session {:store (cookie-store TRULY SECRET KEY)}})
   (permacookie ring-session)))

 And I discovered two problems with how session cookie was handled. First 
 one was that expiration was always set to session, while I want my users to 
 stay logged in for some longer period of time. I fixed that by writing my 
 own middleware (permacookie).

 Second one is that if I restart my app, cookie's store never decrypts the 
 cookie. I guess that's something to do with cryptography, since when I 
 encrypt same data in repl, I get different result from what I have in 
 cookie.

 Now I'm confused - why do have cookie store at all if memory storage will 
 provide exactly same persistency? Or am I doing something wrong? How do I 
 make cookie store decrypt and check cookies between server restarts?
  

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




Re: core.async

2013-07-06 Thread dennis zhuang
It's so cool,great job!
But i don't find any way to do io blocking operations such as socket.read
in 'go'.
Is there a roadmap to make alts! working with java NIO selector that waits
on socket channels?
Then we can read/write data with socket/file channel in go without blocking.
Thanks,it's really awesome!




2013/7/1 David Pollak dpollak...@gmail.com

 Thanks!


 On Mon, Jul 1, 2013 at 8:13 AM, Sean Corfield seancorfi...@gmail.comwrote:

 On Sun, Jun 30, 2013 at 4:42 PM, David Pollak dpollak...@gmail.com
 wrote:
  Looking forward to it
  being published (even as SNAPSHOT) in a Maven repo.

 It's accessible like this:

 (defproject async 0.1.0-SNAPSHOT
   :description FIXME: write description
   :url http://example.com/FIXME;
   :license {:name Eclipse Public License
 :url http://www.eclipse.org/legal/epl-v10.html}
   :repositories {sonatype-oss-public
 https://oss.sonatype.org/content/groups/public/}
   :dependencies [[org.clojure/clojure 1.5.1]
  [org.clojure/core.async 0.1.0-SNAPSHOT]])
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

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



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






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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




Re: core.async go - out of memory

2013-07-06 Thread Timothy Baldridge
Go blocks are GC'd but not until they complete running. The problem is that
you're creating go blocks faster than they can run. Creating go blocks is
very cheap, taking/putting into channels is also cheap but not quite as
cheap. Therefore the outer loop will eventually allocate so many blocks
that you're run OOM.

Timothy


On Sat, Jul 6, 2013 at 10:19 AM, MikeM michael.messini...@invista.comwrote:


 On Saturday, July 6, 2013 11:46:51 AM UTC-4, David Nolen wrote:

 This isn't a bug, you're in a infinite loop constructing go blocks. You
 should probably move the loops into the go blocks.

  I assumed go blocks are garbage collected when they go out of scope, but
 maybe I don't understand the scope of a go block. You're saying every go
 block created in the loop should be expected to hang around indefinitely?
 My (possibly broken) thinking was that after the first iteration, whatever
 is constructed by the go blocks in the first iteration would be candidates
 for garbage collection.



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






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

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




Re: Ring's session cookie-store

2013-07-06 Thread Alexander Solovyov
On Sat, Jul 6, 2013 at 10:07 PM, Thomas Heller th.hel...@gmail.com wrote:

 Hey,

 cookie-store does not expect a string but a map like (cookie-store {:key
 your-key}) otherwise it will generate a random new key each restart, which
 you observed.

 You can also set some options for the cookie itself, see :cookie-attrs (
 http://clojuredocs.org/ring/ring.middleware.session/wrap-session) which
 should fix your expiration issues.


Oh, thanks a lot, I've read this code so many times and still somehow
haven't noticed that I should supply option map instead of just key. Thank
you very much!

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




ANN Monger 1.6.0 is released

2013-07-06 Thread Michael Klishin
Monger (http://clojuremongodb.info) is a Clojure MongoDB client for a more
civilized
age.

1.6.0 is a minor release that that makes it easier to work with multiple
databases.

Release notes:
http://blog.clojurewerkz.org/blog/2013/07/06/monger-1-dot-6-0-is-released/
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

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




Re: core.async go - out of memory

2013-07-06 Thread Laurent PETIT
2013/7/6 MikeM michael.messini...@invista.com:
 Got an out of memory when experimenting with core.async channels in go
 blocks. The following is a simple example.

 (defn go-loop
 []
 (let [c0 (chan)]
  (while true
   (go
 (! c0 1))
   (go
 (println (! c0))

 ;(.start (Thread. go-loop))

 Clojure 1.5.1, Java 1.7.0_25 32-bit running under Win7 x64.


hello,

Maybe you wanted to do this in a serialized way: go blocks return a
channel which will give back the resulting value of the go block.

So maybe you could surround (go (println (! c0))) with a call to !! :

(!! (go (println (! c0

This way you won't have this crazy while true making you run out of memory.



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



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




core.logic - using membero to generate list?

2013-07-06 Thread Adam Saleh
Hi,

I wanted to use featurec to generate hash-map, 
similarily to a way I use membero when generating lists.

i.e 
=  (run 1 [q]
#=   (membero :a q))
((:a . _0))

Unfortunately when I try to do something \w it, it throws exception

= (first *1)
(1 . _0)
= (first *1)
IllegalArgumentException Don't know how to create ISeq from: 
clojure.core.logic.LCons  clojure.lang.RT.seqFrom (RT.java:505)

I guess I need to somehow convert the logic-based list to 
clojure-based, how do I do it?

Thanks!

Adam

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




ANN Validateur 1.5.0 is released

2013-07-06 Thread Michael Klishin
Validateur (http://clojurevalidations.info) is a data validation library
inspired by Ruby's ActiveModel.

1.5 is a minor release that introduces error message customization.

Release notes:
http://blog.clojurewerkz.org/blog/2013/07/06/validateur-1-dot-5-0-is-released/
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

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




Re: Most idiomatic way of splitting a string into sentences?

2013-07-06 Thread Denis Papathanasiou


On Saturday, July 6, 2013 1:22:32 PM UTC-4, Lars Nilsson wrote:

 [snip]
 If that kind of splitting is really all you require, 
 (clojure.string/split my-text #[.!?;]) or (re-seq #[^.!?;]+ 
 my-text) 


Thanks! 

Is there any way to preserve the actual punctuation? That's why I was 
looking at partition-by and group-by instead. 
 


 For fancier stuff look into an opennlp wrapper or something like it. 

 https://github.com/dakrone/clojure-opennlp 


This might be a better solution; thanks for mentioning it.
 


 Lars Nilsson 


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




Re: Most idiomatic way to split a string into sentences by punctuation?

2013-07-06 Thread Denis Papathanasiou


On Saturday, July 6, 2013 1:54:49 PM UTC-4, Jim foo.bar wrote:

  I use this regex usually it's been a while since I last used it so I 
 odn't remember how it performs...

 #
 (?=[.!?]|[.!?][\\'\])(?!e\.g\.|i\.e\.|vs\.|p\.m\.|a\.m\.|Mr\.|Mrs\.|Ms\.|St\.|Fig\.|fig\.|Jr\.|Dr\.|Prof\.|Sr\.|[A-Z]\.)\s+
 )

 and as Lars said all you need is clojure.string/split


Thanks, though as I replied to Lars, I did want to preserve the actual 
terminating punctuation, whatever it was, so that why I'd looked into using 
partition-by.

Also, sorry for the double post (I didn't realize this group was moderated, 
so when I didn't see the first post appear, I re-submitted it a little 
while later). 

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




Re: core.logic - using membero to generate list?

2013-07-06 Thread Norman Richards
On Sat, Jul 6, 2013 at 3:16 PM, Adam Saleh adamthecam...@gmail.com wrote:


 =  (run 1 [q]
 #=   (membero :a q))
 ((:a . _0))

 Unfortunately when I try to do something \w it, it throws exception

 = (first *1)
 (1 . _0)
 = (first *1)
 IllegalArgumentException Don't know how to create ISeq from:
 clojure.core.logic.LCons  clojure.lang.RT.seqFrom (RT.java:505)

 I guess I need to somehow convert the logic-based list to
 clojure-based, how do I do it?


A cons cell doesn't really convert to a clojure list, especially when the
last item is fresh.  I guess the real question is: what result do you want
from Clojure?

If you just want to access the values you have now, you can get them with
lfirst/lnext (in clojure.core.logic.protocols) but maybe the better
question to ask is: what clojure result do you actually want?

If you want all the possible proper lists, then I'd suggest constraining it
to be such:

(defn listo [l]
  (conde [(emptyo l)]
 [(fresh [a d]
 (conso a d l)
 (listo d))]))


In my experience, calling core.logic from real application code works best
when you write programs that produce fully realized results without any
fresh values

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




Re: core.logic - Using featurec to describe relationships around keys in a map

2013-07-06 Thread David Nolen
On Sat, Jul 6, 2013 at 12:27 PM, Norman Richards o...@nostacktrace.comwrote:


 On Fri, Jul 5, 2013 at 1:06 PM, David Rocamora dro...@gmail.com wrote:


 I'm trying to use featurec to describe some relationships within a nested
 map. When I try to use it to find some keys in the map it returns nothing.
 Here is an example:


 I don't believe you can match on the keys in a map - only the values.


This is correct. Supporting fresh keys is *very* hard :)

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




Re: Ring's session cookie-store

2013-07-06 Thread James Reeves
On 6 July 2013 20:07, Thomas Heller th.hel...@gmail.com wrote:

 You can also set some options for the cookie itself, see :cookie-attrs (
 http://clojuredocs.org/ring/ring.middleware.session/wrap-session) which
 should fix your expiration issues.


In this case it doesn't matter much, but note that the Ring docs on
clojuredocs.org are years out of date, and do not apply to any stable
version.

- James

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




Re: Most idiomatic way of splitting a string into sentences?

2013-07-06 Thread Lars Nilsson
On Sat, Jul 6, 2013 at 5:02 PM, Denis Papathanasiou
denis.papathanas...@gmail.com wrote:
 On Saturday, July 6, 2013 1:22:32 PM UTC-4, Lars Nilsson wrote:

 [snip]

 If that kind of splitting is really all you require,
 (clojure.string/split my-text #[.!?;]) or (re-seq #[^.!?;]+
 my-text)
 Is there any way to preserve the actual punctuation? That's why I was
 looking at partition-by and group-by instead.

You could try (re-seq #[^.!?;]+[.!?;]? my-text) or perhaps Jim's
longer regex is better suited (I didn't look at it in-depth, but it is
longer... :) )

 For fancier stuff look into an opennlp wrapper or something like it.

 https://github.com/dakrone/clojure-opennlp


 This might be a better solution; thanks for mentioning it.

It is certainly what I would use, if I was looking for decent text
parsing and I was interested more in the use of the output than the
implementation of tokenization, etc.

Lars Nilsson

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




Re: core.async go - out of memory

2013-07-06 Thread MikeM

On Saturday, July 6, 2013 4:01:31 PM UTC-4, tbc++ wrote: 

 Go blocks are GC'd but not until they complete running. The problem is 
 that you're creating go blocks faster than they can run. Creating go blocks 
 is very cheap, taking/putting into channels is also cheap but not quite as 
 cheap. Therefore the outer loop will eventually allocate so many blocks 
 that you're run OOM.

 Timothy
  

Looking at the oom heap dump, the ManyToManyChannel instances have deeply 
nested graphs via LinkedBlockingQueue$Node instances. Seems that the 
problem is not just rapid allocations.

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




Re: core.async

2013-07-06 Thread Cedric Greevey
The obvious approach is to use a future or other thread as an intermediary
between the blocking I/O read and a channel, then use ! on the channel in
a go; something like:

(go
  (let [c (chan)]
(future (!! c (my-blocking-io-read some-stream)))
(let [thingy (! c)
  (do-something-with thingy

The channel can then be used in alts! and what-not as well, if you want to
react to any of several possible next things, only one of which is the
I/O read completing and returning a value.

This *does* suggest making a small async.io library that provides a
nonblocking read operation that returns a channel, and maybe other related
facilities, such as a line-chan that pops line after line from the input
I/O source when read from, byte-chan (for binary files), edn-chan (top
level edn forms read from input), etc.



On Sat, Jul 6, 2013 at 3:23 PM, dennis zhuang killme2...@gmail.com wrote:

 It's so cool,great job!
 But i don't find any way to do io blocking operations such as socket.read
 in 'go'.
 Is there a roadmap to make alts! working with java NIO selector that waits
 on socket channels?
 Then we can read/write data with socket/file channel in go without
 blocking.
 Thanks,it's really awesome!




 2013/7/1 David Pollak dpollak...@gmail.com

 Thanks!


 On Mon, Jul 1, 2013 at 8:13 AM, Sean Corfield seancorfi...@gmail.comwrote:

 On Sun, Jun 30, 2013 at 4:42 PM, David Pollak dpollak...@gmail.com
 wrote:
  Looking forward to it
  being published (even as SNAPSHOT) in a Maven repo.

 It's accessible like this:

 (defproject async 0.1.0-SNAPSHOT
   :description FIXME: write description
   :url http://example.com/FIXME;
   :license {:name Eclipse Public License
 :url http://www.eclipse.org/legal/epl-v10.html}
   :repositories {sonatype-oss-public
 https://oss.sonatype.org/content/groups/public/}
   :dependencies [[org.clojure/clojure 1.5.1]
  [org.clojure/core.async 0.1.0-SNAPSHOT]])
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

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



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






 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008


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




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

Re: Clojure Group

2013-07-06 Thread Cedric Greevey
I have doubts about the assertion that it can make software engineering
... repeatable, on firm theoretical ground and additionally backed by
experience. Programming is not a kind of manufacturing; the manufacturing
is done by way if right-drag copy files here, uploading to Github and
Sourceforge, stamping out plastic discs, and the like.

Programming is a variety of RD, and RD is inherently nonrepeatable,
unless you're pointlessly (or as a training exercise) reinventing the wheel.



On Sat, Jul 6, 2013 at 3:07 AM, Marcus Lindner 
marcus.goldritter.lind...@gmail.com wrote:


 If it uses clojure or is for clojure and with more information about the
 product I think there speak nothing agianst it, if you post it.

 It is not so good to register before you can get any information about the
 product, so more infos are needed.


 VG
 Marcus

 Am 05.07.2013 19:37, schrieb Michael Sadler:


  Hello,

  I came across the Clojure group via a blog and didn't want to spam it
 and decided to contact you directly.

  I'm wondering if this can be posted to the group:

  #Metricata makes the software engineering process measurable and
 repeatable.
 ses.newventurewebsites.com

  Looking forward,

  Michael Sadler, B. Comm., Web Developer
 http://www.newventurewebsites.com/
 @NewVentureFunds

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




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




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




Re: New CSS library - Garden

2013-07-06 Thread Joel Holdbrooks
Hi Steven,

I know that readability is a bit of an issue for some people. Unfortunately 
there isn't much I can do other than point folks to the defrule macro and some 
of the other suggestions I've made. As I work with the Garden I see problem 
areas too and am working to find solutions that will make using the library 
more palatable.

Speaking of defrule, and correct me if I'm missing something, but I think you 
might be a bit confused about it's nature. You should think of defrule as a way 
to create selector functions. I'll admit this was bad naming on my part and 
I'll probably make an alias called defselector. Those selectors  can be as 
generic or precise as you like and possess the same semantics as normal vector 
based Garden code but are more flexible (since they are functions). Also, they 
should give you the indentation you are looking for.

(defrule a :a)
(defrule footer :footer)

(footer {:color red
 :background-color blue}
(a {:color green}))

But if I have 3 elements with 3 children each, and each child has 3 children, 
that's already 27 defrules I have to stick above it. That'll get pretty unruly 
quick.

Only if you have 27 distinct elements that you have no intention of ever 
reusing. Observe:

;; These forms are all semantically equivalent.

(footer {:color red
 :background-color blue}
(a {:color green}))

[:footer {:color red
  :background-color blue}
 (a {:color green})]

(footer {:color red
 :background-color blue}
[:a {:color green}])

;; This works too.  

(defrule h1 :h1)
(defrule hover :hover)

(footer
 (h1 {:font-weight normal}
 (hover {:font-weight bold}))
 (a {:text-decoration none}
(hover {:text-decoration underline})))


To make life easier I will add all known HTML selectors (via defrule) and make 
some tweaks to it's behavior today. As of this moment most of the pseudo 
classes have been implemented here.

I hope this helps clear things up. Again, if I'm not understanding you 
correctly, please let me know.

Thanks,

Joel

On Jul 6, 2013, at 6:58 AM, Steven Degutis sbdegu...@gmail.com wrote:

 So far, I really like Garden.
 
 There's one thing though that's making it difficult. It's hard to see that 
 nested rules are nested.
 ;; hard to see nesting
 [:footer {:color red
   :background-color blue}
  [:a {:color green}]]
 
 ;; much easier
 (:footer {:color red
   :background-color blue}
  [:a {:color green}])
 (That's a bad example because it's so short. In the real world, much longer 
 and deeper-nested rules show it clearer.)
 
 Technically I'm using emacs with clojure-mode.el, which indents vectors by 
 only 1 char. But I don't think that's the problem. Normally it's good to 
 indent them by only 1 char, but there's no way to differentiate between 
 [:some [:random :data]], which should be indented like that, and a vector of 
 garden-rules which should be indented more obviously. So I don't think this 
 is something that changing our editors/plugins will fix.
 
 One solution is to use defrule more often. But if I have 3 elements with 3 
 children each, and each child has 3 children, that's already 27 defrules I 
 have to stick above it. That'll get pretty unruly quick.
 
 So I was thinking of just using a dummy macro like this:
 (defmacro rule [ body] `[~@body])
 
 (def footer
   (rule :footer {:color red
  :background-color blue}
 (rule :a {:color green})))
 But you can imagine my discomfort at writing/using a macro just to make 
 indentation easier.
 
 Are there any better solutions to this?
 
 -Steven
 
 
 On Tue, Apr 9, 2013 at 2:58 PM, Joel Holdbrooks cjholdbro...@gmail.com 
 wrote:
 Nobel Clojurians,
 
 I am pleased to announce the alpha version of Garden, a new library for 
 writing CSS in Clojure.
 
 The project weds the best ideas from Hiccup, gaka, and cssgen and aims to 
 provide a clean and conventional way to author stylesheets without being too 
 simple or too complex.
 
 Currently the list of notable features include:
 Nestable rules
 Nestable declarations (this my change)
 A builtin set of tools for working with CSS unit values
 Convenient multiple selector syntax (IE. h1, h2, h3 { ... })
 Output formatting options
 What's planned for the near future:
 The ability to use Clojure meta as a media query
 A builtin set of tools for working with CSS color values
  selector syntax for nested rules 
 For those of you who are interested in this sort of thing, please have a look 
 at the project's repository. There is still quite a bit of ground to do cover 
 and any help/criticism/contribution would be greatly appreciated.
 
 Please feel free to offer suggestions, ask questions, open issues, or send 
 pull requests. I would love nothing more than to see this library succeed 
 where other's have not. 
 
 
 Truly,
 
 Joel Holdbrooks (aka noprompt)
 
 
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 

Jenkins/leiningen trigger build when a snapshot gets updated

2013-07-06 Thread Ryan Stradling
I am not aware of one that does that.  I end up using a pom style project.  As 
a prebuild step I generate the pom using lein.  Then my maven step does a lein 
validate (basically a dummy step) and then do post build steps that do the lein 
commands like lein test.  It is not a perfect solution but so far works well 
enough.

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




Re: New CSS library - Garden

2013-07-06 Thread Steven Degutis
Right, I understand how defrule works. But I actually do have 27 [i.e.
O(n)] distinct rules, so it's not a feasible solution.

Because when I write CSS, I only style domain-specific class names (.cart,
.license), never mentioning the elements they just so happen to use at the
moment (h1, p, a). This lets me change the implementation quickly and
easily. And it makes it easier to write for other devices/sizes.

So really I only use defrule for the pseudo-selectors you just linked to
(hover, active, nth-child). Besides that I really have no use for it.

And abstracting really feels like it shouldn't be used to solve the problem
of indentation. Besides, like Dan Neumann mentioned in that Github Issue,
abstracting anything in my stylesheet too early can lead to wrong
abstractions that are difficult to revert. So right now I define an entire
section (header, footer, cart) as one big nested vector, nothing extracted.
Sure, I'll probably clean it up later, but only after I have more pages and
can see more patterns emerging clearly.

Although, I have abstracted one thing which I hope will turn out useful:

(def clearfix
  [:
   [::after {:clear both}]
   [::before
::after {:display table :content ''}]])

Then you can embed it as a rule anywhere that you need to clear some floats:

[:.some-container-with-floats clearfix]

But as for indentation, so far I'm liking the rule macro more and more. I
admit it's weird that it just vector-izes its arguments, and does nothing
else. But the fact that it's a function call fixes the indentation problem
wonderfully.

I think it should be part of the garden lib, really. Although lately I've
renamed it to % so my eyes aren't drawn to the wrong thing when I'm
skimming my rules. It was ! for a while but that was weirder thanks to it
being right after a long skinny parenthese. But either way, these all make
nested rules much easier to visually scan.

Anyway I really love using Garden. Thanks for writing it!

I've been experimenting with some ways of integrating it with compojure for
some Rails4-like asset-pipelining (whatever that means), and it works
really well but the API is still a little raw. But if I come up with
anything good I'll try to share it.

-Steven


On Sat, Jul 6, 2013 at 8:52 PM, Joel Holdbrooks cjholdbro...@gmail.comwrote:

 Hi Steven,

 I know that readability is a bit of an issue for some people.
 Unfortunately there isn't much I can do other than point folks to the *
 defrule* macro and some of the other suggestions I've made. As I work
 with the Garden I see problem areas too and am working to find solutions
 that will make using the library more palatable.

 Speaking of *defrule*, and correct me if I'm missing something, but I
 think you might be a bit confused about it's nature. You should think of *
 defrule* as a way to create selector *functions*. I'll admit this was bad
 naming on my part and I'll probably make an alias called *defselector*.
 Those selectors  can be as generic or precise as you like and possess the
 same semantics as normal vector based Garden code but are more flexible
 (since they are functions). Also, they should give you the indentation you
 are looking for.

 (defrule a :a)(defrule footer :footer)
 (footer {:color red
  :background-color blue}
 (a {:color green}))


 *But if I have 3 elements with 3 children each, and each child has 3
 children, that's already 27 defrules I have to stick above it. That'll get
 pretty unruly quick.*

 Only if you have 27 *distinct* elements that you have no intention of
 ever reusing. Observe:

 ;; These forms are all semantically equivalent.
 (footer {:color red
  :background-color blue}
 (a {:color green}))

 [:footer {:color red
   :background-color blue}

  (a {:color green})]

 (footer {:color red
  :background-color blue}
 [:a {:color green}])
 ;; This works too.
 (defrule h1 :h1)(defrule hover :hover)
 (footer
  (h1 {:font-weight normal}
  (hover {:font-weight bold}))
  (a {:text-decoration none}
 (hover {:text-decoration underline})))



 To make life easier I will add all known HTML selectors (via *defrule*)
 and make some tweaks to it's behavior today. As of this moment most of the
 pseudo classes have been implemented 
 *here*https://github.com/noprompt/garden/blob/master/src/garden/stylesheet/pseudo_classes.clj
 .

 I hope this helps clear things up. Again, if I'm not understanding you
 correctly, please let me know.

 Thanks,

 Joel

 On Jul 6, 2013, at 6:58 AM, Steven Degutis sbdegu...@gmail.com wrote:

 So far, I really like Garden.

 There's one thing though that's making it difficult. It's hard to see that
 nested rules are nested.

 ;; hard to see nesting[:footer {:color red
   :background-color blue}
  [:a {:color green}]]
 ;; much easier(:footer {:color red
   :background-color blue}
  [:a {:color green}])

 (That's a bad example because it's so short. In the real world, much
 longer and 

Re: New CSS library - Garden

2013-07-06 Thread Joel Holdbrooks
Cool. I'm glad you like the library. Thanks for sharing your kind words and 
thoughts. :)

I admit it's weird that it just vector-izes its arguments, and does nothing 
else.

In that case I don't think you need a macro, just alias rule to vector and 
you'll achieve the same end.

I think it should be part of the garden lib...

I don't think there would be any harm in adding this as an alias;  I tend to do 
a similar thing aliasing styles to list. 

And abstracting really feels like it shouldn't be used to solve the problem of 
indentation.

That's definitely not the only reason why defrule was added but it could be 
used to address that problem which is why I brought it up. The beautiful thing 
about programming stylesheets in Clojure is that we can come up with whatever 
abstractions/techniques we like without being tied down by syntax. There's a 
lot of potential there for some interesting ideas.

I've been experimenting with some ways of integrating it with compojure for 
some Rails4-like asset-pipelining...

Some people are definitely looking for this. If you come up with something, 
even a simple gist, please share it. I'm still loading/compiling stylesheets 
manually. :P

Oh, I don't know if you saw this gist but there's also some interest in ideas 
surrounding grid systems.

Thanks,

Joel

On Jul 6, 2013, at 7:41 PM, Steven Degutis sbdegu...@gmail.com wrote:

 Right, I understand how defrule works. But I actually do have 27 [i.e. O(n)] 
 distinct rules, so it's not a feasible solution.
 
 Because when I write CSS, I only style domain-specific class names (.cart, 
 .license), never mentioning the elements they just so happen to use at the 
 moment (h1, p, a). This lets me change the implementation quickly and easily. 
 And it makes it easier to write for other devices/sizes.
 
 So really I only use defrule for the pseudo-selectors you just linked to 
 (hover, active, nth-child). Besides that I really have no use for it.
 
 And abstracting really feels like it shouldn't be used to solve the problem 
 of indentation. Besides, like Dan Neumann mentioned in that Github Issue, 
 abstracting anything in my stylesheet too early can lead to wrong 
 abstractions that are difficult to revert. So right now I define an entire 
 section (header, footer, cart) as one big nested vector, nothing extracted. 
 Sure, I'll probably clean it up later, but only after I have more pages and 
 can see more patterns emerging clearly.
 
 Although, I have abstracted one thing which I hope will turn out useful:
 (def clearfix
   [:
[::after {:clear both}]
[::before
 ::after {:display table :content ''}]])
 Then you can embed it as a rule anywhere that you need to clear some floats:
 [:.some-container-with-floats clearfix]
 But as for indentation, so far I'm liking the rule macro more and more. I 
 admit it's weird that it just vector-izes its arguments, and does nothing 
 else. But the fact that it's a function call fixes the indentation problem 
 wonderfully.
 
 I think it should be part of the garden lib, really. Although lately I've 
 renamed it to % so my eyes aren't drawn to the wrong thing when I'm 
 skimming my rules. It was ! for a while but that was weirder thanks to it 
 being right after a long skinny parenthese. But either way, these all make 
 nested rules much easier to visually scan.
 
 Anyway I really love using Garden. Thanks for writing it!
 
 I've been experimenting with some ways of integrating it with compojure for 
 some Rails4-like asset-pipelining (whatever that means), and it works 
 really well but the API is still a little raw. But if I come up with anything 
 good I'll try to share it.
 
 -Steven
 
 
 On Sat, Jul 6, 2013 at 8:52 PM, Joel Holdbrooks cjholdbro...@gmail.com 
 wrote:
 Hi Steven,
 
 I know that readability is a bit of an issue for some people. Unfortunately 
 there isn't much I can do other than point folks to the defrule macro and 
 some of the other suggestions I've made. As I work with the Garden I see 
 problem areas too and am working to find solutions that will make using the 
 library more palatable.
 
 Speaking of defrule, and correct me if I'm missing something, but I think you 
 might be a bit confused about it's nature. You should think of defrule as a 
 way to create selector functions. I'll admit this was bad naming on my part 
 and I'll probably make an alias called defselector. Those selectors  can be 
 as generic or precise as you like and possess the same semantics as normal 
 vector based Garden code but are more flexible (since they are functions). 
 Also, they should give you the indentation you are looking for.
 
 (defrule a :a)
 (defrule footer :footer)
 
 (footer {:color red
  :background-color blue}
 (a {:color green}))
 
 But if I have 3 elements with 3 children each, and each child has 3 
 children, that's already 27 defrules I have to stick above it. That'll get 
 pretty unruly quick.
 
 Only if you have 27 distinct elements that you