Re: using "hidden" parameters?

2014-06-14 Thread Linus Ericsson
A more commonly used feature are bindings, which are sort of "pluggable"
(or rather overridable) dynamic vars.

http://stackoverflow.com/questions/1523240/let-vs-binding-in-clojure

In short you declare a variable as dynamic and then use some binding around
the function-call.

Sort of a reusable let-body, but with slightly different characteristics.

/Linus

On Saturday, June 14, 2014, Mars0i  wrote:

> Here's a way to do it.  Not sure if this is what you want.
>
> (let [x (atom 12)]
>   (defn next-number [] (swap! x inc)))
>
> Functions are clojures, which means that next-number can retain a pointer
> to a variable that it can see when it's defined.
>
> If some of the ideas here are unfamiliar:
> The atom function gives you something that you can modify in place, in
> effect, and swap! is one way to modify it.  Passing inc to swap! applies
> inc to the value in the atom x, and stores the result back into the atom.
> (I'm not sure if my wording here is precisely correct, but the idea should
> be clear enough.)
>
> You can also use a top-level variable instead of a local one defined by
> let:
>
> (def x (atom 12))
> (defn next-number [] (swap! x inc))
> @x ;=> 12
> ; [the @ operator gets the value out of the atom.]
> (next-number) ;=> 13
> @x ;=> 13
> (next-number) ;=> 14
>
> With the let form, (next-number) is your *only* way of accessing x, which
> could be a good thing or a bad thing--unless you define other functions in
> the scope of the let at the same time that you define next-number:
>
> (let [x (atom 12)]
>   (defn next-number [] (swap! x inc))
>   (defn undo-next [] (swap! x dec))
>   (defn check-number [] @x))
>
> (check-number) ;=> 12
> (check-number) ;=> 12
> (next-number);=> 13
> (check-number) ;=> 13
> (undo-next);=> 12
> (check-number) ;=> 12
>
>
> (Perhaps many Clojure programmers *would* consider all of this perverse,
> but similar things are considered ... cool in the some corners of the
> Scheme and Common Lisp worlds.  ("cool" doesn't necessarily mean "useful
> often"--just *cool*--and maybe useful now and then.))
>
> On Friday, June 13, 2014 7:16:09 PM UTC-5, Christopher Howard wrote:
>>
>> This might be kind of perverse, but I was wondering if it was possible
>> to write a function or macro that takes "hidden parameters", i.e.,
>> uses symbols defined in the scope of use, without passing them in
>> explicitly.
>>
>> For example, function "next-number" takes hidden parameter "x", so
>>
>> => (let [x 12] (next-number))
>>
>> Would return 13.
>>
>> With the whole "code is data" paradigm it seems like this should be
>> possible, but I haven't figured out how to do this yet without getting
>> an error.
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> 
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: time expression of clojure produces different results on cascalog queries

2014-06-14 Thread Linus Ericsson
It says Criterium ran four batches of 60 samples in each (it tries to make
the jvm då garbage collection etc between each such batch).

In total, 240 samples (ie timed test runs).

The statistics are better looked up at wikipedia, but "lower quartile" here
means the 2.5% of the 240 samples (0.025 * 240 = 6) that had the lowest
time where 229.8 ms etc. Outliers are intresting, since there can be some
that takes much much longer time than other.

Overhead (in this case negible small) is the time criterium takes in the
samples, I think.

Your results looks consistent, the one minute delay you saw initially COULD
have been delayed by a full Garbage Collection. These can be triggered at
random in production, so try to collect metrics (there's both clojure and
java libs for that, named something "metrics") in production or with
realistic loads! And remember you can tweak the GC in many ways to make it
less rude to your application.

/Linus

On Saturday, June 14, 2014, sindhu hosamane  wrote:

> Thanks a ton for ur reply's Andy and Thomas .
>>
>> I used Criterium and got results like below :
>
> Evaluation count : 240 in 60 samples of 4 calls.
>  Execution time mean : 265.359848 ms
> Execution time std-deviation : 25.544031 ms
>Execution time lower quantile : 229.851248 ms ( 2.5%)
>Execution time upper quantile : 310.110448 ms (97.5%)
>Overhead used : 2.708614 ns
>
> But i don't understand the output . What does "Evaluation count : 240 in
> 60 samples of 4 calls." mean ? Also little unclear about other details too.
> Could you please make me understand a little about above output !! Would
> really appreciate ur help .
>
> Cheers,
> Sindhu
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> 
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Gin card game with Datomic

2014-06-14 Thread Gijs S.

In IE the network parts only work in IE10 or better. The EventSource 
polyfill does support IE8 or better, but doesn't send cookies along for IE8 
or 9 and the cookies are used for authentication. I haven't bothered with 
working around that.

-Gijs

On Saturday, June 14, 2014 6:22:33 AM UTC+2, Dry Jin wrote:
>
> Great, but I couldn't play this game.
>  
> Do I need something else to play this? 
>  
> I am using  IE8.
>
> 2014년 6월 13일 금요일 오후 4시 49분 19초 UTC+9, Gijs S. 님의 말:
>
>> Hi all,
>>
>> I wrote a web app where you can play a card game with Clojure, 
>> ClojureScript and Datomic.
>>
>> Background on the design is here: 
>> http://thegeez.net/2014/06/12/gin_datomic.html
>>
>> The game is playable here: http://gin.thegeez.net/
>>
>> The code is on github: https://github.com/thegeez/gin
>>
>> -Gijs
>>
>

-- 
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: Mathematica like eval

2014-06-14 Thread Maik Schünemann
Hi,
You can use expresso  for
this:
(use 'numeric.expresso.core)
(def e (ex (+ 8 a (* 9 (+ 2 b)) 2)))
;=> (+ 8 a (* 9 (+ 2 b)) 2)
This expression can now be manipulated by expresso to
simplify it, solve it, etc.
you can substitute a and b for its values when you know them and then
evaluate
(evaluate (substitute e '{a 1 b 2})) (or (evaluate e '{a 1 b 2}) which is
equivalent)
;=> 47
But I think you are searching for compile-expr which turns the expression
to a efficient clojure function taking the arguments
((compile-expr [a b] (+ a b)) 1 2) ;=> 3
In your example, you can get the partial evaluate behaviour by using
optimize on the expression beforehand. optimize will do several
transformations one of them is constant merging:
(optimize e) ;=> (+ 10 a (* 9 (+ 2 b)))
which can the compiled by compile-expr* (the function equivalent)
(def partial-evaluated (compile-expr* '[a b] (optimize e)))
(partial-evaluated 1 2) ;=> 47

Hope this helps
M*aik*




On Sat, Jun 14, 2014 at 1:43 AM, Christopher Small 
wrote:

> There is a nice example of something similar to this in Joy of Clojure
> (2nd edition anyway; not sure about first). It only shows you how to do
> contextual-evaluation, and doesn't return a function if some set of the
> symbols are not mapped in the context, but I'll bet you could modify the
> example to infer when one of the variables is missing in the context
> specification, and return a function in that case. It is right at the
> beginning of the section on macros. Good book, BTW.
>
> Can maybe share more later if you aren't interested in getting the book or
> need more guidance on this.
>
> Chris
>
>
>
> On Friday, June 13, 2014 2:46:56 PM UTC-7, Dilvan wrote:
>>
>>Hi all,
>>
>>I'm a novice to Clojure (but not to programming).
>>I'm looking for an implementation of an eval function to eval
>> expression like Mathematica does.
>>For instance, in Mathematica the expression:
>>
>>8 + a + 9 (2 + b) + 2
>>
>>if a and b are not bound, translates to
>>
>> Plus[10, a, Times[9, Plus[2, b]]]
>>
>>if a and b become bounded later (let say to 1 and 2) and the
>> expression is evaluated again, it returns 47.
>>
>>I would like to be able to run:
>>  (eval-partial '(+ (+ 8 2) a (* 9 (+ 2 b
>>and get, if a and b are unbound:
>>  (fn [x y] (+ 10 x (* 9 (+ 2 y
>>or (better still)
>>  ['(a b) (fn [x y] (+ 10 x (* 9 (+ 2 y]
>>Notice that, whenever possible, the eval takes place and parts of the
>> expression are evaluated (in the example above, the expression (+ 8 2) is
>> evaluated to 10).
>>
>>If you know of any implementation or have any ideas on the subject,
>> please let me know.
>>
>>Cheers,
>> Dilvan.
>>
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Convert clj-time date-time to UTC

2014-06-14 Thread gvim
I want to convert a time specified with a TZ datababse timezone such as 
"America/Caracas" into a UTC date-time but I can only find in clj-time 
from-time-zone and to-time-zone allowing the zone to be specified as a 
string. I want:


(t/ (t/date-time 1967 7 31 6 30) (t/time-zone-for-id 
"America/Caracas"))


to give me:

#

Even the (t/from-time-zone []) output would do if I could read the UTC 
date and time straight from it.


gvim

--
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: Convert clj-time date-time to UTC

2014-06-14 Thread Stephen Gilardi
This is not quite to your exact specification, but should help you to write 
what you want:

user> (defn to-utc [dt]
(t/to-time-zone dt (t/time-zone-for-offset 0)))
#'user/to-utc
user> (to-utc (t/from-time-zone (t/date-time 1967 7 31 6 30) 
(t/time-zone-for-id "America/Caracas")))
#

--Steve

On Jun 14, 2014, at 10:09 AM, gvim  wrote:

> I want to convert a time specified with a TZ datababse timezone such as 
> "America/Caracas" into a UTC date-time but I can only find in clj-time 
> from-time-zone and to-time-zone allowing the zone to be specified as a 
> string. I want:
> 
> (t/ (t/date-time 1967 7 31 6 30) (t/time-zone-for-id 
> "America/Caracas"))
> 
> to give me:
> 
> #
> 
> Even the (t/from-time-zone []) output would do if I could read the UTC date 
> and time straight from it.
> 
> gvim
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: Convert clj-time date-time to UTC

2014-06-14 Thread gvim

On 14/06/2014 16:12, Stephen Gilardi wrote:

This is not quite to your exact specification, but should help you to
write what you want:

user> (defn to-utc [dt]
(t/to-time-zone dt (t/time-zone-for-offset 0)))
#'user/to-utc
user> (to-utc (t/from-time-zone (t/date-time 1967 7 31 6 30)
(t/time-zone-for-id "America/Caracas")))
#



Thanks. Can't think why it's not baked into the library, though, as it 
must be a common requirement.


gvim

--
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: Convert clj-time date-time to UTC

2014-06-14 Thread Stephen Gilardi
You're welcome.

As another small refinement, I noticed that there's a var for the utc timezone:

(t/time-zone-for-offset 0)

can be replaced with

t/utc

--Steve

On Jun 14, 2014, at 12:49 PM, gvim  wrote:

> On 14/06/2014 16:12, Stephen Gilardi wrote:
>> This is not quite to your exact specification, but should help you to
>> write what you want:
>> 
>> user> (defn to-utc [dt]
>> (t/to-time-zone dt (t/time-zone-for-offset 0)))
>> #'user/to-utc
>> user> (to-utc (t/from-time-zone (t/date-time 1967 7 31 6 30)
>> (t/time-zone-for-id "America/Caracas")))
>> #
>> 
> 
> Thanks. Can't think why it's not baked into the library, though, as it must 
> be a common requirement.
> 
> gvim
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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


Re: Convert clj-time date-time to UTC

2014-06-14 Thread gvim

On 14/06/2014 17:59, Stephen Gilardi wrote:

You're welcome.

As another small refinement, I noticed that there's a var for the utc
timezone:

(t/time-zone-for-offset 0)


can be replaced with

t/utc



I tried t/utc in place of your function but it didn't produce the 
desired result.


gvim

--
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: Instaparse - thank you!

2014-06-14 Thread Mark Engelberg
Thanks for the kind words, everyone!  It's great to hear that people are
using Instaparse to "get things done."

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


Re: Instaparse - thank you!

2014-06-14 Thread John Mastro
Agreed - thanks Mark!

If anyone is able to share the query languages you're using (the language's
grammar more than the implementation), I'd be very interested (and
grateful).

I'm always struggling to create reports for our non-technical staff which
are flexible enough to be useful but don't rely on complicated UIs. I've
tried the natural language approach a couple times but haven't come up with
anything I'm happy with.

- John

On Tue, Jun 10, 2014 at 8:04 PM, Sean Corfield  wrote:

> I just wanted to post a public "Thank You!" to Mark Engelberg for his
> Instaparse library.
>
> https://github.com/Engelberg/instaparse
>
> We are just starting to use this at World Singles so that we can provide a
> "natural language" interface to our search engine, allowing our internal
> support folks to create custom queries without needing some complex
> cascading drop-down-filled UI to define complex queries. The ability to
> provide an English-like DSL for an otherwise very complex part of our
> business is a huge benefit!
>
> I started playing with Instaparse just yesterday morning and we have a
> working proof of concept up on QA today - Instaparse is an amazing tool!
>
> Sean Corfield -- http://clojurebridge.org
>
> "ClojureBridge aims to increase diversity within the Clojure community by
>  offering free, beginner-friendly Clojure programming workshops for women."
>
>

-- 
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: How to unit test (defn-) functions?

2014-06-14 Thread rarous
Always test private functions through public ones. They have to use them. 
Private stuff should appear during refactoring phase.

On Thursday, June 12, 2014 10:44:21 AM UTC+2, Hussein B. wrote:
>
> Hi,
>
> I like to use (defn-) when it comes to internal implementation functions. 
> But since they aren't exposed, how to unit test them?
>
> Of course, I'm using Lein and clojure.test
>
> Thanks.
>

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


Re: Convert clj-time date-time to UTC

2014-06-14 Thread Michael Klishin
2014-06-14 20:49 GMT+04:00 gvim :

> Can't think why it's not baked into the library, though, as it must be a
> common requirement.


Feel free to submit a pull request and a few tests. The clj-time
maintainers are responsive
and the library is primarily driven by user feedback at this point.
-- 
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/d/optout.


ANN metrics-clojure 2.1.0 is released

2014-06-14 Thread Michael Klishin
metrics-clojure [1] is a Clojure interace to Coda Hale's Metrics library
[2]. If you are not sure
why collecting metrics about your app is valuable, take a moment and watch
[3].

Release notes:
https://github.com/sjl/metrics-clojure/blob/master/ChangeLog.md#changes-between-20x-and-210

1. https://github.com/sjl/metrics-clojure/
2. http://metrics.codahale.com/
3. http://www.youtube.com/watch?v=czes-oa0yik
-- 
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/d/optout.


Re: Convert clj-time date-time to UTC

2014-06-14 Thread gvim

On 14/06/2014 21:59, Michael Klishin wrote:

2014-06-14 20:49 GMT+04:00 gvim mailto:gvi...@gmail.com>>:

Can't think why it's not baked into the library, though, as it must
be a common requirement.


Feel free to submit a pull request and a few tests. The clj-time
maintainers are responsive
and the library is primarily driven by user feedback at this point.
--
MK


I'll have to leave it to the gods as I'm a mere mortal :)

gvim

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


Could use an error message here? (using `get` on an atom containing a map)

2014-06-14 Thread John Gabriele
This one took me a few minutes to see what I was doing wrong:

~~~
user=> (def m (atom {:x 1 :y 2}))
#'user/m

;; Later on ...
user=> (get m :x)
nil

;; What?? `:x` isn't a key in `m`? But I *know* it is...

;; Sanity check, for comparison:
user=> (get {:a 1 :b 2} :c); Right; `:c` is not a key in there, so I 
get `nil`.
nil

;; Time passes and I eventually see the typo:
user=> (get @m :x)
1
~~~

Would be nice if that `(get m :x)` yielded an error message along the lines 
of, "That's not a map, it's a reference to an atom containing a map."

-- John

-- 
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: Clojure on iOS devices - Swift as a host?

2014-06-14 Thread Mike Fikes
Hey Devin,

You had asked to see some code. Here is a little, to give a feel for the 
“top level” without digging into the plumbing.

Let's say you want an authentication UI that lets you enter a 6-digit code 
with a keypad and asterisk indicators showing how many digits have been 
keyed. Here is a screenshot of that UI (actually being driven by 
ClojureScript):


This UI simply comprises some labels and some buttons.

The ClojureScript code that runs the UI binds to those iOS components via 
tag number (which is set in interface builder), and has a little logic to 
maintain a model that consists of a vector of the digits entered so far, 
and code to color the asterisks.

In the picture above, two button presses have occurred and the code has 
logged:

*2014-06-14 22:47:11.291 Test App[2428:60b] JS: code-entered: [1]*

*2014-06-14 22:47:12.213 Test App[2428:60b] JS: code-entered: [1 4]*

The “view controller namespace” hooked up to this view is this 
ClojureScript code below. In it you can see an atom per UI element along 
with bits of code manipulating the maps in the atoms (such as 
set-enabled!). The “plumbing” that I haven't shown is a bit of boring code 
that marshals information between the atom values and the iOS components. A 
sample atom value for a text field might look like {:text "foo" :enabled 
true}.

(ns test-app.view-controller
  (:require [fikesfarm.ios.interop :refer [bind!]]
[fikesfarm.ios.view-model :refer [set-text! set-callback! 
set-enabled! set-hidden!]])
  (:require-macros [fikesfarm.ios.util :refer [with-try]]))

;; View-Model
(def asterisk-labels (vec (repeatedly 6 #(atom {}
(def number-buttons (vec (repeatedly 10 #(atom {}
(def clear-button (atom {}))

;; Model
(def code-entered (atom [] :validator #(< (count %) 7)))

(defn- update-asterisk-labels!
  [count-entered]
  (dorun (map-indexed (fn [n asterisk-label] (set-enabled! asterisk-label 
(< n count-entered))) asterisk-labels)))

(defn- set-number-buttons-enabled!
  [enabled]
  (dorun (map #(set-enabled! % enabled) number-buttons)))

(defn ^:export init-myvc!
  [view]
  (with-try

;; Bind the UI elements
(dorun (map #(bind! view %1 %2) (range 21 27) asterisk-labels))
(dorun (map #(bind! view %1 %2 :touch-up-inside) (range 1 11) 
number-buttons))
(bind! view 11 clear-button :touch-up-inside)

;; When a number button is pressed, conj value to the code-entered 
vector
(dorun (map #(set-callback! %1 (fn [] (swap! code-entered conj (mod %2 
10
number-buttons
(range 1 11)))

;; Empty the code-entered vector if clear button pressed
(set-callback! clear-button (fn [] (reset! code-entered [])))

;; Set the asterisk labels to the correct initial rendering
(update-asterisk-labels! 0)

;; As the code-entered model changes, update the number of asterisks 
shown
(add-watch code-entered :code-entered
   (fn [_ _ old-code-entered new-code-entered]
 (when-not (= old-code-entered new-code-entered)
   (println "code-entered:" new-code-entered)
   (update-asterisk-labels! (count new-code-entered))
   (when (= new-code-entered [1 4 7 2 5 8])
 (set-number-buttons-enabled! false)
 (set-enabled! clear-button false)))

- Mike

On Wednesday, June 11, 2014 10:46:28 PM UTC-4, Devin Walters (devn) wrote:
>
> If I had a small fortune I would pay you to sit down and show me how this 
> business you're talking about works. Sounds really cool. Is doing this kind 
> if thing documented well anywhere? I'd love to see some code and your 
> workflow. 
>
> '(Devin Walters) 
>

-- 
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: Could use an error message here? (using `get` on an atom containing a map)

2014-06-14 Thread Ambrose Bonnaire-Sergeant
Seems unlikely:
http://dev.clojure.org/jira/browse/CLJ-1107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=34820#comment-34820

I would write my own get variant, or use something like Dynalint
.

Thanks,
Ambrose

On Sun, Jun 15, 2014 at 10:35 AM, John Gabriele  wrote:

> This one took me a few minutes to see what I was doing wrong:
>
> ~~~
> user=> (def m (atom {:x 1 :y 2}))
> #'user/m
>
> ;; Later on ...
> user=> (get m :x)
> nil
>
> ;; What?? `:x` isn't a key in `m`? But I *know* it is...
>
> ;; Sanity check, for comparison:
> user=> (get {:a 1 :b 2} :c); Right; `:c` is not a key in there, so I
> get `nil`.
> nil
>
> ;; Time passes and I eventually see the typo:
> user=> (get @m :x)
> 1
> ~~~
>
> Would be nice if that `(get m :x)` yielded an error message along the
> lines of, "That's not a map, it's a reference to an atom containing a map."
>
> -- John
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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