Re: [Bug?] Spec: spec/? not working?

2016-07-21 Thread Torsten Anders
Thanks a lot for testing that. I am also using the same 1.9.0 Alpha 10, 
should have said so. 

I found the error, which was in my code.

Best,
Torsten


On Thursday, 21 July 2016 01:25:51 UTC+1, Sean Corfield wrote:
>
> Your code works for me as expected on 1.9.0 Alpha 10. What version are you 
> using?
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> On 7/20/16, 2:59 PM, "Torsten Anders"   on behalf of torste...@gmx.de > wrote:
>
>  
>
> Dear all,
>
> I have some problems using clojure.spec: ? does not work as I would expect 
> it. Instead of specifying an optional value, it seems that such values are 
> never permitted, and instead the next value is always matched. Please see 
> the short example demonstration below. BTW, * seems to cause the same 
> problem. 
>
> What am I missing?
>
>
> (ns test-ns
>   (:require [clojure.spec :as spec]))
>
> (spec/def ::test-spec (spec/cat :symbol symbol?
> :optional-string (spec/? string?)
> :int int?))
> (spec/valid? ::test-spec '[test 42]) ; -> true
> (spec/valid? ::test-spec '[test "my string" 42]) ; -> false
>
> (spec/explain ::test-spec '[test "my string" 42])
> ;; In: [1] val: "my string" fails spec: :clojure2minizinc.core/test-spec 
> at: [:int] predicate: int?
>
>
> Best,
> Torsten
>
>  
>
>

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


Re: Amazonica and S3

2016-07-21 Thread Gareth Rogers
Thanks that's helpful. I must have been too frustrated by the end of the 
day and didn't Google that one!

Reading the trace output for the tag setting I believe the original code I 
wrote is producing an empty TagSet which is what the API considers 
malformed. Looks like a  element is required: 
http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTtagging.html.

That makes me feel that the my problem is that I can't create a tag set 
correctly through Amazonica. For now I need this to work so I'll switch to 
doing the Java interop which the SO article is very helpful, thanks :)

set-bucket-notification-configuration is still a mystery but I haven't 
tried trace with that yet.

I'm going to try set-bucket-lifecycle-configuration which has an example in 
tests and I'd like to set a policy to delete failed part file uploads. It's 
use is similar to the notification configuration.

On Thursday, 21 July 2016 00:44:11 UTC+1, Andrea Richiardi wrote:
>
> Maybe not related, but I was checking that api and this showed up, maybe 
> it can be helpful?
>
>
> https://stackoverflow.com/questions/30521046/malformedxml-when-tagging-an-s3-bucket
>
> On Wednesday, July 20, 2016 at 7:56:10 AM UTC-7, Gareth Rogers wrote:
>>
>> After chatting with a colleague who read this and showed me the magic of 
>> trace I think the problem with amazonica.aws.
>> s3/set-bucket-tagging-configuration is that I need
>>
>> {:tag-sets [{:tag {"Formation" "notlive"}}]}
>>
>> i.e. I need to know how to call setTag(string key, string value) which 
>> takes two args through the Amazonica. I've only dealt with single args 
>> before.
>>
>> On Wednesday, 20 July 2016 14:53:11 UTC+1, Gareth Rogers wrote:
>>>
>>> Hi
>>>
>>> Has any one had any success using either 
>>> amazonica.aws.s3/set-bucket-notification-configuration or 
>>> amazonica.aws.s3/set-bucket-tagging-configuration?
>>>
>>> I've got
>>>
>>> (amazonica.aws.s3/set-bucket-notification-configuration
>>> "my.bucket.name"
>>> {"my-custom-event-name"
>>> {"" ;; This replaced with the ARN of an SQS queue I've 
>>> created
>>>  "ObjectCreatedByPut" ;; [S3Event/ObjectCreatedByPut] ;; 
>>> "s3:ObjectCreated:Put" <-- tried all three
>>>  ;; :filter"/_SUCCESS"
>>>  }})
>>>
>>> and
>>>
>>> (amazonica.aws.s3/set-bucket-tagging-configuration
>>>  "my.bucket.name"
>>>  {:tag-sets [{"Formation" "notlive"}]})
>>>
>>> Both of those are wrapped with amazonica.core/with-credential which 
>>> I've omitted.
>>>
>>> The call to amazonica.aws.s3/set-bucket-notification-configuration returns 
>>> nil. I guess this means it's getting converted to a valid call but the S3 
>>> API is rejecting it silently? Anyone know what it should look like?
>>>
>>> The call to amazonica.aws.s3/set-bucket-tagging-configuration is 
>>> throwing:
>>>
>>> Unhandled com.amazonaws.services.s3.model.AmazonS3Exception
>>>The XML you provided was not well-formed or did not validate
>>>against our published schema (Service: Amazon S3; Status Code: 400;
>>>Error Code: MalformedXML; Request ID: )
>>>
>>> I can't figure out what might be wrong there either. I've tried a few 
>>> variations on the tag sets but it either doesn't run because it can't find 
>>> an appropriate function or gives the XML error.
>>>
>>> Any pointers would be appreciated.
>>>
>>> Thanks
>>> Gareth
>>>
>>

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


Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Steve Miner
With a little help from Java, you can make equivalent open intervals for the 
desired bounds.  For example,

  (s/and (s/double-in :min 0.0 :max 1.0) #(not= 0.0 %))

should be the same as

  (s/double-in :min Double/MIN_VALUE :max 1.0)

Also, you can use java.lang.Math/nextUp and nextAfter to get adjacent doubles 
for your bounds.

(java.lang.Math/nextUp 1.1)
;=> 1.1003

(java.lang.Math/nextAfter 1.1 Double/NEGATIVE_INFINITY)
;=> 1.0999

There are a few tricky situations around the zeroes and infinities so you 
should read the doc on nextAfter, especially if you’re dealing with extreme 
doubles.

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


Re: Amazonica and S3

2016-07-21 Thread Gareth Rogers
I've created this issue https://github.com/mcohen01/amazonica/issues/230 
for the set-bucket-notification-configuration as I believe there is a 
problem with the use of that function.

Having looked at the trace out from set-bucket-notification-configuration I'm 
convinced I can get set-bucket-tagging-configuration to work with the right 
structure as it looks like it's doing the right thing when it needs to pass 
multiple args to a function. Can't get the data structures correct though.

On Thursday, 21 July 2016 10:30:50 UTC+1, Gareth Rogers wrote:
>
> Thanks that's helpful. I must have been too frustrated by the end of the 
> day and didn't Google that one!
>
> Reading the trace output for the tag setting I believe the original code I 
> wrote is producing an empty TagSet which is what the API considers 
> malformed. Looks like a  element is required: 
> http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTtagging.html.
>
> That makes me feel that the my problem is that I can't create a tag set 
> correctly through Amazonica. For now I need this to work so I'll switch to 
> doing the Java interop which the SO article is very helpful, thanks :)
>
> set-bucket-notification-configuration is still a mystery but I haven't 
> tried trace with that yet.
>
> I'm going to try set-bucket-lifecycle-configuration which has an example 
> in tests and I'd like to set a policy to delete failed part file uploads. 
> It's use is similar to the notification configuration.
>
> On Thursday, 21 July 2016 00:44:11 UTC+1, Andrea Richiardi wrote:
>>
>> Maybe not related, but I was checking that api and this showed up, maybe 
>> it can be helpful?
>>
>>
>> https://stackoverflow.com/questions/30521046/malformedxml-when-tagging-an-s3-bucket
>>
>> On Wednesday, July 20, 2016 at 7:56:10 AM UTC-7, Gareth Rogers wrote:
>>>
>>> After chatting with a colleague who read this and showed me the magic of 
>>> trace I think the problem with amazonica.aws.
>>> s3/set-bucket-tagging-configuration is that I need
>>>
>>> {:tag-sets [{:tag {"Formation" "notlive"}}]}
>>>
>>> i.e. I need to know how to call setTag(string key, string value) which 
>>> takes two args through the Amazonica. I've only dealt with single args 
>>> before.
>>>
>>> On Wednesday, 20 July 2016 14:53:11 UTC+1, Gareth Rogers wrote:

 Hi

 Has any one had any success using either 
 amazonica.aws.s3/set-bucket-notification-configuration or 
 amazonica.aws.s3/set-bucket-tagging-configuration?

 I've got

 (amazonica.aws.s3/set-bucket-notification-configuration
 "my.bucket.name"
 {"my-custom-event-name"
 {"" ;; This replaced with the ARN of an SQS queue I've 
 created
  "ObjectCreatedByPut" ;; [S3Event/ObjectCreatedByPut] ;; 
 "s3:ObjectCreated:Put" <-- tried all three
  ;; :filter"/_SUCCESS"
  }})

 and

 (amazonica.aws.s3/set-bucket-tagging-configuration
  "my.bucket.name"
  {:tag-sets [{"Formation" "notlive"}]})

 Both of those are wrapped with amazonica.core/with-credential which 
 I've omitted.

 The call to amazonica.aws.s3/set-bucket-notification-configuration returns 
 nil. I guess this means it's getting converted to a valid call but the S3 
 API is rejecting it silently? Anyone know what it should look like?

 The call to amazonica.aws.s3/set-bucket-tagging-configuration is 
 throwing:

 Unhandled com.amazonaws.services.s3.model.AmazonS3Exception
The XML you provided was not well-formed or did not validate
against our published schema (Service: Amazon S3; Status Code: 400;
Error Code: MalformedXML; Request ID: )

 I can't figure out what might be wrong there either. I've tried a few 
 variations on the tag sets but it either doesn't run because it can't find 
 an appropriate function or gives the XML error.

 Any pointers would be appreciated.

 Thanks
 Gareth

>>>

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


Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Alex Miller
You can already get open intervals by just omitting :min or :max.

On Thursday, July 21, 2016 at 8:50:21 AM UTC-5, miner wrote:
>
> With a little help from Java, you can make equivalent open intervals for 
> the desired bounds.  For example, 
>
>   (s/and (s/double-in :min 0.0 :max 1.0) #(not= 0.0 %)) 
>
> should be the same as 
>
>   (s/double-in :min Double/MIN_VALUE :max 1.0) 
>
> Also, you can use java.lang.Math/nextUp and nextAfter to get adjacent 
> doubles for your bounds. 
>
> (java.lang.Math/nextUp 1.1) 
> ;=> 1.1003 
>
> (java.lang.Math/nextAfter 1.1 Double/NEGATIVE_INFINITY) 
> ;=> 1.0999 
>
> There are a few tricky situations around the zeroes and infinities so you 
> should read the doc on nextAfter, especially if you’re dealing with extreme 
> doubles. 
>
>

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


Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Mars0i
On Thursday, July 21, 2016 at 9:51:02 AM UTC-5, Alex Miller wrote:
>
> You can already get open intervals by just omitting :min or :max.
>

I think my terminology may have created some confusion; I probably 
shouldn't have used open/closed.  I meant "open interval" in the sense that 
an open interval is one 
that doesn't include the endpoints.  e.g. all real numbers x such that x > 
0 and x < 1 are the open interval (0, 1).  A half-open interval is one that 
includes one of the endpoints, but not the other one.   

(s/double-in :infinite? false) sort of specifies an open interval in my 
sense, except that there are hard boundaries on what can be represented as 
a double, so I suppose it's really a closed interval.  I don't know.  
That's getting too pedantic even for me. :-)

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


Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Steve Miner
> (s/and (s/double-in :min 0.0 :max 1.0) #(not= 0.0 %)) 
> 
> should be the same as 
> 
>   (s/double-in :min Double/MIN_VALUE :max 1.0) 

I should have mentioned that Double/MIN_VALUE is the smallest positive double 
(just greater than 0.0), not a large negative value.  It’s easy to get confused 
by the fact that Long/MIN_VALUE is extremely negative.

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


Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Mars0i
On Thursday, July 21, 2016 at 8:50:21 AM UTC-5, miner wrote:
>
> With a little help from Java, you can make equivalent open intervals for 
> the desired bounds.  For example, 
>
> Also, you can use java.lang.Math/nextUp and nextAfter to get adjacent 
> doubles for your bounds. 
>
> (java.lang.Math/nextUp 1.1) 
> ;=> 1.1003 
>
> (java.lang.Math/nextAfter 1.1 Double/NEGATIVE_INFINITY) 
> ;=> 1.0999 
>
> There are a few tricky situations around the zeroes and infinities so you 
> should read the doc on nextAfter, especially if you’re dealing with extreme 
> doubles. 
>

Cool--very nice to know.  Thanks.  I may use it.

Ideally, I'd rather not have to descend to that level for a spec, because 
the meaning becomes less clear, and I'd rather let built-in language 
constructs hide differences between Clojure and Clojurescript whenever 
possible.  Testing for being > 0.0 and < 1.1 won't involve a meaningful 
difference in different clojure variants, for most purposes.

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


meaning of spec/and ?

2016-07-21 Thread Mars0i
With Clojure 1.9.0-alpha10:








*user=> (s/def ::interval-with-cloj-and #(and   (> % 0.0) (< % 1.0)))user=> 
(s/def ::interval-with-spec-and #(s/and (> % 0.0) (< % 1.0)))user=> 
(s/valid? ::interval-with-cloj-and 1.0)false*That's what I expected.


*user=> (s/valid? ::interval-with-spec-and 1.0)true*

That's not what I expected.

In fact, as far as I can tell, (valid? ::interval-with-spec-and x) will 
return true for any number x.  What does spec/and mean, then?  I thought 
that in this context it would mean the same as Clojure's normal 'and'.  
That's what the first example of its use in the Clojure.spec Guide seems to 
show.  I must be misunderstanding something basic and perhaps obvious.

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


Re: [Review] Slow server, not maxing out CPU

2016-07-21 Thread Вук Мировић


On Thursday, July 21, 2016 at 6:15:46 AM UTC+2, James Reeves wrote:
>
> On 21 July 2016 at 05:05, Ashish Negi 
> > wrote:
>
>> with core async `go` you can not do blocking IO or any time consuming 
>> work.
>> `go` uses fixed threadpool (no of cpus + 2 or something).
>> and in your async-handler you are using `> https://clojure.github.io/core.async/
>>
>> Try with `future`. https://clojuredocs.org/clojure.core/future
>>
>
> While futures will work, it's worth pointing out you'd get the same result 
> just by increasing the thread count on the adapter. Either way you're using 
> up a thread per request.
>
> Since the database functions are not asynchronous, core.async isn't really 
> useful in this context. My suggestion would be to drop it altogether.
>
> - James
>

http-kit threadpool was definitely bottleneck, and probably hakiri-cp 
connection pool.
I reverted to initial version without core.async and bumped both pools to 
128 and now CPU is fully saturated, and performance is much better. 
Comparable to Go version I wrote, maybe even better.
Thanks you both for your time :)

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


Re: meaning of spec/and ?

2016-07-21 Thread Steve Miner
It looks like you’ve got your #s misplaced.  I think you want something like 
this:

(s/and #(> % 0.0) #(< % 1.0))

Of course, the first predicate expression could be replaced by `pos?`.

The `s/and` returns a single spec that combines multiple specs.  Of course, 
`clojure.core/and` is basically the logical AND of “truthy” values.

The #(…) form is creating an anonymous function.  In your first case, that 
creates a reasonable predicate, which works correctly as a spec.

Your second form isn’t doing what you wanted because the anonymous function 
notation is wrapping the whole `s/and` combining form, and in that context the 
tests aren't syntactically the appropriate predicates.  You’re getting an extra 
level of nesting and bad tests.

I suspect that the confusion comes from the similarity between a predicate and 
a spec.  In a sense, a predicate function is the simplest form of a spec.  
However, you need a special way of combining multiple specs, not just the plain 
logical `and` combination.  So we have `s/and` to do the job.



> On Jul 21, 2016, at 1:23 PM, Mars0i  wrote:
> 
> With Clojure 1.9.0-alpha10:
> 
> user=> (s/def ::interval-with-cloj-and #(and   (> % 0.0) (< % 1.0)))
> 
> user=> (s/def ::interval-with-spec-and #(s/and (> % 0.0) (< % 1.0)))
> 
> user=> (s/valid? ::interval-with-cloj-and 1.0)
> false
> 
> That's what I expected.
> 
> user=> (s/valid? ::interval-with-spec-and 1.0)
> true
> 
> That's not what I expected.
> 
> In fact, as far as I can tell, (valid? ::interval-with-spec-and x) will 
> return true for any number x.  What does spec/and mean, then?  I thought that 
> in this context it would mean the same as Clojure's normal 'and'.  That's 
> what the first example of its use in the Clojure.spec Guide seems to show.  I 
> must be misunderstanding something basic and perhaps obvious.


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


Re: meaning of spec/and ?

2016-07-21 Thread Mars0i
Ahh...  I realized my mistake very soon after I posted the question, and 
deleted it.  You must have caught it before it went away.  Your explanation 
is helpful, though.  Thanks.

On Thursday, July 21, 2016 at 1:30:56 PM UTC-5, miner wrote:
>
> It looks like you’ve got your #s misplaced.  I think you want something 
> like this:
>
> (s/and #(> % 0.0) #(< % 1.0))
>
> Of course, the first predicate expression could be replaced by `pos?`.
>
> The `s/and` returns a single spec that combines multiple specs.  Of 
> course, `clojure.core/and` is basically the logical AND of “truthy” values.
>
> The #(…) form is creating an anonymous function.  In your first case, that 
> creates a reasonable predicate, which works correctly as a spec.
>
> Your second form isn’t doing what you wanted because the anonymous 
> function notation is wrapping the whole `s/and` combining form, and in that 
> context the tests aren't syntactically the appropriate predicates.  You’re 
> getting an extra level of nesting and bad tests.
>
> I suspect that the confusion comes from the similarity between a predicate 
> and a spec.  In a sense, a predicate function is the simplest form of a 
> spec.  However, you need a special way of combining multiple specs, not 
> just the plain logical `and` combination.  So we have `s/and` to do the job.
>
>
>
> On Jul 21, 2016, at 1:23 PM, Mars0i > 
> wrote:
>
> With Clojure 1.9.0-alpha10:
>
>
>
>
>
>
>
>
> *user=> (s/def ::interval-with-cloj-and #(and   (> % 0.0) (< % 
> 1.0)))user=> (s/def ::interval-with-spec-and #(s/and (> % 0.0) (< % 
> 1.0)))user=> (s/valid? ::interval-with-cloj-and 1.0)false*That's what I 
> expected.
>
>
> *user=> (s/valid? ::interval-with-spec-and 1.0)true*
>
> That's not what I expected.
>
> In fact, as far as I can tell, (valid? ::interval-with-spec-and x) will 
> return true for any number x.  What does spec/and mean, then?  I thought 
> that in this context it would mean the same as Clojure's normal 'and'.  
> That's what the first example of its use in the Clojure.spec Guide seems to 
> show.  I must be misunderstanding something basic and perhaps obvious.
>
>
>
>

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


Re: meaning of spec/and ?

2016-07-21 Thread adrian . medina
Just for future reference this is a mailing list and not a traditional 
forum, so after you post something here it will email everyone subscribed. 

On Thursday, July 21, 2016 at 6:24:28 PM UTC-4, Mars0i wrote:
>
> Ahh...  I realized my mistake very soon after I posted the question, and 
> deleted it.  You must have caught it before it went away.  Your explanation 
> is helpful, though.  Thanks.
>
> On Thursday, July 21, 2016 at 1:30:56 PM UTC-5, miner wrote:
>>
>> It looks like you’ve got your #s misplaced.  I think you want something 
>> like this:
>>
>> (s/and #(> % 0.0) #(< % 1.0))
>>
>> Of course, the first predicate expression could be replaced by `pos?`.
>>
>> The `s/and` returns a single spec that combines multiple specs.  Of 
>> course, `clojure.core/and` is basically the logical AND of “truthy” values.
>>
>> The #(…) form is creating an anonymous function.  In your first case, 
>> that creates a reasonable predicate, which works correctly as a spec.
>>
>> Your second form isn’t doing what you wanted because the anonymous 
>> function notation is wrapping the whole `s/and` combining form, and in that 
>> context the tests aren't syntactically the appropriate predicates.  You’re 
>> getting an extra level of nesting and bad tests.
>>
>> I suspect that the confusion comes from the similarity between a 
>> predicate and a spec.  In a sense, a predicate function is the simplest 
>> form of a spec.  However, you need a special way of combining multiple 
>> specs, not just the plain logical `and` combination.  So we have `s/and` to 
>> do the job.
>>
>>
>>
>> On Jul 21, 2016, at 1:23 PM, Mars0i  wrote:
>>
>> With Clojure 1.9.0-alpha10:
>>
>>
>>
>>
>>
>>
>>
>>
>> *user=> (s/def ::interval-with-cloj-and #(and   (> % 0.0) (< % 
>> 1.0)))user=> (s/def ::interval-with-spec-and #(s/and (> % 0.0) (< % 
>> 1.0)))user=> (s/valid? ::interval-with-cloj-and 1.0)false*That's what I 
>> expected.
>>
>>
>> *user=> (s/valid? ::interval-with-spec-and 1.0)true*
>>
>> That's not what I expected.
>>
>> In fact, as far as I can tell, (valid? ::interval-with-spec-and x) will 
>> return true for any number x.  What does spec/and mean, then?  I thought 
>> that in this context it would mean the same as Clojure's normal 'and'.  
>> That's what the first example of its use in the Clojure.spec Guide seems to 
>> show.  I must be misunderstanding something basic and perhaps obvious.
>>
>>
>>
>>

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


Re: meaning of spec/and ?

2016-07-21 Thread Sean Corfield
And deleting a post from the Google Groups interface still leaves everyone 
else’s replies – and in this case Steve’s first reply to your included your 
original post anyway… 

 

https://groups.google.com/forum/?hl=en#!topic/clojure/MxJOgQJPGN8

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 

On 7/21/16, 3:34 PM, "clojure@googlegroups.com on behalf of 
adrian.med...@mail.yu.edu"  wrote:

 

Just for future reference this is a mailing list and not a traditional forum, 
so after you post something here it will email everyone subscribed. 

On Thursday, July 21, 2016 at 6:24:28 PM UTC-4, Mars0i wrote:

Ahh...  I realized my mistake very soon after I posted the question, and 
deleted it.  You must have caught it before it went away.  Your explanation is 
helpful, though.  Thanks.


 

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


async-webinar vs. lein-cljsbuild vs nooby

2016-07-21 Thread hiskennyness
This cemo of channels in a web client works great.

   https://github.com/cognitect/async-webinar/blob/master/project.clj

It uses plugin:

  [lein-cljsbuild "1.0.4-SNAPSHOT"]

While trying to extend the webinar with my Cells library 
https://github.com/kennytilton/rube (which loads nicely from clojars  in my 
mobile app framework Qxia (https://github.com/kennytilton/qxia)) things 
were not going well so, looking for differences, I noticed that Qxia's 
cljsbuild plugin is:

  [lein-cljsbuild "1.1.3"]

In the spirit of eliminating differences, I tried that plugin on 
async-webinar and got errors:

Exception in thread "main" java.io.FileNotFoundException: Could not locate 
>> cljs/build/api__init.class or cljs/build/api.clj on classpath: , 
>> compiling:(cljsbuild/compiler.clj:1:1)
>
>
>
I am not surprised because I *did* change something, but:

   1. Is that about right? I do have to stick to 1.0.4-SNAPSHOT?
   2. I do not see where the webinar references "api" anything. Just 
   typical error noise?
   3. How daft am I for worrying about the lein-cljsbuild version before 
   anything else?

-kt 

  

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


ANN: One-Time 0.1.0 [One Time Password (TOTP and HOTP) library for Clojure]

2016-07-21 Thread Suvash Thapaliya
One-Time is a Clojure library for generating one time passwords (HOTP & 
TOTP) as per RFC 4226 and RFC 6238. TOTP/HOTP is widely used for 
Multi-Factor Authentication.

Leiningen dependency:

  [one-time "0.1.0"]

This is the first release of the library. https://github.com/suvash/one-time

- The library can generate both Time based One-time passwords (TOTP) and 
HMAC based One-time passwords (HOTP).
- Randomly generates relevant secret-key for TOTP/HOTP.
- Validate TOTP/HOTP tokens against the secret keys.
- Generate TOTP/HOTP URIs that can be embedded in QR codes.
- Generate QR Code URLs using 3rd party provider (Google).
- Has been tested to be compatible with Google Authenticator and Authy.
- The code is (almost)fully tested.
- Beginner-friendly documentation is provided.

Hopefully, this makes it easier to implement Multi-factor Authentication 
(TOTP/HOTP) to Clojure applications. Looking forward to feedback and 
patches.

https://github.com/suvash/one-time

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


Re: meaning of spec/and ?

2016-07-21 Thread Mars0i
On Thursday, July 21, 2016 at 5:34:37 PM UTC-5, adrian...@mail.yu.edu wrote:
>
> Just for future reference this is a mailing list and not a traditional 
> forum, so after you post something here it will email everyone subscribed. 
>

Thanks Adrian.  I actually didn't realize that. 

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


Re: Amazonica and S3

2016-07-21 Thread Andrea Richiardi
I am glad you solved and raised the issue so that we can track that!

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


fspec requires dependency on test.check

2016-07-21 Thread Joe Selman
I have a simple lein project on clojure 1.9.0-alpha10 with no other 
dependencies. Trying to use fspec and explain yields an error:

(require '[clojure.spec :as s])
> => nil
> (s/def ::my-spec (s/fspec :args string? :ret string?))
> => :user/my-spec
> (s/explain ::my-spec (fn [_] "foo"))
> FileNotFoundException Could not locate 
> clojure/test/check/generators__init.class or 
> clojure/test/check/generators.clj on classpath.  clojure.lang.RT.load 
> (RT.java:458)


Is this a bug or do some uses of spec require a test.check dependency?

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


Re: fspec requires dependency on test.check

2016-07-21 Thread Alex Miller
Hi Joe,

This is an area of ongoing work and the following ticket captures this 
issue as well:

http://dev.clojure.org/jira/browse/CLJ-1936 (and 
duped http://dev.clojure.org/jira/browse/CLJ-1976)

Spec by itself should not require a test.check dependency.

Alex


On Thursday, July 21, 2016 at 11:55:37 PM UTC-5, Joe Selman wrote:
>
> I have a simple lein project on clojure 1.9.0-alpha10 with no other 
> dependencies. Trying to use fspec and explain yields an error:
>
> (require '[clojure.spec :as s])
>> => nil
>> (s/def ::my-spec (s/fspec :args string? :ret string?))
>> => :user/my-spec
>> (s/explain ::my-spec (fn [_] "foo"))
>> FileNotFoundException Could not locate 
>> clojure/test/check/generators__init.class or 
>> clojure/test/check/generators.clj on classpath.  clojure.lang.RT.load 
>> (RT.java:458)
>
>
> Is this a bug or do some uses of spec require a test.check dependency?
>

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


Re: fspec requires dependency on test.check

2016-07-21 Thread Joe Selman
Great, thanks!

On Thursday, July 21, 2016 at 10:02:51 PM UTC-7, Alex Miller wrote:
>
> Hi Joe,
>
> This is an area of ongoing work and the following ticket captures this 
> issue as well:
>
> http://dev.clojure.org/jira/browse/CLJ-1936 (and duped 
> http://dev.clojure.org/jira/browse/CLJ-1976)
>
> Spec by itself should not require a test.check dependency.
>
> Alex
>
>
> On Thursday, July 21, 2016 at 11:55:37 PM UTC-5, Joe Selman wrote:
>>
>> I have a simple lein project on clojure 1.9.0-alpha10 with no other 
>> dependencies. Trying to use fspec and explain yields an error:
>>
>> (require '[clojure.spec :as s])
>>> => nil
>>> (s/def ::my-spec (s/fspec :args string? :ret string?))
>>> => :user/my-spec
>>> (s/explain ::my-spec (fn [_] "foo"))
>>> FileNotFoundException Could not locate 
>>> clojure/test/check/generators__init.class or 
>>> clojure/test/check/generators.clj on classpath.  clojure.lang.RT.load 
>>> (RT.java:458)
>>
>>
>> Is this a bug or do some uses of spec require a test.check dependency?
>>
>

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