Re: subtle om + core.async problems

2014-07-25 Thread Daniel Kersten
You could simplify your fix code a small bit by using go-loop and when,
like this:

(go-loop []
  (let [[v ch] (alts! [dump-chan (om/get-state owner :exit-chan)])]
(when (= ch dump-chan)
  (.log js/console "dumping state:")
  (.log js/console (pr-str (om/get-state owner)))
  (recur

This won't work in your code because my-form's parent owns dump-chan, but
if a component owns the channel, an alternative approach is to simply close
dump-chan in IWillUnmount and change your go block to something like this:

(go-loop []
  (when-let [v ( new dom nodes out; but as the child stores the
channel between calls to parents render, this breaks that "rule") and I've
never had the issue.
Since base isn't being re-rendered in this case, I'm not sure why this
would be a problem here.



On 24 July 2014 02:35, Sean Corfield  wrote:

> You'll want to read this thread:
> https://groups.google.com/forum/#!topic/clojurescript/DHJvcGey8Sc
>
> In particular:
>
> "So if you have code that's like this, those components will want to clean
> up after themselves in IWillUnmount."
>
> That should address your first problem?
>
> I'm not sure what to suggest right now about the second problem.
>
> Sean
>
>
> On Jul 23, 2014, at 4:19 PM, Alexander Hudek  wrote:
>
> I've encountered two subtle but serious problems using om with core.async.
>
> The first one is illustrated by this code:
>
> https://github.com/akhudek/om-async-error
>
> First, one obvious solution here is to move the dump-chan inside the form
> state.
> However, it's written this way to illustrate the error which originally
> arose in a
> dialog component that took both an action channel that receives button
> presses
> and a dialog content component. It exposed the action channel in this way
> in
> order to be flexible.
>
> I believe the cause of this error is that when you toggle the form in the
> demo
> to off, it unmounts the component. However, the go-block is still active
> and
> listening to the channel. When you toggle the form back on, a new component
> is created and mounted. Now you have two components listening on the same
> channel!
>
> The ideal solution might be to find a way to end the go block when the
> component
> unmounts. This is easy to do on a case by case basis, but not easy to do
> in a
> completely generic fashion. Here is one solution:
>
>
> https://github.com/akhudek/om-async-error/blob/alts-fix/src/om_async_error/core.cljs
>
> The second problem is easy to fix, however, I don't understand why it
> happens.
>
> https://github.com/akhudek/om-async-error/tree/chan-opts-bug
>
> Instead of initializing the dump channel in the base components state, we
> initialize
> it when creating the form component. As soon as you start typing into the
> form
> the channel breaks. It was suggested on irc that this might be because of
> a
> re-render of base would create a new channel, but the form component will
> not
> be re-mounted because it's already mounted. However, putting in some debug
> code shows that there is no re-render of the base component occurring
> between
> when the channel works and when it doesn't.
>
> I'm posting this here mostly to warn people to be wary of these
> situations. Of
> course, if you have any suggestions or explanations for these I'd love to
> hear them.
>
> Alex
>
>
>
>

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Bob Hutchison

On Jul 25, 2014, at 12:27 AM, Michael O'Keefe  
wrote:

> Andy, good advice and I agree. Thanks. I'll think on it then.

Would you want one of your users going though this kind of thought process: I 
won't file a ticked because I don't think it can be fixed? It's a bug, file the 
ticket. At the very least it can be documented.

Cheers,
Bob


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


Re: ANN qarth 0.1.0, an OAuth library

2014-07-25 Thread Plínio Balduino
Hi, Fred

I never used Friend and I don't have parameters to compare so, why Qarth?

I didn't get the "Qarth's goal is to fix the problem of Ring/Compojure
and/or Friend apps reinventing the wheel for OAuth." explanation.

Regards

Plínio


On Fri, Jul 25, 2014 at 3:47 AM, Robin Heggelund Hansen <
skinney...@gmail.com> wrote:

> I was just looking for a OAuth library, this looks great!
>
> kl. 19:15:11 UTC+2 torsdag 24. juli 2014 skrev Mike Thvedt følgende:
>>
>> Qarth is a simple interface to OAuth. Qarth's goal is to fix the problem
>> of Ring/Compojure and/or Friend apps reinventing the wheel for OAuth.
>>
>> Qarth features zero-effort Friend integration. The interactive auth flow
>> in "friendless" Qarth is two or three lines of code plus configuration. All
>> OAuth providers use the same interface, so that you can swap providers or
>> use "multi" providers (i.e. login with Facebook or Github) with little
>> additional effort.
>>
>> Qarth comes with out-of-the-box support for Facebook, Github, Twitter,
>> Google, and Yahoo!, and generic support for OAuth v2 and Scribe-Java.
>>
>> https://github.com/mthvedt/qarth
>>
>> Qarth is brand new, so please let me know about any issues or rough edges
>> you encounter.
>>
>> --Mike
>> mike@gmail.com
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


"proxy"ing PersistentHash to allow key->val and (reverse key)->val mapping

2014-07-25 Thread Geoff Little
I'm attempting to proxy PersistentHashmap so that "get"ting an existing key 
or its reverse returns the same value.

Here's the code that I have

(defn sym-key-hash-map []
  (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
(valAt [key]
   (or (proxy-super valAt key)
   (proxy-super valAt (reverse key))

(let [key (list 1 2)]
  (get (assoc (sym-key-hash-map) key "sweet")
   (reverse key)))

But unfortunately, the test code returns nil instead of "sweet".

Does anyone with knowledge of proxy and PersistentHashmap know how to solve 
this?

Thanks.

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


Re: Is Korma still a good current choice for DB backend?

2014-07-25 Thread Scott Nielsen

On Jul 24, 2014, at 7:23 PM, Tony Tam  wrote:

> I've been using korma in a side-project for a while and it behaves well.
> There sure are a bunch of PRs on their github that could be merged, not sure 
> what's up with that.
> 
> One problem I ran into last week was that I got some conflicts when trying to 
> upgrade the versions of some dependencies.
> 
> One benefit of using korma is that it uses a connection/statement pooling 
> library underneath (in this case c3p0), something that I don't think 
> yesql/honeysql do.

Yesql is connection agnostic, so it will work with any connection that 
clojure.java.jdbc can work with, including a connection pool.

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

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


Re: Is Korma still a good current choice for DB backend?

2014-07-25 Thread Jason Coffin

Tony Tam writes:

> One benefit of using korma is that it uses a connection/statement pooling 
> library underneath (in this case c3p0), something that I don't think 
> yesql/honeysql do.

This guide will help you setup connection pooling. It is general enough
to be applied to anything that requires a db spec. And you will notice it
that it isn't too difficult to setup.

-- 
Jason Coffin
www.jasoncoffin.com | ja...@jasoncoffin.com
617.869.0609

-- 
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 control evaluation of code with cider

2014-07-25 Thread Timothy Washington
On Wed, Jul 23, 2014 at 10:08 PM, Brent Millare 
wrote:

> I forgot to include in the snippet, that I would do something like
>
> (def live-repl-client (cljs.repl/channel-repl repl-env))
>
> When you say channel-repl/cider-function, do you mean
> user/live-repl-client?
>

Yes, exactly.


>
> I don't quite understand what you mean by (prefix).
>

*prefix* was just the variable taken from the interactive function.

(defun cider-eval-cljs-defun-at-point (&optional *prefix*)
  "Evaluate the current toplevel form, and print result in the minibuffer.
With a PREFIX argument, print the result in the current buffer."
  *(interactive "P")*
  ...)




>
> What I want is just to be able to evaluate clojurescript code in a buffer
> just like I do with regular clojure code. This way I get the same access to
> large chunks of scratch code that I can only easily access when I have it
> in an emacs buffer.
>

Ah, ok. I think austin gives this to you. I'll need to double-check.


>
> I don't really know much about piggieback or austin. I'd prefer to stay as
> close to upstream/vanilla clojurescript as possible.
>
>
But this is a fair point, as Austin 
took some doing for me to set up. If it helps, I created a simple component
(gist here ) that
puts the repl-env creation into a *Component
*. There's also a helper
function that lets you deliver an HTML resource, with a
'clojure.browser.repl.connect' back to your repl-env (in your browserrepl).


Cheers
Tim

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


Re: Is Korma still a good current choice for DB backend?

2014-07-25 Thread Jason Coffin

Jason Coffin writes:

> This guide will help you setup connection pooling. It is general enough
> to be applied to anything that requires a db spec. And you will notice it
> that it isn't too difficult to setup.

Bah, I forgot to link to the guide! Haha, here it is:
http://clojure-doc.org/articles/ecosystem/java_jdbc/connection_pooling.html

-- 
Jason Coffin
www.jasoncoffin.com | ja...@jasoncoffin.com
617.869.0609

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Andy Fingerhut
Sorry, I forgot the following disclaimer: I am in no way an official voice
for what will or will not be changed in Clojure in the future.  I am merely
an interested observer of what has changed in Clojure in the past.  I've
created and edited some tickets, written some Clojure patches, some of
which have been accepted, many of which have been rejected.

I was providing Michael advice based upon my best guess of what would
happen if he filed a ticket for this issue.  I could be completely 100%
wrong.  Do whatever you like.

Andy


On Fri, Jul 25, 2014 at 4:30 AM, Bob Hutchison 
wrote:

>
> On Jul 25, 2014, at 12:27 AM, Michael O'Keefe 
> wrote:
>
> > Andy, good advice and I agree. Thanks. I'll think on it then.
>
> Would you want one of your users going though this kind of thought
> process: I won't file a ticked because I don't think it can be fixed? It's
> a bug, file the ticket. At the very least it can be documented.
>
> Cheers,
> Bob
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Steve Miner
I will call it a bug.  It's definitely surprising to the user, and therefore 
worthy of a ticket.  On first glance, it seems that the fix isn't too hard. In 
core.clj where the macro fn is redefined, we just need to wrap the section that 
handles the post condition either with a loop* or a fn* so that the body has 
the proper recur target.  I'll try to make a patch and a test.  If it works, 
I'll file a bug with the patch.

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Michael O'Keefe
Thanks Bob, Steve, and Andy. I was trying to get logged into JIRA to file 
the bug report but I seem to be having a heck of a time -- I have a CA and 
am signed up at dev.clojure.org but when I try to log into JIRA, it gives 
me a nice "System Error" saying " user should not be null!". I've run out 
of time to deal with this right now but, Steve, if you get to it before me, 
feel free to submit the bug report.

Thanks all for the helpful discussions!

Michael

On Friday, July 25, 2014 7:58:51 AM UTC-6, miner wrote:
>
> I will call it a bug.  It's definitely surprising to the user, and 
> therefore worthy of a ticket.  On first glance, it seems that the fix isn't 
> too hard. In core.clj where the macro fn is redefined, we just need to wrap 
> the section that handles the post condition either with a loop* or a fn* so 
> that the body has the proper recur target.  I'll try to make a patch and a 
> test.  If it works, I'll file a bug with the patch.

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread adrian . medina
I do not believe this should be considered a bug. Recur is a special form 
that rebinds the bindings at the point of recursion with new values. It 
does not return a value. It does not get evaluated in the normal sense of 
the word. You cannot type check a value on a valueless expression. Just 
think about the implications of what a post condition on a recur form 
means. Even if you wanted to give value semantics to the evaluation of a 
recur form, there would be no single value it could check against. If you 
wanted the post condition to only be evaluated on the termination of the 
loop, or when the recur form is not conditionally present in the 
expression, then you are essentially asking the impossible for the 
compiler: it cannot know your intentions better than you do. 

On Friday, July 25, 2014 10:12:14 AM UTC-4, Michael O'Keefe wrote:
>
> Thanks Bob, Steve, and Andy. I was trying to get logged into JIRA to file 
> the bug report but I seem to be having a heck of a time -- I have a CA and 
> am signed up at dev.clojure.org but when I try to log into JIRA, it gives 
> me a nice "System Error" saying " user should not be null!". I've run out 
> of time to deal with this right now but, Steve, if you get to it before me, 
> feel free to submit the bug report.
>
> Thanks all for the helpful discussions!
>
> Michael
>
> On Friday, July 25, 2014 7:58:51 AM UTC-6, miner wrote:
>>
>> I will call it a bug.  It's definitely surprising to the user, and 
>> therefore worthy of a ticket.  On first glance, it seems that the fix isn't 
>> too hard. In core.clj where the macro fn is redefined, we just need to wrap 
>> the section that handles the post condition either with a loop* or a fn* so 
>> that the body has the proper recur target.  I'll try to make a patch and a 
>> test.  If it works, I'll file a bug with the patch.
>
>

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Ambrose Bonnaire-Sergeant
Now that Steve mentions it, I have fixed this kind of issue in my own defn
macros. IIRC adding an inner loop form did the trick.

Thanks,
Ambrose


On Fri, Jul 25, 2014 at 10:35 PM,  wrote:

> I do not believe this should be considered a bug. Recur is a special form
> that rebinds the bindings at the point of recursion with new values. It
> does not return a value. It does not get evaluated in the normal sense of
> the word. You cannot type check a value on a valueless expression. Just
> think about the implications of what a post condition on a recur form
> means. Even if you wanted to give value semantics to the evaluation of a
> recur form, there would be no single value it could check against. If you
> wanted the post condition to only be evaluated on the termination of the
> loop, or when the recur form is not conditionally present in the
> expression, then you are essentially asking the impossible for the
> compiler: it cannot know your intentions better than you do.
>
>
> On Friday, July 25, 2014 10:12:14 AM UTC-4, Michael O'Keefe wrote:
>>
>> Thanks Bob, Steve, and Andy. I was trying to get logged into JIRA to file
>> the bug report but I seem to be having a heck of a time -- I have a CA and
>> am signed up at dev.clojure.org but when I try to log into JIRA, it
>> gives me a nice "System Error" saying " user should not be null!". I've run
>> out of time to deal with this right now but, Steve, if you get to it before
>> me, feel free to submit the bug report.
>>
>> Thanks all for the helpful discussions!
>>
>> Michael
>>
>> On Friday, July 25, 2014 7:58:51 AM UTC-6, miner wrote:
>>>
>>> I will call it a bug.  It's definitely surprising to the user, and
>>> therefore worthy of a ticket.  On first glance, it seems that the fix isn't
>>> too hard. In core.clj where the macro fn is redefined, we just need to wrap
>>> the section that handles the post condition either with a loop* or a fn* so
>>> that the body has the proper recur target.  I'll try to make a patch and a
>>> test.  If it works, I'll file a bug with the patch.
>>
>>  --
> 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: Leiningen resource-paths

2014-07-25 Thread Yura Perov
Dear Thomas Heller, Dear Laurent Petit,
 

> I don't quite understand the issue against using the way I described.

 
We just did not want to have an additional dependency of Maven. For 
example, Maven should be independentally installed on Windows.

My suggestion then: instead of storing the jar files, unzip them in their 
> respective resource directories? Should solve the über jar problem if 
> Leiningen isn't too strict in filtering what's copied from resources 
> folders to final build dir. 


Yes, this is what we wanted, but on the other hand it creates too many 
files in the repository.

***

For our project we have decided to depend on Maven and require user to 
install Maven and execute these several commands to add jars to the local 
repository.

Thank you very much!

Yours faithfully,
Yura

On Thursday, July 24, 2014 5:43:57 PM UTC+1, Laurent PETIT wrote:
>
> My suggestion then: instead of storing the jar files, unzip them in their 
> respective resource directories? Should solve the über jar problem if 
> Leiningen isn't too strict in filtering what's copied from resources 
> folders to final build dir. 
>
> Le mercredi 23 juillet 2014, Yura Perov > 
> a écrit :
>
>> In my project.clj I include two jar files:
>>
>> :resource-paths ["resources/exterior_jars/forssj-optimization.jar" 
>> "resources/exterior_jars/umontreal-ssj-2.5.jar"]
>>
>> In my main.clj I import some objects from these dependencies:
>>
>> (ns myproject.main
>>   (:import [umontreal.iro.lecuyer.probdist ChiSquareDist])
>>   ...)
>>
>> So I am able to use them in main.clj:
>>
>> (println "Hello")
>> (println (. umontreal.iro.lecuyer.probdist.ChiSquareDist cdf 5 10 3.0))
>> (println "Bye")
>>
>> It perfectly works if I do lein run.
>>
>> However, if I do lein uberjar these dependencies are not included to the 
>> standalone jar file.
>>
>> I know that there exist way to use local Maven repository, but I would 
>> like to avoid this way to simplify things for anybody who wants to download 
>> the source code and compile it quickly.
>>
>> Could you advise, please, is it possible to somehow force Leiningen to 
>> include these two resources in the final standalone jar?
>>
>> Thank you.
>>
>> 

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Steve Miner
Ticket CLJ-1475 with my patch.

http://dev.clojure.org/jira/browse/CLJ-1475

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Michael O'Keefe
Adrian, thanks for your input on whether this is a bug or not. Your 
viewpoint may yet prove to be the "accepted" one but I still felt like the 
original way I wrote the function should have meant:  
 . In that sense, it feels 
like my original function g should have been semantically equivalent to 
g2... but we'll see.

Thanks for the ticket and patch, Steve! Also, I seem to now be able to 
finally log into JIRA -- I'll sign up to watch the ticket.

Anyhow, thanks everyone! We'll see what happens.

Michael

On Friday, July 25, 2014 8:41:47 AM UTC-6, Ambrose Bonnaire-Sergeant wrote:
>
> Now that Steve mentions it, I have fixed this kind of issue in my own defn 
> macros. IIRC adding an inner loop form did the trick.
>
> Thanks,
> Ambrose
>
>
> On Fri, Jul 25, 2014 at 10:35 PM, > 
> wrote:
>
>> I do not believe this should be considered a bug. Recur is a special form 
>> that rebinds the bindings at the point of recursion with new values. It 
>> does not return a value. It does not get evaluated in the normal sense of 
>> the word. You cannot type check a value on a valueless expression. Just 
>> think about the implications of what a post condition on a recur form 
>> means. Even if you wanted to give value semantics to the evaluation of a 
>> recur form, there would be no single value it could check against. If you 
>> wanted the post condition to only be evaluated on the termination of the 
>> loop, or when the recur form is not conditionally present in the 
>> expression, then you are essentially asking the impossible for the 
>> compiler: it cannot know your intentions better than you do. 
>>
>>
>> On Friday, July 25, 2014 10:12:14 AM UTC-4, Michael O'Keefe wrote:
>>>
>>> Thanks Bob, Steve, and Andy. I was trying to get logged into JIRA to 
>>> file the bug report but I seem to be having a heck of a time -- I have a CA 
>>> and am signed up at dev.clojure.org but when I try to log into JIRA, it 
>>> gives me a nice "System Error" saying " user should not be null!". I've run 
>>> out of time to deal with this right now but, Steve, if you get to it before 
>>> me, feel free to submit the bug report.
>>>
>>> Thanks all for the helpful discussions!
>>>
>>> Michael
>>>
>>> On Friday, July 25, 2014 7:58:51 AM UTC-6, miner wrote:

 I will call it a bug.  It's definitely surprising to the user, and 
 therefore worthy of a ticket.  On first glance, it seems that the fix 
 isn't 
 too hard. In core.clj where the macro fn is redefined, we just need to 
 wrap 
 the section that handles the post condition either with a loop* or a fn* 
 so 
 that the body has the proper recur target.  I'll try to make a patch and a 
 test.  If it works, I'll file a bug with the patch.
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


defprotocol's :on-interface directive

2014-07-25 Thread Tassilo Horn
Hi all,

in the JIRA issue

  
http://dev.clojure.org/jira/browse/CLJ-308?focusedCommentId=35149&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-35149

Brandon Bloom mentioned that instead of extending a protocol upon
existing interfaces using `extend` (or `extend-protocol`,
`extend-type`), one could also use a (non-documented) :on-interface
directive provided by `defprotocol` which would be much faster, and he
gave this example code:

  (defprotocol Closeable
:on-interface java.io.Closeable
(close [this]))

I have a couple of questions about that:

  1. Where's the difference between extension and using that directive,
 especially what makes it faster?

  2. If I'd want to use that, how would I add an implementation for it?
 E.g., in the case above, where would I write that closing a
 java.io.Closable should happen with (.close this)?

  3. Can the :on-interface directive also get a vector of interfaces,
 e.g., :on-interface [java.io.Closable my.other.Interface]?

Thanks,
Tassilo

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread adrian . medina
I hear what you're saying. Given that recur is a special form, there exists 
a closed set of exceptions to be worked around like this even 
theoretically, so I could see the argument for having this patch accepted 
and not opening pandora's box. 

On Friday, July 25, 2014 11:36:36 AM UTC-4, Michael O'Keefe wrote:
>
> Adrian, thanks for your input on whether this is a bug or not. Your 
> viewpoint may yet prove to be the "accepted" one but I still felt like the 
> original way I wrote the function should have meant:  
>  . In that sense, it feels 
> like my original function g should have been semantically equivalent to 
> g2... but we'll see.
>
> Thanks for the ticket and patch, Steve! Also, I seem to now be able to 
> finally log into JIRA -- I'll sign up to watch the ticket.
>
> Anyhow, thanks everyone! We'll see what happens.
>
> Michael
>
> On Friday, July 25, 2014 8:41:47 AM UTC-6, Ambrose Bonnaire-Sergeant wrote:
>>
>> Now that Steve mentions it, I have fixed this kind of issue in my own 
>> defn macros. IIRC adding an inner loop form did the trick.
>>
>> Thanks,
>> Ambrose
>>
>>
>> On Fri, Jul 25, 2014 at 10:35 PM,  wrote:
>>
>>> I do not believe this should be considered a bug. Recur is a special 
>>> form that rebinds the bindings at the point of recursion with new values. 
>>> It does not return a value. It does not get evaluated in the normal sense 
>>> of the word. You cannot type check a value on a valueless expression. Just 
>>> think about the implications of what a post condition on a recur form 
>>> means. Even if you wanted to give value semantics to the evaluation of a 
>>> recur form, there would be no single value it could check against. If you 
>>> wanted the post condition to only be evaluated on the termination of the 
>>> loop, or when the recur form is not conditionally present in the 
>>> expression, then you are essentially asking the impossible for the 
>>> compiler: it cannot know your intentions better than you do. 
>>>
>>>
>>> On Friday, July 25, 2014 10:12:14 AM UTC-4, Michael O'Keefe wrote:

 Thanks Bob, Steve, and Andy. I was trying to get logged into JIRA to 
 file the bug report but I seem to be having a heck of a time -- I have a 
 CA 
 and am signed up at dev.clojure.org but when I try to log into JIRA, 
 it gives me a nice "System Error" saying " user should not be null!". I've 
 run out of time to deal with this right now but, Steve, if you get to it 
 before me, feel free to submit the bug report.

 Thanks all for the helpful discussions!

 Michael

 On Friday, July 25, 2014 7:58:51 AM UTC-6, miner wrote:
>
> I will call it a bug.  It's definitely surprising to the user, and 
> therefore worthy of a ticket.  On first glance, it seems that the fix 
> isn't 
> too hard. In core.clj where the macro fn is redefined, we just need to 
> wrap 
> the section that handles the post condition either with a loop* or a fn* 
> so 
> that the body has the proper recur target.  I'll try to make a patch and 
> a 
> test.  If it works, I'll file a bug with the patch.

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

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


Re: Leiningen resource-paths

2014-07-25 Thread Shantanu Kumar

>
>
> For our project we have decided to depend on Maven and require user to 
> install Maven and execute these several commands to add jars to the local 
> repository.
>

You could probably have a script that uses lein-localrepo (to install all 
dependencies in one go) if you don't want to install Maven. (Sorry about 
the plug.)

https://github.com/kumarshantanu/lein-localrepo

Shantanu

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


Re: [ANN] Gorilla REPL 0.3.1

2014-07-25 Thread Paul Mooser
I've made gorilla-repl part of my normal workflow recently, and I've been 
enjoying great results. 

With this new version, I'm having trouble loading documents using the 
normal ctrl-g ctrl-l method. When I hit return after typing the path into 
the load dialog, it simply closes with no feedback or visible effect. If I 
type the path into the URL (ie, ?filename=foo/bar) it works fine. Any idea 
what might be causing this or how I might debug it more effectively ? 


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


Re: [ANN] Gorilla REPL 0.3.1

2014-07-25 Thread Jony Hudson
Hi Paul,

 glad you're finding it useful!

As for the problem: I think it's a good example of why I should stick to 
science and not dabble in UI design :-) The idea is that the text-box 
simply filters the list of options below it - it doesn't allow you to type 
in an arbitrary path. I'm guessing that it's particularly confusing in your 
case because the list of options below the box is empty?

The way it's _supposed_ to work is that Gorilla scans your project 
directory for worksheets, and lists them in the menu, and you can use the 
filter box to navigate the list quickly. I think the problem is that I've 
been too strict with the definition of "worksheet file": at the moment, it 
has to be either a ".cljw" file, or a ".clj" file with the magic Gorilla 
header as it's first line. Would I be right in thinking that your worksheet 
files don't conform to this (unannounced, possibly unwanted) convention?

I think the solution is probably for me to relax the file-naming 
convention, if that's not something people want to be forced into. I was 
worried about the time taken to open and read the header line of all the 
files in a project, but that's perhaps less of a worry now that I've 
implemented excluded directories for the file scan.

I'm rambling: the workaround is to name your worksheets *.clj, if I've 
guessed the problem correctly. The solution is probably that I should 
change the file-name criteria to be less restrictive.

Hope that helps,


Jony


On Friday, 25 July 2014 17:11:01 UTC+1, Paul Mooser wrote:
>
> I've made gorilla-repl part of my normal workflow recently, and I've been 
> enjoying great results. 
>
> With this new version, I'm having trouble loading documents using the 
> normal ctrl-g ctrl-l method. When I hit return after typing the path into 
> the load dialog, it simply closes with no feedback or visible effect. If I 
> type the path into the URL (ie, ?filename=foo/bar) it works fine. Any idea 
> what might be causing this or how I might debug it more effectively ? 
>
>
>

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


Re: [ANN] Gorilla REPL 0.3.1

2014-07-25 Thread Paul Mooser
Ah, this makes sense. I renamed my worksheets, and it finds them fine. I 
didn't understand that it was supposed to be showing me a filtered list, 
since what I was doing worked in a previous version. 

So, is there now no way to create a worksheet in a subdirectory of the 
project? I normally keep all of mine in a subdirectory. 

I have another question regarding how exceptions are rendered. If you 
happen to evaluate code which generates an exception, the displayed 
representation contains only a single line. If you try to use clojure.repl 
and do something like (pst *e), that has the same effect. I have a dumb 
workaround, but is there a way to get gorilla-repl to show me the full 
stack trace, so that I can easily debug it in-place ? 

Thanks again for all of your work on this! 

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


destructure command line arguments

2014-07-25 Thread emptya45
Hi, 

I have a main function:

(defn -main [& args]
  (let [{:keys [graph filepath title]} args]
(cond 
 (= graph "response") (graph-response filepath title)
 (= graph "requests") (graph-request filepath)
 (= graph "throughput") (graph-throughput filepath

Which I can invoke with this call:

(-main :graph "throughput" :filepath "./aggregate-report.csv")

However, when I create an uberjar and do this:

java -jar jmeter-graphs-0.1.0-standalone.jar :graph "throughput" :filepath 
"./aggregate-report.csv"

There arguments are not destructured. Is it possible to use key value pairs 
through the command line?

Many Thanks

Aidy

-- 
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: subtle om + core.async problems

2014-07-25 Thread Alexander K. Hudek
Could you describe your mixin a bit more? We’ve just written an om component 
and macro to help clean up go-blocks in cases like these. Several of our 
components take channels as input from parent components to allow for more 
sophisticated communication. We’ll post a link to this manager component today 
or tomorrow after we add some documentation.

Regarding the second problem, we don’t typically do that either. I was just 
being lazy when writing the error demo and ran into. Curious behaviour, but 
easy to avoid the problem.


From: Daniel Kersten 
Reply: clojure@googlegroups.com >
Date: July 25, 2014 at 5:26:56 AM
To: clojure@googlegroups.com >
Subject:  Re: subtle om + core.async problems  

You could simplify your fix code a small bit by using go-loop and when, like 
this:

(go-loop []
  (let [[v ch] (alts! [dump-chan (om/get-state owner :exit-chan)])]
    (when (= ch dump-chan)
      (.log js/console "dumping state:")
      (.log js/console (pr-str (om/get-state owner)))
      (recur

This won't work in your code because my-form's parent owns dump-chan, but if a 
component owns the channel, an alternative approach is to simply close 
dump-chan in IWillUnmount and change your go block to something like this:

(go-loop []
  (when-let [v ( new dom nodes out; but as the child stores the channel 
between calls to parents render, this breaks that "rule") and I've never had 
the issue.
Since base isn't being re-rendered in this case, I'm not sure why this would be 
a problem here.



On 24 July 2014 02:35, Sean Corfield  wrote:
You'll want to read this thread: 
https://groups.google.com/forum/#!topic/clojurescript/DHJvcGey8Sc

In particular:

"So if you have code that's like this, those components will want to clean up 
after themselves in IWillUnmount."

That should address your first problem?

I'm not sure what to suggest right now about the second problem.

Sean


On Jul 23, 2014, at 4:19 PM, Alexander Hudek  wrote:
I've encountered two subtle but serious problems using om with core.async.

The first one is illustrated by this code: 

https://github.com/akhudek/om-async-error

First, one obvious solution here is to move the dump-chan inside the form 
state. 
However, it's written this way to illustrate the error which originally arose 
in a 
dialog component that took both an action channel that receives button presses
and a dialog content component. It exposed the action channel in this way in 
order to be flexible. 

I believe the cause of this error is that when you toggle the form in the demo 
to off, it unmounts the component. However, the go-block is still active and
listening to the channel. When you toggle the form back on, a new component
is created and mounted. Now you have two components listening on the same
channel!

The ideal solution might be to find a way to end the go block when the component
unmounts. This is easy to do on a case by case basis, but not easy to do in a
completely generic fashion. Here is one solution:

https://github.com/akhudek/om-async-error/blob/alts-fix/src/om_async_error/core.cljs

The second problem is easy to fix, however, I don't understand why it happens.

https://github.com/akhudek/om-async-error/tree/chan-opts-bug

Instead of initializing the dump channel in the base components state, we 
initialize
it when creating the form component. As soon as you start typing into the form
the channel breaks. It was suggested on irc that this might be because of a 
re-render of base would create a new channel, but the form component will not
be re-mounted because it's already mounted. However, putting in some debug
code shows that there is no re-render of the base component occurring between
when the channel works and when it doesn't. 

I'm posting this here mostly to warn people to be wary of these situations. Of
course, if you have any suggestions or explanations for these I'd love to hear 
them.

Alex



--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google 
Groups "Clojure" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/clojure/abczlIGvogk/unsubscribe.
To unsubscribe from this group and all its topics, 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 ema

Re: destructure command line arguments

2014-07-25 Thread Tassilo Horn
empty...@gmail.com writes:

Hi!

> I have a main function:
>
> (defn -main [& args]
>   (let [{:keys [graph filepath title]} args]
> (cond 
>  (= graph "response") (graph-response filepath title)
>  (= graph "requests") (graph-request filepath)
>  (= graph "throughput") (graph-throughput filepath
>
> Which I can invoke with this call:
>
> (-main :graph "throughput" :filepath "./aggregate-report.csv")

Apparently, args is a sequence and you use map-destructuring on it.  I
wonder why that should work here.  That might just be a coincidence.

What should work is to create a map from the args seq first:

  (let [{:keys [graph filepath title]} (apply hash-map args)]
...)

Bye,
Tassilo

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


Re: ANN qarth 0.1.0, an OAuth library

2014-07-25 Thread Mike Thvedt
Hi Plínio,

Thanks for the question. I considered writing Ring handlers for Qarth, but 
since most people would either use Friend or have custom Ring handlers 
anyway, the advantage was unclear. However, Qarth was written s.t. a small 
set of auth-related methods can be adapted to any OAuth provider. This lets 
you write "OAuth agnostic" code if you don't want to use Friend.

Before I wrote Qarth, I asked around Clojure users how they handeld OAuth, 
and a lot of them wrote OAuth handling code by themselves. This didn't seem 
efficient since most people just wanted to do the same thing with 
OAuth--log in users and get a token to make requests. However, differences 
between OAuth providers made code reuse difficult, despite a few attempts 
at fixing the situation. This is the wheel I hope doesn't have to be 
reinvented.

Mike

On Friday, July 25, 2014 8:16:44 AM UTC-5, Plinio Balduino wrote:
>
> Hi, Fred
>
> I never used Friend and I don't have parameters to compare so, why Qarth?
>
> I didn't get the "Qarth's goal is to fix the problem of Ring/Compojure 
> and/or Friend apps reinventing the wheel for OAuth." explanation.
>
> Regards
>
> Plínio
>
>
> On Fri, Jul 25, 2014 at 3:47 AM, Robin Heggelund Hansen <
> skinn...@gmail.com > wrote:
>
>> I was just looking for a OAuth library, this looks great!
>>
>> kl. 19:15:11 UTC+2 torsdag 24. juli 2014 skrev Mike Thvedt følgende:
>>>
>>> Qarth is a simple interface to OAuth. Qarth's goal is to fix the problem 
>>> of Ring/Compojure and/or Friend apps reinventing the wheel for OAuth.
>>>
>>> Qarth features zero-effort Friend integration. The interactive auth flow 
>>> in "friendless" Qarth is two or three lines of code plus configuration. All 
>>> OAuth providers use the same interface, so that you can swap providers or 
>>> use "multi" providers (i.e. login with Facebook or Github) with little 
>>> additional effort.
>>>
>>> Qarth comes with out-of-the-box support for Facebook, Github, Twitter, 
>>> Google, and Yahoo!, and generic support for OAuth v2 and Scribe-Java.
>>>
>>> https://github.com/mthvedt/qarth
>>>
>>> Qarth is brand new, so please let me know about any issues or rough 
>>> edges you encounter.
>>>
>>> --Mike
>>> mike@gmail.com
>>>
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


ANN: ClojureScript 0.0-2277

2014-07-25 Thread David Nolen
ClojureScript, the Clojure compiler that emits JavaScript source code.

README and source code: https://github.com/clojure/clojurescript

New release version: 0.0-2277

Leiningen dependency information:

[org.clojure/clojurescript "0.0-2277"]

The main reason behind this release is fixing a critical issue around
the structure of the Google Closure Library which broke REPL support
in some cases.

## Enhancements
* All IEquiv implementor now export equiv Object method

## Fixes
* CLJS-824: Unsigned hash for keywords produced via keyword fn
* CLJS-827: CLJS-827: wrap macro expansion in try/catch
* CLJS-826: fix broken closure release script
* CLJS-825: conflict between node js support files
* typo in unchecked-subtract-int

-- 
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: subtle om + core.async problems

2014-07-25 Thread Daniel Kersten
The way I use mixins is really simple and might be a bit too specific to
how I currently use channels I plan to explore the idea more, but haven't
had the time yet. I'm sure you can build much more sophisticated
abstractions.

I don't have the code in front of me right now, but the basic idea is as
follows: Before om-tools, I had a subscribe function that wrapped
core.async/sub. You pass it a keyword topic, owner and a function that
takes the value as its argument. All messages on the channel take the form
[topic value]. I also had a matching unsubscribe function that took owner
and killed the go blocks created by all subscribe calls in that component.
The problem I had was that it was very easy to forgot to call unsubscribe
in IWillUnmount (plus the extra boilerplate was a bit annoying). So I wrote
a mixin that looks something like this:

(defmixin subscriber
  (will-unmount [owner]
(my-unsubscribe owner))
  (subscribe [owner topic callback]
(my-subscribe owner topic callback)))

Which can then be used like this:

(defcomponentk a-component [owner]
  (:mixins subscriber)
  (did-mount [_]
(.subscribe owner :foo (fn [v] ...)))
  (render [_]
...))


For your purposes, perhaps something like this would work:

(defmixin go-block-aware
  (init-state []
{:exit-chan (async/chan)})
  (will-unmount [owner]
   (async/put! (om/get-state owner :exit-chan) true))

  (go [owner callback]
(let [exit-chan (om/get-state owner :exit-chan)]
  (go-loop []
(let [[v ch] (async/alts! [dump-chan exit-chan])]
  (when (= ch dump-chan)
(callback v)
(recur)))

And use like this:

(defcomponentk a-component [owner]
  (:mixins go-block-aware)
  (did-mount [_]
(.go owner (fn [v] ...)))
  (render [_]
...))







On 25 July 2014 19:12, Alexander K. Hudek  wrote:

> Could you describe your mixin a bit more? We’ve just written an om
> component and macro to help clean up go-blocks in cases like these. Several
> of our components take channels as input from parent components to allow
> for more sophisticated communication. We’ll post a link to this manager
> component today or tomorrow after we add some documentation.
>
> Regarding the second problem, we don’t typically do that either. I was
> just being lazy when writing the error demo and ran into. Curious
> behaviour, but easy to avoid the problem.
>
>
> From: Daniel Kersten  
> Reply: clojure@googlegroups.com >
> 
> Date: July 25, 2014 at 5:26:56 AM
> To: clojure@googlegroups.com >
> 
> Subject:  Re: subtle om + core.async problems
>
>  You could simplify your fix code a small bit by using go-loop and when,
> like this:
>
>  (go-loop []
>   (let [[v ch] (alts! [dump-chan (om/get-state owner :exit-chan)])]
> (when (= ch dump-chan)
>   (.log js/console "dumping state:")
>   (.log js/console (pr-str (om/get-state owner)))
>   (recur
>
> This won't work in your code because my-form's parent owns dump-chan, but
> if a component owns the channel, an alternative approach is to simply close
> dump-chan in IWillUnmount and change your go block to something like this:
>
> (go-loop []
>   (when-let [v ( (.log js/console "dumping state:")
> (.log js/console (pr-str (om/get-state owner)))
> (recur)))
>
> In my own code, I've abstracted my go blocks into om-tools mixins that
> handle the killing of go blocks.
>
> I'm not sure why the second problem happens. As a general rule, I never
> create new resources in render (IMO render should be pure functional: app
> state and local state in -> new dom nodes out; but as the child stores the
> channel between calls to parents render, this breaks that "rule") and I've
> never had the issue.
> Since base isn't being re-rendered in this case, I'm not sure why this
> would be a problem here.
>
>
>
> On 24 July 2014 02:35, Sean Corfield  wrote:
>
>> You'll want to read this thread:
>> https://groups.google.com/forum/#!topic/clojurescript/DHJvcGey8Sc
>>
>> In particular:
>>
>> "So if you have code that's like this, those components will want to
>> clean up after themselves in IWillUnmount."
>>
>> That should address your first problem?
>>
>> I'm not sure what to suggest right now about the second problem.
>>
>> Sean
>>
>>
>> On Jul 23, 2014, at 4:19 PM, Alexander Hudek  wrote:
>>
>> I've encountered two subtle but serious problems using om with
>> core.async.
>>
>> The first one is illustrated by this code:
>>
>> https://github.com/akhudek/om-async-error
>>
>> First, one obvious solution here is to move the dump-chan inside the form
>> state.
>> However, it's written this way to illustrate the error which originally
>> arose in a
>> dialog component that took both an action channel that receives button
>> presses
>> and a dialog content component. It exposed the action channel in this way
>> in
>> order to be flexible.
>>
>> I believe the cause of this error is that when you toggle the form in the
>> demo
>> to off, it unmounts the component. However, th

Re: timbre logging, java libs

2014-07-25 Thread Hugo Duncan

craft.br...@gmail.com writes:

> Is there any good way to use timbre in a project with java libs, e.g. c3p0,
> that use java logging APIs?

You might want to look at:

  http://ptaoussanis.github.io/timbre/taoensso.timbre.tools.logging.html
  https://github.com/palletops/log-config#user-content-timbre-and-java-logging

If you set up tools.logging to use your preferred java logging
implementation, then timbre can log to it.

Hugo


signature.asc
Description: PGP signature


Could I get some feedback on this function?

2014-07-25 Thread Christopher Elwell
New to Clojure, how is this function that I wrote? Any suggestions for 
improvement; is it too complicated?

It filters a sequence, leaving only the first occurrence of each item in 
the seq that has a matching prefix (get-form-id-without-timestamp gets just 
the id prefix).

(defn only-keep-unique-ids [ids]
  (let [seen-ids (atom #{})
filter-fn #(let [raw-form-id (get-form-id-without-timestamp %)
 is-unique (not (contains? @seen-ids raw-form-id))]
 (do (swap! seen-ids conj raw-form-id)
 is-unique))]
(filter filter-fn ids)))



-- 
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 I get some feedback on this function?

2014-07-25 Thread boz
I'm no Clojure guru, but why not just use set?
http://grimoire.arrdem.com/1.6.0/clojure.core/set/

But you want to get rid of the timestamp. Using map is probably right for 
that. So I think this is more idiomatic...

(defn only-keep-unique-ids [ids]
  (set (map #(get-form-id-without-timestamp %) ids)))

- boz


On Friday, July 25, 2014 2:32:43 PM UTC-7, Christopher Elwell wrote:
>
> New to Clojure, how is this function that I wrote? Any suggestions for 
> improvement; is it too complicated?
>
> It filters a sequence, leaving only the first occurrence of each item in 
> the seq that has a matching prefix (get-form-id-without-timestamp gets 
> just the id prefix).
>
> (defn only-keep-unique-ids [ids]
>   (let [seen-ids (atom #{})
> filter-fn #(let [raw-form-id (get-form-id-without-timestamp %)
>  is-unique (not (contains? @seen-ids raw-form-id))]
>  (do (swap! seen-ids conj raw-form-id)
>  is-unique))]
> (filter filter-fn ids)))
>
>
>
>

-- 
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 I get some feedback on this function?

2014-07-25 Thread Ben Wolfson
On Fri, Jul 25, 2014 at 3:09 PM, boz  wrote:

> I'm no Clojure guru, but why not just use set?
> http://grimoire.arrdem.com/1.6.0/clojure.core/set/
>
> But you want to get rid of the timestamp. Using map is probably right for
> that. So I think this is more idiomatic...
>
> (defn only-keep-unique-ids [ids]
>   (set (map #(get-form-id-without-timestamp %) ids)))
>
>
That won't necessarily get the *first* one; also, it will return a set of
the prefixes, not a set of the ids that have the relevant prefixes.

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Steve Miner
My first patch was buggy with destructured args so I had to withdraw it.

While working on a better patch, I came up against a related issue: Should the 
:pre conditions apply to every recur "call". I'm saying no.  The :pre 
conditions should be checked just once on the initial function call and never 
during a recur. Any other opinions?

On Jul 25, 2014, at 10:57 AM, Steve Miner  wrote:

> Ticket CLJ-1475 with my patch.
> 
> http://dev.clojure.org/jira/browse/CLJ-1475

-- 
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: "proxy"ing PersistentHash to allow key->val and (reverse key)->val mapping

2014-07-25 Thread Geoff Little
bump!

On Thursday, July 24, 2014 9:52:48 PM UTC-4, Geoff Little wrote:
>
> I'm attempting to proxy PersistentHashmap so that "get"ting an existing 
> key or its reverse returns the same value.
>
> Here's the code that I have
>
> (defn sym-key-hash-map []
>   (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
> (valAt [key]
>(or (proxy-super valAt key)
>(proxy-super valAt (reverse key))
>
> (let [key (list 1 2)]
>   (get (assoc (sym-key-hash-map) key "sweet")
>(reverse key)))
>
> But unfortunately, the test code returns nil instead of "sweet".
>
> Does anyone with knowledge of proxy and PersistentHashmap know how to 
> solve this?
>
> Thanks.
>

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


Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Ambrose Bonnaire-Sergeant
Yes :pre should apply to every recur, like usual without :post.

user=> ((fn [a] {:pre [(number? a)]} (recur 'a)) 1)
AssertionError Assert failed: (number? a)  user/eval5376/fn--5377
(form-init687485383035947214.clj:1)

That probably means that if :post is present, the preconditions should be
moved inside the inner loop instead.

I can see how destructuring makes this a little tricky.

Thanks,
Ambrose


On Sat, Jul 26, 2014 at 6:27 AM, Steve Miner  wrote:

> My first patch was buggy with destructured args so I had to withdraw it.
>
> While working on a better patch, I came up against a related issue: Should
> the :pre conditions apply to every recur "call". I'm saying no.  The :pre
> conditions should be checked just once on the initial function call and
> never during a recur. Any other opinions?
>
> On Jul 25, 2014, at 10:57 AM, Steve Miner  wrote:
>
> > Ticket CLJ-1475 with my patch.
> >
> > http://dev.clojure.org/jira/browse/CLJ-1475
>
> --
> 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: "proxy"ing PersistentHash to allow key->val and (reverse key)->val mapping

2014-07-25 Thread Ambrose Bonnaire-Sergeant
Hi Geoff,

You probably want a sorted-map-by:

user=> (sorted-map-by (fn [a b] (or (when (every? coll? [a b]) (when (= a
(reverse b)) 0)) -1)) [1 2] 42 [2 1] 42)
{[1 2] 42}

Thanks,
Ambrose


On Fri, Jul 25, 2014 at 9:52 AM, Geoff Little  wrote:

> I'm attempting to proxy PersistentHashmap so that "get"ting an existing
> key or its reverse returns the same value.
>
> Here's the code that I have
>
> (defn sym-key-hash-map []
>   (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
> (valAt [key]
>(or (proxy-super valAt key)
>(proxy-super valAt (reverse key))
>
> (let [key (list 1 2)]
>   (get (assoc (sym-key-hash-map) key "sweet")
>(reverse key)))
>
> But unfortunately, the test code returns nil instead of "sweet".
>
> Does anyone with knowledge of proxy and PersistentHashmap know how to
> solve this?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: "proxy"ing PersistentHash to allow key->val and (reverse key)->val mapping

2014-07-25 Thread Geoff Little
Thanks so much Ambrose!  I know that function is simple, but I don't 
understand how it provides the functionality I'm after.  Do you mind 
explaining what's going on?  I'm playing with it now in my repl.

Thanks!!

On Friday, July 25, 2014 6:48:06 PM UTC-4, Ambrose Bonnaire-Sergeant wrote:
>
> Hi Geoff,
>
> You probably want a sorted-map-by:
>
> user=> (sorted-map-by (fn [a b] (or (when (every? coll? [a b]) (when (= a 
> (reverse b)) 0)) -1)) [1 2] 42 [2 1] 42)
> {[1 2] 42}
>
> Thanks,
> Ambrose
>
>
> On Fri, Jul 25, 2014 at 9:52 AM, Geoff Little  > wrote:
>
>> I'm attempting to proxy PersistentHashmap so that "get"ting an existing 
>> key or its reverse returns the same value.
>>
>> Here's the code that I have
>>
>> (defn sym-key-hash-map []
>>   (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
>> (valAt [key]
>>(or (proxy-super valAt key)
>>(proxy-super valAt (reverse key))
>>
>> (let [key (list 1 2)]
>>   (get (assoc (sym-key-hash-map) key "sweet")
>>(reverse key)))
>>
>> But unfortunately, the test code returns nil instead of "sweet".
>>
>> Does anyone with knowledge of proxy and PersistentHashmap know how to 
>> solve this?
>>
>> Thanks.
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: "proxy"ing PersistentHash to allow key->val and (reverse key)->val mapping

2014-07-25 Thread Ambrose Bonnaire-Sergeant
The function basically returns 0 if the keys are equivalent, or -1
otherwise.

It satisfies a comparator, see
http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html#compare(T,%20T)

Thanks,
Ambrose


On Sat, Jul 26, 2014 at 7:52 AM, Geoff Little  wrote:

> Thanks so much Ambrose!  I know that function is simple, but I don't
> understand how it provides the functionality I'm after.  Do you mind
> explaining what's going on?  I'm playing with it now in my repl.
>
> Thanks!!
>
>
> On Friday, July 25, 2014 6:48:06 PM UTC-4, Ambrose Bonnaire-Sergeant wrote:
>
>> Hi Geoff,
>>
>> You probably want a sorted-map-by:
>>
>> user=> (sorted-map-by (fn [a b] (or (when (every? coll? [a b]) (when (= a
>> (reverse b)) 0)) -1)) [1 2] 42 [2 1] 42)
>> {[1 2] 42}
>>
>> Thanks,
>> Ambrose
>>
>>
>> On Fri, Jul 25, 2014 at 9:52 AM, Geoff Little  wrote:
>>
>>> I'm attempting to proxy PersistentHashmap so that "get"ting an existing
>>> key or its reverse returns the same value.
>>>
>>> Here's the code that I have
>>>
>>> (defn sym-key-hash-map []
>>>   (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
>>> (valAt [key]
>>>(or (proxy-super valAt key)
>>>(proxy-super valAt (reverse key))
>>>
>>> (let [key (list 1 2)]
>>>   (get (assoc (sym-key-hash-map) key "sweet")
>>>(reverse key)))
>>>
>>> But unfortunately, the test code returns nil instead of "sweet".
>>>
>>> Does anyone with knowledge of proxy and PersistentHashmap know how to
>>> solve this?
>>>
>>> Thanks.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>>
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>>
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: "proxy"ing PersistentHash to allow key->val and (reverse key)->val mapping

2014-07-25 Thread Geoff Little
Is this comparator called when get is called?  How does this allow calling 
get on the reverse of a valid key?

Geoff

On Friday, July 25, 2014 7:58:47 PM UTC-4, Ambrose Bonnaire-Sergeant wrote:
>
> The function basically returns 0 if the keys are equivalent, or -1 
> otherwise.
>
> It satisfies a comparator, see 
> http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html#compare(T,%20T)
>
> Thanks,
> Ambrose
>
>
> On Sat, Jul 26, 2014 at 7:52 AM, Geoff Little  > wrote:
>
>> Thanks so much Ambrose!  I know that function is simple, but I don't 
>> understand how it provides the functionality I'm after.  Do you mind 
>> explaining what's going on?  I'm playing with it now in my repl.
>>
>> Thanks!!
>>
>>
>> On Friday, July 25, 2014 6:48:06 PM UTC-4, Ambrose Bonnaire-Sergeant 
>> wrote:
>>
>>> Hi Geoff,
>>>
>>> You probably want a sorted-map-by:
>>>
>>> user=> (sorted-map-by (fn [a b] (or (when (every? coll? [a b]) (when (= 
>>> a (reverse b)) 0)) -1)) [1 2] 42 [2 1] 42)
>>> {[1 2] 42}
>>>
>>> Thanks,
>>> Ambrose
>>>
>>>
>>> On Fri, Jul 25, 2014 at 9:52 AM, Geoff Little  wrote:
>>>
 I'm attempting to proxy PersistentHashmap so that "get"ting an existing 
 key or its reverse returns the same value.

 Here's the code that I have

 (defn sym-key-hash-map []
   (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
 (valAt [key]
(or (proxy-super valAt key)
(proxy-super valAt (reverse key))

 (let [key (list 1 2)]
   (get (assoc (sym-key-hash-map) key "sweet")
(reverse key)))

 But unfortunately, the test code returns nil instead of "sweet".

 Does anyone with knowledge of proxy and PersistentHashmap know how to 
 solve this?

 Thanks.

 -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com

 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com

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

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

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

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


Re: "proxy"ing PersistentHash to allow key->val and (reverse key)->val mapping

2014-07-25 Thread Ambrose Bonnaire-Sergeant
Right, it doesn't.

user=> (get (sorted-map-by (fn [a b] (or (when (every? coll? [a b]) (when
(= a (reverse b)) 0)) -1)) [1 2] 42 [2 1] 42) [2 1])
42
user=> (get (sorted-map-by (fn [a b] (or (when (every? coll? [a b]) (when
(= a (reverse b)) 0)) -1)) [1 2] 42 [2 1] 42) [1 2])
nil

Sorry about that. Check out def-map-type here:
https://github.com/ztellman/potemkin

Thanks,
Ambrose


On Sat, Jul 26, 2014 at 8:00 AM, Geoff Little  wrote:

> Is this comparator called when get is called?  How does this allow calling
> get on the reverse of a valid key?
>
> Geoff
>
>
> On Friday, July 25, 2014 7:58:47 PM UTC-4, Ambrose Bonnaire-Sergeant wrote:
>
>> The function basically returns 0 if the keys are equivalent, or -1
>> otherwise.
>>
>> It satisfies a comparator, see http://docs.oracle.com/
>> javase/7/docs/api/java/util/Comparator.html#compare(T,%20T)
>>
>> Thanks,
>> Ambrose
>>
>>
>> On Sat, Jul 26, 2014 at 7:52 AM, Geoff Little  wrote:
>>
>>> Thanks so much Ambrose!  I know that function is simple, but I don't
>>> understand how it provides the functionality I'm after.  Do you mind
>>> explaining what's going on?  I'm playing with it now in my repl.
>>>
>>> Thanks!!
>>>
>>>
>>> On Friday, July 25, 2014 6:48:06 PM UTC-4, Ambrose Bonnaire-Sergeant
>>> wrote:
>>>
 Hi Geoff,

 You probably want a sorted-map-by:

 user=> (sorted-map-by (fn [a b] (or (when (every? coll? [a b]) (when (=
 a (reverse b)) 0)) -1)) [1 2] 42 [2 1] 42)
 {[1 2] 42}

 Thanks,
 Ambrose


 On Fri, Jul 25, 2014 at 9:52 AM, Geoff Little 
 wrote:

> I'm attempting to proxy PersistentHashmap so that "get"ting an
> existing key or its reverse returns the same value.
>
> Here's the code that I have
>
> (defn sym-key-hash-map []
>   (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
> (valAt [key]
>(or (proxy-super valAt key)
>(proxy-super valAt (reverse key))
>
> (let [key (list 1 2)]
>   (get (assoc (sym-key-hash-map) key "sweet")
>(reverse key)))
>
> But unfortunately, the test code returns nil instead of "sweet".
>
> Does anyone with knowledge of proxy and PersistentHashmap know how to
> solve this?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
>
> Note that posts from new members are moderated - please be patient
> with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+u...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
>

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

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

Re: Could I get some feedback on this function?

2014-07-25 Thread Ben Wolfson
I'd probably write this like so, fwiw (parameterized by the transformation
function):

user> (defn only-keep-unique-ids [id-transform ids]
(map first (vals (group-by id-transform ids
#'user/only-keep-unique-ids
user> (only-keep-unique-ids (partial take 2) ["aaa" "baa" "xsdf" "aa3"
"ba4" "azx" "aa4" "xsss"])
("aaa" "baa" "xsdf" "azx")

it's not lazy, though.



On Fri, Jul 25, 2014 at 2:32 PM, Christopher Elwell <
elwell.christop...@gmail.com> wrote:

> New to Clojure, how is this function that I wrote? Any suggestions for
> improvement; is it too complicated?
>
> It filters a sequence, leaving only the first occurrence of each item in
> the seq that has a matching prefix (get-form-id-without-timestamp gets
> just the id prefix).
>
> (defn only-keep-unique-ids [ids]
>   (let [seen-ids (atom #{})
> filter-fn #(let [raw-form-id (get-form-id-without-timestamp %)
>  is-unique (not (contains? @seen-ids raw-form-id))]
>  (do (swap! seen-ids conj raw-form-id)
>  is-unique))]
> (filter filter-fn ids)))
>
>
>
>  --
> 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.
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
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 I get some feedback on this function?

2014-07-25 Thread Paul L. Snyder
On Fri, 25 Jul 2014, Christopher Elwell wrote:

> New to Clojure, how is this function that I wrote? Any suggestions for
> improvement; is it too complicated?

'filter' is a great tool to reach for in many cases, but (as you found)
it's not ideal if you need your test predicate to change as it processes
the sequence. This results in the most non-idiomatic part of your code:
the use of the atom.

Three typical ways to build up state via one or more accumulators as you
work your way through a seq are:

  (1) reduce, supplying empty collections for your accumulators' bases;
  (2) recursion via loop/recur, introducing the accumulators in the loop
  declaration; or
  (3) a lazy sequence using a similar recursive strategy.

> It filters a sequence, leaving only the first occurrence of each item
> in the seq that has a matching prefix (get-form-id-without-timestamp
> gets just the id prefix).
>
> (defn only-keep-unique-ids [ids]
>   (let [seen-ids (atom #{})
> filter-fn #(let [raw-form-id (get-form-id-without-timestamp %)
>  is-unique (not (contains? @seen-ids raw-form-id))]
>  (do (swap! seen-ids conj raw-form-id)
>  is-unique))]
> (filter filter-fn ids)))

Here's an example of strategy #1: 'seen' collects the keys encountered (as
determined by a passed-in function 'f') and is also used as a predicate if
the 'if', while 'ret' builds up a vector containing the full items as they
are encountered.

user> (defn unique-by [f coll]
(second
 (reduce (fn [[seen ret] val]
  (let [key (f val)]
(if (seen key)
[seen ret]
[(conj seen key) (conj ret val)])))
 [#{} []]
 coll)))
#'user/unique-by


Since reduce is not lazy, this will process the entire sequence immediately
and then return a vector of the results:

user> (defn prefix [st]
(subs st 0 3))
#'user/prefix
user> (unique-by prefix ["foobar" "foobaz" "wombat" "womble"])
["foobar" "wombat"]


For comparison, here's a lazy implementation (strategy #3):

user> (defn unique-by
([f coll]
   ((fn step [f coll seen]
  (lazy-seq
   (when-let [[val & vals] (seq coll)]
 (let [key (f val)]
   (if (seen key)
 (step f vals seen)
 (cons val (step f vals (conj seen key
f coll #{})))
#'user/unique-by
user> (unique-by prefix ["foobar" "foobaz" "wombat" "womble"])
("foobar" "wombat")

Since this is fully lazy, you can use it on infinite sequences...but the
example below will be non-terminating if you try to take 3 or more items
from the resulting sequence!

user> (take 2 (unique-by prefix (cycle ["foobar" "foobaz" "wombat" "womble"])))
("foobar" "wombat")


Note that the version in your message is also lazy, since it relies on 'filter'
to do the processing.

Hope this helps! I'd recommend trying to implement strategy #2 yourself
using the above as models, as this pattern is one that you can expect to
encounter frequently. Clojure idioms tend to favor 'reduce' over 'loop/recur',
but I've found that there are situations where the latter can result in more
readable code.

Paul

P.S.: I saw Ben's suggestion using 'group-by' right before sending this...it's
a great example of how far you can get using just the standard sequence
functions.

-- 
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: cassius 0.1.14] - Cassandra as a Big Nested Map

2014-07-25 Thread zcaudate
I'm happy to announce that the team at MyPost (https://*digitalmailbox*
.com.au/) has decided to release a library that we have been working on for 
the past couple of months.

https://github.com/MyPost/cassius

Apparently its `also only the second release of open source software by a 
public sector organisation in Australia`
 (http://www.andykelk.net/tech/open-sourcing-our-work-why-were-doing-it)


Overview

Cassius is a clojure wrapper around cassandra's thrift interface. It treats 
cassandra as a big mutable nested hashmap and provides the following 
abstractions:

   - cassandra data and schema can be represented as values and clojure 
   maps.
   - keyspaces, column families, rows and columns can be abstracted as 
   nested map layers
   - supercolumns are just one extra level of nesting

The library has been used for both mocking and for higher level 
abstractions on top of cassandra. An ORM has been built and used internally 
at MyPost 
 to 
deal with legacy cassandra data.
Motivation

The library was motivated by an inability to reason about what changes the 
existing monolithic system was doing to the underlying database. In order 
to move away from the existing system into more agile architecture, the 
team had to be careful about reworking features without breaking 
functionality. The typical work of code migration would end up looking 
something like this:

   1. Get the current state of the DB
   2. Run some legacy code (java)
   3. See what has changed in the DB
   4. Rewrite that change in clojure

cassius was designed as a tool for developers to reason about and test 
changes to cassandra. It also has the following features:

   - Written in thrift in order to support supercolumns in the legacy 
   system.
   - Abstracts the database in such a way that tests are easy to write and 
   easy to read.
   - Uses of conditional restarts for more control of error states.
   - Option to use the component/Lifecycle framework. Mock DB is included 
   for testing purposes.
   - Uses the Hashmap as a protocol, defined in cassius.protocols/IMap.
  - Methods: put-in, peek-in, keys-in, drop-in, set-in, select-in and 
  mutate-in
   


The repo is here: https://github.com/MyPost/cassius

Please have a play!

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


Help Getting Sente to Work

2014-07-25 Thread Timothy Washington
Hi all,

I'm using [com.taoensso/sente "0.15.1"
], and having trouble connecting the
client to the server. I'm sure it's something simple, but not obvious, as
this is taken directly from the examples on sente's github page. Anyone
seen and fixed the error in fig.1? The clojurescript and clojure code are
in fig 2 and 3 respectively.


WebSocket connection to 'ws://172.28.128.5:58269/chsk' failed: Error during
WebSocket handshake: Unexpected response code: 404
 WebSocket error: [object Event] VM1707:1689
 Chsk is closed: will try reconnect (8). VM1707:1689

fig.1 - Chrome network error message

(ns my.ns
  (:require-macros
   [cljs.core.match.macros :refer (match)] ; Optional, useful
   [cljs.core.async.macros :as asyncm :refer (go go-loop)])
  (:require
   ;;[clojure.browser.repl :as repl]
   [cljs.core.match] ; Optional, useful
   [cljs.core.async :as async :refer (! put! chan)]
   [taoensso.sente :as sente :refer (cb-success?)]))


(let [{:keys [chsk ch-recv send-fn state]}
  (sente/make-channel-socket! "/chsk" {:type :auto})]

  (def chsk   chsk)
  (def ch-chskch-recv)
  (def chsk-send! send-fn)
  (def chsk-state state))

(defn one []
  (chsk-send! [:some/request-id {:name "Rich Hickey" :type "Awesome"}]))


*fig.2 - my.cljs *


(ns my.http.ns
  (:require [compojure.core :refer :all]
...

;; Sente stuff
[clojure.core.match :as match :refer (match)] ; Optional, useful
[clojure.core.async :as async :refer (! >!! put! chan
go go-loop)]
[taoensso.sente :as sente]))


(let [{:keys [ch-recv send-fn ajax-post-fn ajax-get-or-ws-handshake-fn]}
  (sente/make-channel-socket! {})]

  (def ring-ajax-postajax-post-fn)
  (def ring-ajax-get-or-ws-handshake ajax-get-or-ws-handshake-fn)
  (def ch-chsk   ch-recv)
  (def chsk-send!send-fn))

...

(defn create-approutes [project-config browserrepl]

  (defroutes app-routes

;; Sente stuff
(GET  "/chsk" req (ring-ajax-get-or-ws-handshake req)) ; tried both
ring-ajax-get-or-ws-handshake and *#'*ring-ajax-get-or-ws-handshake
(POST "/chsk" req (ring-ajax-postreq)); same
here for trying both


(GET "/" []
 (-> (ring-resp/response (with-browser-repl "index.html"
browserrepl))
 (ring-resp/content-type "text/html")))

(route/resources "/" {:root "resources/public/"})
(route/not-found "Not Found")))

*fig.3 - my.clj *


Tim Washington
Interruptsoftware.com 

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


Re: Help Getting Sente to Work

2014-07-25 Thread Daniel Kersten
My server looks like this and its been working for me for the past few
months without issue:

(defroutes ws-routes
  (GET  "/cmd/chsk" req (ring-ajax-get-or-ws-handshake req))
  (POST "/cmd/chsk" req (ring-ajax-postreq)))





(defn run

  [& [routes]]

  (let [site  (http-handler/site (compojure/routes ws-routes routes))
webserver (httpkit/run-server site {:port 3002})
{:keys [ch-recv send-fn ajax-post-fn ajax-get-or-ws-handshake-fn
connected-uids]} (sente/make-channel-socket! {})]
(def ring-ajax-postajax-post-fn)
(def ring-ajax-get-or-ws-handshake ajax-get-or-ws-handshake-fn)
(def ch-chsk   ch-recv) ; ChannelSocket's
receive channel
(def chsk-send!send-fn) ; ChannelSocket's send API fn
(def connected-uidsconnected-uids) ; Watchable,
read-only atom
(def server webserver)
(sente/start-chsk-router-loop! sente-message-router ch-chsk)
webserver))



Where sente-message-router is a function that receives messages from the
client.

In my actual codebase, there is a little more additional code for setting
up client-id's and CSRF tokens too.

On 26 July 2014 05:33, Timothy Washington  wrote:

> Hi all,
>
> I'm using [com.taoensso/sente "0.15.1"
> ], and having trouble connecting
> the client to the server. I'm sure it's something simple, but not obvious,
> as this is taken directly from the examples on sente's github page. Anyone
> seen and fixed the error in fig.1? The clojurescript and clojure code are
> in fig 2 and 3 respectively.
>
>
> WebSocket connection to 'ws://172.28.128.5:58269/chsk' failed: Error
> during WebSocket handshake: Unexpected response code: 404
>  WebSocket error: [object Event] VM1707:1689
>  Chsk is closed: will try reconnect (8). VM1707:1689
>
> fig.1 - Chrome network error message
>
> (ns my.ns
>   (:require-macros
>[cljs.core.match.macros :refer (match)] ; Optional, useful
>[cljs.core.async.macros :as asyncm :refer (go go-loop)])
>   (:require
>;;[clojure.browser.repl :as repl]
>[cljs.core.match] ; Optional, useful
>[cljs.core.async :as async :refer (! put! chan)]
>[taoensso.sente :as sente :refer (cb-success?)]))
>
>
> (let [{:keys [chsk ch-recv send-fn state]}
>   (sente/make-channel-socket! "/chsk" {:type :auto})]
>
>   (def chsk   chsk)
>   (def ch-chskch-recv)
>   (def chsk-send! send-fn)
>   (def chsk-state state))
>
> (defn one []
>   (chsk-send! [:some/request-id {:name "Rich Hickey" :type "Awesome"}]))
>
>
> *fig.2 - my.cljs *
>
>
> (ns my.http.ns
>   (:require [compojure.core :refer :all]
> ...
>
> ;; Sente stuff
> [clojure.core.match :as match :refer (match)] ; Optional,
> useful
> [clojure.core.async :as async :refer (! >!! put! chan
> go go-loop)]
> [taoensso.sente :as sente]))
>
>
> (let [{:keys [ch-recv send-fn ajax-post-fn ajax-get-or-ws-handshake-fn]}
>   (sente/make-channel-socket! {})]
>
>   (def ring-ajax-postajax-post-fn)
>   (def ring-ajax-get-or-ws-handshake ajax-get-or-ws-handshake-fn)
>   (def ch-chsk   ch-recv)
>   (def chsk-send!send-fn))
>
> ...
>
> (defn create-approutes [project-config browserrepl]
>
>   (defroutes app-routes
>
> ;; Sente stuff
> (GET  "/chsk" req (ring-ajax-get-or-ws-handshake req)) ; tried both
> ring-ajax-get-or-ws-handshake and *#'*ring-ajax-get-or-ws-handshake
> (POST "/chsk" req (ring-ajax-postreq)); same
> here for trying both
>
>
> (GET "/" []
>  (-> (ring-resp/response (with-browser-repl "index.html"
> browserrepl))
>  (ring-resp/content-type "text/html")))
>
> (route/resources "/" {:root "resources/public/"})
> (route/not-found "Not Found")))
>
> *fig.3 - my.clj *
>
>
> Tim Washington
> Interruptsoftware.com 
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

[ANN] nginx-clojure v0.2.4 released

2014-07-25 Thread Yuexiang Zhang
Nginx-Clojure  is a Nginx 
module for embedding Clojure / Java / Groovy programs, typically those Ring 
based handlers.

Release 0.2.4 contains  important updates


   1. New Feature: Support Groovy - another dynamic jvm language (issue #34)
   2. Fix bug: Slow Memory Leak for Coroutine based Socket bug (issue #32 )
   3. Fix bug: Should Clone ThreadLocals for Coroutines (issue #31)
   4. New Feature: More friendly to java users who maybe know nothing about 
   clojure feature (issue #29)
   5. Five new nginx directives `handler_type`, `handler_name`, 
   `handler_code`, `rewrite_handler_name`, `rewrite_handler_code`.  Make 
   Clojure/Java/Groovy handler configurations have the same form. e.g. The old 
   pair of nginx directives `clojure`, `clojure_code` is equivalent to 
   `handler_type='clojure'` + `handler_code`.



The binary release (support win32, linux x86 32bit, linux x64, macosx) can 
be found from https://sourceforge.net/projects/nginx-clojure/files/
The source files and guide can be found from 
https://github.com/nginx-clojure/nginx-clojure/blob/master/README.md
The index page for guide can be found from 
https://github.com/nginx-clojure/nginx-clojure/wiki

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