Re: Need help in geeting cemerick/friend working with openid

2012-12-19 Thread Chas Emerick
Murtaza,

First, you need to either

(a) :allow-anon? false in the configuration map you provide to 
friend/authenticate — it is true by default, or
(b) Use an authorization guard (which can include friend/authenticated, which 
reuses the authorization mechanism to ensure that only authenticated users' 
requests can cause the enclosed code to be evaluated)

Either option will redirect to whatever you have configured as :login-uri 
(default "/login").

Also, openid-uri is not where the provider's URI goes; that's what configures 
the URI that the OpenId workflow is bound to e.g. for receiving the redirect 
from the provider after the user has authenticated with them.  So, you'd want 
:openid-uri to be something like "/openid".

It is generally the case that the OpenId workflow is initiated by the user by 
clicking on one of a couple of different buttons, or specifying their OpenId 
URL manually.  This is what you would put on the /login page.  You can see 
different takes on this this at http://www.clojureatlas.com/login and 
http://stackoverflow.com/users/login.

I suppose you *could* start the OpenId workflow automatically, but that might 
be a jarring experience for your users: because you can't control the 
presentation / branding of the OpenId provider's authentication flow, 
unauthenticated users may get confused, or think they've wandered into an 
attempt to obtain their e.g. Google credentials.  However, I can see use cases 
for this — maybe when the users know a particular site always uses credentials 
from a particular site, or for internal apps where an OpenId SSO is ubiquitous 
and expected.

FWIW, I'll add an example for that option (as well as the more common 
form-initiated style) to the set of example applications I'm slowly building 
for Friend:

https://friend-demo.herokuapp.com/

I haven't publicly announced that app/effort yet — mostly because I want to get 
a certain minimum number of example apps spiked out with non-hideous 
presentation before blowing the trumpets.

Anyway, I hope the content above is helpful.  Let me know if you have any other 
questions...

Cheers,

- Chas

On Dec 19, 2012, at 2:59 AM, Murtaza Husain wrote:

> Hi,
> 
> I am trying to setup my authentication using cemerick/friend. I would like to 
> authenticate using openid with gmail. 
> 
> Below is the code that I have - 
> 
> (ns faiz.handler
>   (:use compojure.core)
>   (:require [compojure.handler :as handler]
> [compojure.route :as route]
> [ring.util.response :as resp]
> [me.shenfeng.mustache :as mustache]
> [cemerick.friend :as friend]
> (cemerick.friend [workflows :as workflows]
>  [credentials :as creds]
>  [openid :as openid])))
> 
> (mustache/deftemplate index (slurp "public/index-async.html"))
> 
> (def index-data {:title "Invoize." :brand "Faiz" :links [{:url "#/students" 
> :text "Students"} {:url "#/thaalis" :text "Thaalis"}]})
> 
> 
> 
> 
> (defroutes app-routes
>   (GET "/" [] (resp/redirect "/landing"))
>   (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
>   (GET "/index" [] (index index-data))
>   (route/files "/" {:root "public"})
>   (route/not-found "Not Found"))
> 
> (def mock-app
>   (-> app-routes
>   (friend/authenticate
>{:workflows [(openid/workflow :openid-uri 
> "https://www.google.com/accounts/o8/id"; :realm "http://invoize.com";)]})))
> 
> (def app
>   (handler/site app-routes))
> 
> My expectation is that when I try to access the "/index" or "/landing" url, 
> it should not allow me as I am not authenticated and redirect to the 
> openid-url,however this does not happen. How do I achieve it ?
> 
> Thanks,
> Murtaza
> 
> 
> -- 
> 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 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

Re: Need help in geeting cemerick/friend working with openid

2012-12-19 Thread Murtaza Husain
Chas,
 
Thanks for the great library and appreciate your taking the time to answer !

1) I have included the key/val - :allow-anon? false - in the 
friend/authenticate options map, but I am still able to access all my urls 
without any redirection. 

2) I have also set the :openid-url "/openid". I am assuming friend creates 
a compujure route for this internally. However when I post to the '/openid' 
url I get a 404 error.

Below is my updated code -

(ns faiz.handler
  (:use compojure.core)
  (:require [compojure.handler :as handler]
[compojure.route :as route]
[ring.util.response :as resp]
[me.shenfeng.mustache :as mustache]
[cemerick.friend :as friend]
(cemerick.friend [workflows :as workflows]
 [credentials :as creds]
 [openid :as openid])))

(mustache/deftemplate index (slurp "public/index-async.html"))

(def index-data {:title "Invoize." :brand "Faiz" :links [{:url "#/students" 
:text "Students"} {:url "#/thaalis" :text "Thaalis"}]})

(defroutes app-routes
  (GET "/" [] (resp/redirect "/landing"))
  (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
  (GET "/index" [] (index index-data))
  (route/files "/" {:root "public"})
  (route/not-found "Not Found"))

(def mock-app
  (-> app-routes
  (friend/authenticate
   {:allow-anon? false
:login-uri? "/landing"
:workflows [(openid/workflow :openid-uri "/openid" :realm 
"http://invoize.com";)]})))

(def app
  (handler/site app-routes))

Thanks,
Murtaza

On Wednesday, December 19, 2012 3:37:27 PM UTC+5:30, Chas Emerick wrote:
>
> Murtaza,
>
> First, you need to either
>
> (a) :allow-anon? false in the configuration map you provide to 
> friend/authenticate — it is true by default, or
> (b) Use an authorization guard (which can include friend/authenticated, 
> which reuses the authorization mechanism to ensure that only authenticated 
> users' requests can cause the enclosed code to be evaluated)
>
> Either option will redirect to whatever you have configured as :login-uri 
> (default "/login").
>
> Also, openid-uri is not where the provider's URI goes; that's what 
> configures the URI that the OpenId workflow is bound to e.g. for receiving 
> the redirect from the provider after the user has authenticated with them. 
>  So, you'd want :openid-uri to be something like "/openid".
>
> It is generally the case that the OpenId workflow is initiated by the user 
> by clicking on one of a couple of different buttons, or specifying their 
> OpenId URL manually.  This is what you would put on the /login page.  You 
> can see different takes on this this at http://www.clojureatlas.com/loginand 
> http://stackoverflow.com/users/login.
>
> I suppose you *could* start the OpenId workflow automatically, but that 
> might be a jarring experience for your users: because you can't control the 
> presentation / branding of the OpenId provider's authentication flow, 
> unauthenticated users may get confused, or think they've wandered into an 
> attempt to obtain their e.g. Google credentials.  However, I can see use 
> cases for this — maybe when the users know a particular site always uses 
> credentials from a particular site, or for internal apps where an OpenId 
> SSO is ubiquitous and expected.
>
> FWIW, I'll add an example for that option (as well as the more common 
> form-initiated style) to the set of example applications I'm slowly 
> building for Friend:
>
> https://friend-demo.herokuapp.com/
>
> I haven't publicly announced that app/effort yet — mostly because I want 
> to get a certain minimum number of example apps spiked out with non-hideous 
> presentation before blowing the trumpets.
>
> Anyway, I hope the content above is helpful.  Let me know if you have any 
> other questions...
>
> Cheers,
>
> - Chas
>
> On Dec 19, 2012, at 2:59 AM, Murtaza Husain wrote:
>
> Hi,
>
> I am trying to setup my authentication using cemerick/friend. I would like 
> to authenticate using openid with gmail. 
>
> Below is the code that I have - 
>
> (ns faiz.handler
>   (:use compojure.core)
>   (:require [compojure.handler :as handler]
> [compojure.route :as route]
> [ring.util.response :as resp]
> [me.shenfeng.mustache :as mustache]
> [cemerick.friend :as friend]
> (cemerick.friend [workflows :as workflows]
>  [credentials :as creds]
>  [openid :as openid])))
>
> (mustache/deftemplate index (slurp "public/index-async.html"))
>
> (def index-data {:title "Invoize." :brand "Faiz" :links [{:url 
> "#/students" :text "Students"} {:url "#/thaalis" :text "Thaalis"}]})
>
>
>
>
> (defroutes app-routes
>   (GET "/" [] (resp/redirect "/landing"))
>   (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
>   (GET "/index" [] (index index-data))
>   (route/files "/" {:root "public"})
>   (route/not-f

Re: Need help in geeting cemerick/friend working with openid

2012-12-19 Thread Aaron Cohen
On Wed, Dec 19, 2012 at 8:40 AM, Murtaza Husain <
murtaza.hus...@sevenolives.com> wrote:
>
> (defroutes app-routes
>   (GET "/" [] (resp/redirect "/landing"))
>   (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
>   (GET "/index" [] (index index-data))
>   (route/files "/" {:root "public"})
>   (route/not-found "Not Found"))
>
> (def mock-app
>   (-> app-routes
>   (friend/authenticate
>{:allow-anon? false
> :login-uri? "/landing"
> :workflows [(openid/workflow :openid-uri "/openid" :realm "
> http://invoize.com";)]})))
>
>

I'm not fully conversant with all the libraries, but don't you actually
need to use mock-app somewhere?


> (def app
>   (handler/site app-routes))
>
>

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

Two clojure with emacs questions

2012-12-19 Thread Jonathon McKitrick
1.  Can emacs with swank dynamically update Noir code running locally, or 
do I need to save the code and then 'lein run' to see the new result?

2.  When trying (in-ns ...) and a few other commands from emacs, nRepl 
hangs consistently.  Is this user error?

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

Re: Two clojure with emacs questions

2012-12-19 Thread Tassilo Horn
Jonathon McKitrick  writes:

Hi Jonathon,

> 1.  Can emacs with swank dynamically update Noir code running locally,
> or do I need to save the code and then 'lein run' to see the new
> result?

Without ever having used Noir, I would assume you can hack on the living
instance at the REPL.

> 2.  When trying (in-ns ...) and a few other commands from emacs, nRepl
> hangs consistently.  Is this user error?

Uhm, now do you use SLIME/swank, or do you use nrepl.el/nREPL?  (Aside
from that, neither should hang on (in-ns ...).)

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


Re: [ANN] CJD 0.1.0, a documentation technology for Clojure programs

2012-12-19 Thread greenh
Yes, no argument, this is a problem, and I'm open to suggestions for 
solving it.

As an aside, I personally don't find it to be a problem, as pretty much all 
of my documentation needs tend to be fulfilled by browser-based mechanisms, 
and my use of docstrings in a running system is negligible. That 
notwithstanding, I'm entirely sensitive to the fact that not everyone does 
it my way... so the notion of tying it into the existing state of affairs 
is entirely reasonable.

Anyway, I'm thinking about it...

-- Howard


On Tuesday, December 18, 2012 2:47:59 PM UTC-8, FrankS wrote:
>
> It sure looks very nice! 
>
> … but doesn't your use of #_ preclude us from getting that doc-info in the 
> running system? 
>
> In other words, how would you enhance the doc facility in the repl to 
> pickup your doc-meta-data in real-time? 
>
> -FrankS. 
>
>
> On Dec 18, 2012, at 11:10 PM, greenh > 
> wrote: 
>
> > I'd like to announce the availability of CJD 0.1.0. 
> > 
> > CJD is a technology for documenting Clojure programs which I devised to 
> satisfy my idiosyncratic documentation-related propensities. It's mostly 
> complete, so I thought I'd share it with the community just in case there 
> are any fellow travelers with similar inclinations. 
> > 
> > CJD makes use of structured comments embedded in Clojure source code in 
> a fashion inspired by Javadoc, to which it bears a superficial similarity. 
> Like Javadoc, CJD comments support a simple form of markup that not only 
> can add formatting detail but also provides a modicum of metadata that 
> describes what's being documented. This allows CJD's processing facility to 
> extract the documentation content from collections of Clojure namespaces 
> and convert it into trees of consistently-formatted HTML documents. Thus, 
> CJD comments represent a much more expressive alternative or supplement to 
> docstrings. 
> > 
> > Ground zero for CJD is its home on GitHub, which includes a FAQ that 
> provides a reasonably concise overview and rationale for CJD, and a user's 
> guide that represents a first-pass attempt at describing the gory details. 
> > 
> > Needless to say, CJD uses CJD for its own program documentation. You can 
> see the output of a representative namespace in your choice of 
> light-background and dark-background (my favorite!) renderings, and the 
> source from which it was generated here. 
> > 
> > Here's a few additional points about CJD. You'll get all these and more 
> from the links above, but just in case your interest hasn't already been 
> piqued… 
> > 
> > • Documentation comments generally consist largely of ordinary 
> text, so they're easily readable in source form. Required additions for 
> markup and escape sequences tend to be fairly minimal. 
> > • Markup is structured in terms of syntactically valid Clojure 
> forms, allowing Clojure-aware editors to be used to good advantage. 
> > • A recursively-defined documentation syntax allows Clojure's 
> recursively-defined data structures and functions to be documented to 
> whatever depth is needful. 
> > • Structure-aware support for documenting core Clojure artifacts 
> (vars, functions, macros, protocols, records, etc.) is available right out 
> of the box. CJD also provides facilities for extensions that allow 
> user-defined artifacts to be compatibly documented. 
> > • Recognizing the value of richly-linked documentation, CJD 
> tries to make it easy to link to other artifacts' documentation, both 
> within and external to a project. 
> > • What does and doesn't get documented, and to what extent, is 
> entirely at the developer's discretion. No pressure, no complaints—CJD 
> happily accepts whatever scraps of documentation you throw its way. 
> > And, it's available from Clojars, it includes a plugin that works with 
> both the 1.x and 2.x versions Leiningen, it runs from the REPL, and there's 
> even support for all you command-line enthusiasts out there. 
> > 
> > Enjoy! 
> > 
> > --- Howard 
> > 
> > 
> > 
> > 
> > -- 
> > 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 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

Re: Two clojure with emacs questions

2012-12-19 Thread Jonathon McKitrick
Hi Tassilo

> 1.  Can emacs with swank dynamically update Noir code running locally, 

> > or do I need to save the code and then 'lein run' to see the new 
> > result? 
>
> Without ever having used Noir, I would assume you can hack on the living 
> instance at the REPL. 
>

I was wondering if I could make changes in emacs, C-c C-k, and refresh the 
web page to see the results.
 

>
> > 2.  When trying (in-ns ...) and a few other commands from emacs, nRepl 
> > hangs consistently.  Is this user error? 
>
> Uhm, now do you use SLIME/swank, or do you use nrepl.el/nREPL?  (Aside 
> from that, neither should hang on (in-ns ...).) 
>

Hmm, I guess I have migrated to nrepl as the backend to emacs.  I'm using 
nrepl-jack-in.
 

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

Re: abysmal multicore performance, especially on AMD processors

2012-12-19 Thread Wm. Josiah Erikson
So here's what we came up with that clearly demonstrates the problem. Lee
provided the code and I tweaked it until I believe it shows the problem
clearly and succinctly.

I have put together a .tar.gz file that has everything needed to run it,
except lein. Grab it here: clojush_bowling_benchmark.tar.gz

Then run, for instance: /usr/bin/time -f %E lein run
clojush.examples.benchmark-bowling

and then, when that has finished, edit
src/clojush/examples/benchmark_bowling.clj and uncomment
":use-single-thread true" and run it again. I think this is a succinct,
deterministic benchmark that clearly demonstrates the problem and also
doesn't use conj or reverse. We don't see slowdowns, but I cannot get any
better than around 2x speedup on any hardware with this benchmark.

I hope this helps people get to the bottom of things.

-Josiah


On Sun, Dec 16, 2012 at 4:54 PM, Lee Spector  wrote:

>
> On Dec 14, 2012, at 10:41 PM, cameron wrote:
> > Until Lee has a representative benchmark for his application it's
> difficult to tell if he's
> > experiencing the same problem but there would seem to be a case for
> changing the PersistentList
> > implementation in clojure.lang.
>
> We put together a version of our application in which we just replaced all
> of the random calls with deterministic functions (returning either
> constants or deterministic functions of their arguments).
>
> What we saw was a maximum speedup of less than x2 on a 48 core machine,
> which was interesting in part because the determinism meant that only a
> tiny subset of our code was being executed (because all of the Push
> programs in the population were identical and used only a single Push
> instruction). So I think that this may indeed help us to hone in on the
> problem.
>
> Before we share that code, however, we should make sure that the
> evaluations that are being done concurrently are sufficiently long-running,
> and maybe tweak a couple of other things. I think we'll have a chance to do
> that early in the week and we'll share the results/code when we do.
>
> Thanks,
>
>  -Lee
>
> --
> 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 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

Re: Little namespace question

2012-12-19 Thread juan.facorro
The following example shows an implementation of *eval-in* as a function. 

There are a some *println* added to show the namespace where the code is 
running at each point.

;;
(ns another-ns)

(defn X [w h]
  {:w w :h h})
;;
(ns this-ns)

(defn eval-in [code ns]
  (let [orig-ns *ns*]
(println *ns*) ; we are in this-ns
(in-ns (symbol ns))
(println *ns* (resolve *ns* 'X)) ; not anymore, now it's another-ns
(let [ret (eval (read-string code))]
  (println *ns* (resolve *ns* 'X) ret) ; it's still another-ns but now 
we have the return value
  (in-ns (ns-name orig-ns))
  (println *ns*) ; back to this-ns
  ret)))
  
(def generator "(X 20 20)")
(println (eval-in generator "another-ns"))
(println (eval-in "(X 20 20)" "another-ns"))
;;

Cheers,

Juan

On Wednesday, December 19, 2012 4:22:58 AM UTC-3, nodename wrote:
>
> As an aside, I'm curious about whether this could have been implemented 
> without a macro.
>
> -A
>  On Dec 18, 2012 11:06 PM, "Alan Shaw" > 
> wrote:
>
>> Thanks very much Juan, that's some good study material for me.
>>
>> -A
>>  On Dec 18, 2012 10:45 PM, "juan.facorro" > 
>> wrote:
>>
>>> The macro sees it arguments as *symbols* and does not resolve to the 
>>> corresponding *var* until evaluation, so the value for the local *code* var 
>>> in the macro is actually the *symbol** generator.*
>>>
>>> The *eval-in* macro uses the *read-string* function to evaluate the 
>>> code you provide, this function expects a string but it's getting the* *
>>> *symbol** generator* instead, since that's what the macro got as a 
>>> first argument.
>>>
>>> Here's a modified version of the *eval-in* macro, that delays the 
>>> evaluation of the call to *read-string*:
>>>
>>> (require '[clojure.pprint :as p])
>>>
>>> (defmacro eval-in
>>>   [code ns]
>>>   `(do
>>>  (in-ns '~(symbol ns))
>>>  (let [ret# (eval *(read-string ~code)*)] ; This line was changed
>>>(in-ns '~(ns-name *ns*))
>>>ret#)))
>>>
>>> (p/pprint (macroexpand '(eval-in generator "another-ns")))
>>>
>>> Here's the output:
>>>
>>> (do
>>>  (clojure.core/in-ns 'another-ns)
>>>  (clojure.core/let
>>>   [ret__1879__auto__
>>>(clojure.core/eval *(clojure.core/read-string generator)*)] ; The 
>>> unquoting of code resulted in the symbol generator
>>>   (clojure.core/in-ns 'test-eval)
>>>   ret__1879__auto__))
>>>
>>> If you want to use a var as an argument for the code, you could resolve 
>>> the var before changing namespaces, delaying the read-string until the 
>>> forms evaluation:
>>>
>>> (ns another-ns)
>>>
>>> (defn X [w h] [w h])
>>> ;---
>>> (ns this-ns
>>>   (:require [clojure.pprint :as p]))
>>>
>>> (defmacro eval-in
>>>   [code ns]
>>>   `(let [code# ~code]
>>>  (in-ns '~(symbol ns))
>>>   (let [ret# (eval (read-string code#))]
>>>(in-ns '~(ns-name *ns*))
>>>ret#)))
>>>
>>> (def generator "(X 300 300)")
>>> (p/pprint (eval-in generator another-ns))
>>>
>>> Hope it helps,
>>>
>>> Juan
>>>
>>>
>>> On Wednesday, December 19, 2012 1:13:00 AM UTC-3, nodename wrote:

 From yesterday:

 (defmacro eval-in
   "Eval a Clojure form in a different namespace and switch back to 
 current namespace.

Args:
code - Clojure form as string
ns - Target namespace as string"
   [code ns]
   `(do
  (in-ns '~(symbol ns))
  (let [ret# (eval '~(read-string code))]
(in-ns '~(ns-name *ns*))
ret#)))



 user=> (def generator "(X 400 400)")
 #'user/generator
 user=> (def image (eval-in generator "clevolution.version.version0-**
 1-1"))
 CompilerException java.lang.ClassCastException: clojure.lang.Symbol 
 cannot be cast to java.lang.String, compiling:(NO_SOURCE_PATH:1)

 user=> (def image (eval-in "(X 400 400)" "clevolution.version.version0-
 **1-1"))
 #'user/image

 So it's OK to pass the explicit string but not the symbol. What am I 
 not getting here?

 -A


 On Tue, Dec 18, 2012 at 12:48 AM, Alan Shaw  wrote:

> Now I do, and the macro worked!
> I believe I have a problem using the macro from a function, but 
> leaving that for tomorrow.
>
> Thanks BG!
>
> -A
>
>
>
> On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose  > wrote:
>
>> Do you have target ns "clevolution.version.version0-**1-1" required?
>>
>> -BG
>>
>> On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw  wrote:
>> > BG,
>> > The macro doesn't seem to do the trick. The function X is interned 
>> in the
>> > target namespace, but:
>> >
>> > user=> (def image (eval-in "(X 400 400)"
>> > "clevolution.version.version0-**1-1"))
>> > CompilerException java.lang.RuntimeException: Unable to resolve 
>> symbol: X in
>> > this context, compiling:(NO_SOURCE_PATH:

Re: abysmal multicore performance, especially on AMD processors

2012-12-19 Thread Wm. Josiah Erikson
Whoops, sorry about the link. It should be able to be found here:
http://gibson.hampshire.edu/~josiah/clojush/

On Wed, Dec 19, 2012 at 11:57 AM, Wm. Josiah Erikson wrote:

> So here's what we came up with that clearly demonstrates the problem. Lee
> provided the code and I tweaked it until I believe it shows the problem
> clearly and succinctly.
>
> I have put together a .tar.gz file that has everything needed to run it,
> except lein. Grab it here: clojush_bowling_benchmark.tar.gz
>
> Then run, for instance: /usr/bin/time -f %E lein run
> clojush.examples.benchmark-bowling
>
> and then, when thWhooat has finished, edit
> src/clojush/examples/benchmark_bowling.clj and uncomment
> ":use-single-thread true" and run it again. I think this is a succinct,
> deterministic benchmark that clearly demonstrates the problem and also
> doesn't use conj or reverse. We don't see slowdowns, but I cannot get any
> better than around 2x speedup on any hardware with this benchmark.
>
> I hope this helps people get to the bottom of things.
>
> -Josiah
>
>
>
> On Sun, Dec 16, 2012 at 4:54 PM, Lee Spector wrote:
>
>>
>> On Dec 14, 2012, at 10:41 PM, cameron wrote:
>> > Until Lee has a representative benchmark for his application it's
>> difficult to tell if he's
>> > experiencing the same problem but there would seem to be a case for
>> changing the PersistentList
>> > implementation in clojure.lang.
>>
>> We put together a version of our application in which we just replaced
>> all of the random calls with deterministic functions (returning either
>> constants or deterministic functions of their arguments).
>>
>> What we saw was a maximum speedup of less than x2 on a 48 core machine,
>> which was interesting in part because the determinism meant that only a
>> tiny subset of our code was being executed (because all of the Push
>> programs in the population were identical and used only a single Push
>> instruction). So I think that this may indeed help us to hone in on the
>> problem.
>>
>> Before we share that code, however, we should make sure that the
>> evaluations that are being done concurrently are sufficiently long-running,
>> and maybe tweak a couple of other things. I think we'll have a chance to do
>> that early in the week and we'll share the results/code when we do.
>>
>> Thanks,
>>
>>  -Lee
>>
>> --
>> 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 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

[ANN] mesto, a memory storage for ClojureScript

2012-12-19 Thread Alexander Solovyov
mesto is a MEmory STOrage for ClojureScript, I wrote it because of my
experience writing JS apps using Backbone.js.

http://github.com/piranha/mesto

Idea is that you have atom (or atoms), containing all information you need
to show to user. Storing this information directly in DOM is not a nice
option, since it's slower, it's harder to access and overall is not a
welcome practice.

Of course, you could have such an atom yourself, so what mesto gives you?
It gives you simple language for queries and events.

Simple language is an extension of usual Clojure paths, used in
get-in/assoc-in: [:items {:id 1}]. Here {:id 1} serves as a filter for list
of :items. See readme (on Github) for better description.

Events give you an ability to act when your data changes. Event binding
system also supports filters (same as querying system) and puts actual
bindings in the same data storage as your data lies in, so you can bind
handlers on binding of handlers (sorry :).

Anyway, this is it. I hope to use it as a basis for FRP system (I'm already
experimenting with Flapjax, if you have something working written in
Clojure please let me know).

I also thought about using Datalog for querying atoms and subscribing to
their changes, but honestly it's too unfamiliar  complex and poorly
documented for me to use it productively *and* improve (i.e. add events).
Also it's too slow (minimal query takes 1-5 ms in *Clojure*, not even
ClojureScript). Implementation of Datalog from Datomic is easier to
understand, but then it's closed, so...

Also the code of mesto could be written much better (as in
quality/readability and performance), but I really wanted to get it done.

I would really like to hear some feedback, so if you have any remarks,
questions, or think it shouldn't be done like that, please reply to this
message.

Thank you for reading this email.

-- 
Alexander

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

Re: Two clojure with emacs questions

2012-12-19 Thread Tassilo Horn
Jonathon McKitrick  writes:

>> 1.  Can emacs with swank dynamically update Noir code running locally, 
>> > or do I need to save the code and then 'lein run' to see the new 
>> > result? 
>>
>> Without ever having used Noir, I would assume you can hack on the
>> living instance at the REPL.
>
> I was wondering if I could make changes in emacs, C-c C-k, and refresh
> the web page to see the results.

Yes, I guess so.

>> > 2.  When trying (in-ns ...) and a few other commands from emacs, nRepl 
>> > hangs consistently.  Is this user error? 
>>
>> Uhm, now do you use SLIME/swank, or do you use nrepl.el/nREPL?  (Aside 
>> from that, neither should hang on (in-ns ...).) 
>
> Hmm, I guess I have migrated to nrepl as the backend to emacs.  I'm
> using nrepl-jack-in.

Yes, then you are using nrepl and not SLIME/Swank.  I use that, too, and
I haven't encountered hangs with (in-ns ...) forms yet.  If you have
your project accessible somewhere, I'm happy to try to reproduce the
issue.

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


Re: abysmal multicore performance, especially on AMD processors

2012-12-19 Thread Lee Spector

On Dec 19, 2012, at 11:57 AM, Wm. Josiah Erikson wrote:
>  I think this is a succinct, deterministic benchmark that clearly 
> demonstrates the problem and also doesn't use conj or reverse. 

Clarification: it's not just a tight loop involving reverse/conj, as our 
previous benchmark was. It's our real application but with deterministic 
versions of all of the "random" functions, and while the project includes some 
calls to reverse and conj I don't think they're playing a big role here. 

Almost all of the time here is spent evaluating a Push program that just does a 
lot of integer addition and consing. As far as I can tell all of the consing is 
done with "cons" explicitly, and not conj although maybe I'm missing 
something, and I'm saying this only from looking at our code, not the Clojure 
libraries.

 -Lee

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


Re: Need help in geeting cemerick/friend working with openid

2012-12-19 Thread Murtaza Husain

Thanks for catching that Aaron !

The app currently redirects to the login page now. However I get an error 
when I try to post to the "/openid" url with 
{"openid_identifier":"https://www.google.com/accounts/o8/id"} 
as post data.

Here is the updated code - 

(ns faiz.handler
  (:use compojure.core)
  (:require [compojure.handler :as handler]
[compojure.route :as route]
[ring.util.response :as resp]
[me.shenfeng.mustache :as mustache]
[cemerick.friend :as friend]
(cemerick.friend [workflows :as workflows]
 [credentials :as creds]
 [openid :as openid])))

(mustache/deftemplate index (slurp "public/index-async.html"))

(def index-data {:title "Invoize." :brand "Faiz" :links [{:url "#/students" 
:text "Students"} {:url "#/thaalis" :text "Thaalis"}]})

(defroutes app-routes
  (GET "/" [] (resp/redirect "/login"))
  (ANY "/login" [] (resp/file-response "landing.html" {:root "public"}))
  (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
  (GET "/index" [] (friend/authenticated (index index-data)))
  (route/files "/" {:root "public"})
  (route/not-found "Not Found"))

(def app-routes-with-auth
  (-> app-routes
  (friend/authenticate
   {:workflows [(openid/workflow :openid-uri "/openid" :realm 
"http://invoize.com"; :credential-fn identity)]})))

(def app
  (handler/site app-routes-with-auth))


Below is the stacktrace -

java.lang.NullPointerExceptionopenid.clj:124
cemerick.friend.openid/workflow[fn]friend.clj:174
cemerick.friend/authenticate*[fn]core.clj:2432clojure.core/map[fn]
LazySeq.java:42clojure.lang.LazySeq.sval

Thanks,
Murtaza




On Wednesday, December 19, 2012 7:37:04 PM UTC+5:30, Aaron Cohen wrote:
>
>
>
>
> On Wed, Dec 19, 2012 at 8:40 AM, Murtaza Husain <
> murtaza...@sevenolives.com > wrote:
>>
>> (defroutes app-routes
>>   (GET "/" [] (resp/redirect "/landing"))
>>   (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
>>   (GET "/index" [] (index index-data))
>>   (route/files "/" {:root "public"})
>>   (route/not-found "Not Found"))
>>
>> (def mock-app
>>   (-> app-routes
>>   (friend/authenticate
>>{:allow-anon? false
>> :login-uri? "/landing"
>> :workflows [(openid/workflow :openid-uri "/openid" :realm "
>> http://invoize.com";)]})))
>>
>>
>
> I'm not fully conversant with all the libraries, but don't you actually 
> need to use mock-app somewhere?
>  
>
>> (def app
>>   (handler/site app-routes))
>>
>>

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

Re: abysmal multicore performance, especially on AMD processors

2012-12-19 Thread Wm. Josiah Erikson
I tried redefining the few places in the code (string_reverse, I think)
that used reverse to use the same version of reverse that I got such great
speedups with in your code, and it made no difference. There are not any
explicit calls to conj in the code that I could find.

On Wed, Dec 19, 2012 at 1:00 PM, Lee Spector  wrote:

>
> On Dec 19, 2012, at 11:57 AM, Wm. Josiah Erikson wrote:
> >  I think this is a succinct, deterministic benchmark that clearly
> demonstrates the problem and also doesn't use conj or reverse.
>
> Clarification: it's not just a tight loop involving reverse/conj, as our
> previous benchmark was. It's our real application but with deterministic
> versions of all of the "random" functions, and while the project includes
> some calls to reverse and conj I don't think they're playing a big role
> here.
>
> Almost all of the time here is spent evaluating a Push program that just
> does a lot of integer addition and consing. As far as I can tell all of the
> consing is done with "cons" explicitly, and not conj although maybe I'm
> missing something, and I'm saying this only from looking at our code, not
> the Clojure libraries.
>
>  -Lee
>
> --
> 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 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

Reminder! Clojure/West 2013 CFP closes Jan 4th!

2012-12-19 Thread Alex Miller
I think if you reflect back on 2012 you'll find that one of your biggest
regrets was not attending enough Clojure conferences.

Don't worry though - Clojure/West is right around the corner! Make a new
year's resolution to attend, or even better, submit a talk! Rich Hickey
will be keynoting (along with another hopefully to be named soon) and we'll
of course have Clojure friends old and new.

Clojure/West will be in sunny* Portland, Oregon March 18-20th. The early
bird tickets are already sold out (I thought we were all about laziness in
the Clojure community?) but that's ok because we still have plenty left and
they're only $350 for 3 days of people smartening+ you with Clojure and
ClojureScript.

Alex Miller

- CFP: http://clojurewest.org/call-for-presentations/
- Sponsorship: http://clojurewest.org/sponsorship-prospectus/
- Tickets: http://regonline.com/clojurewest2013
- Theater: http://www.stoneyphoto.com/gerding-theater-at-the-armory/

* it's right above the clouds
+ not a real word, but you'd know that if you were smartener

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

Re: abysmal multicore performance, especially on AMD processors

2012-12-19 Thread Tassilo Horn
"Wm. Josiah Erikson"  writes:

> Then run, for instance: /usr/bin/time -f %E lein run
> clojush.examples.benchmark-bowling
>
> and then, when that has finished, edit
> src/clojush/examples/benchmark_bowling.clj and uncomment
> ":use-single-thread true" and run it again. I think this is a
> succinct, deterministic benchmark that clearly demonstrates the
> problem and also doesn't use conj or reverse. We don't see slowdowns,
> but I cannot get any better than around 2x speedup on any hardware
> with this benchmark.

FWIW, I've just ran it with these results:

- a dual-core intel notebook:
  + single-threaded: 4:00.09
  + multi-threaded:  2:27.35

- an AMD Opteron 8-core machine [*]
  + single-threaded: 3:03.51
  + multi-threaded:  1:31.58

So indeed, I also get only a speedup of factor 2.

[*] I'm not exactly sure what for a machine that is.  /proc/cpuinfo
reports 8 processors, each being a "Quad-Core AMD Opteron(tm) Processor
8387".  Well, that would make 32 cores, but actually htop shows just 8.
But I think its some virtualized machine, so maybe the host has 8
4-cores, but the virtual machine gets only 8 of them...

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


Re: Need help in geeting cemerick/friend working with openid

2012-12-19 Thread Chas Emerick
The parameter name is 'identifier' (not 'openid_identifier') by default (which 
you can customize if you want by specifying a :user-identifier-param option in 
openid/workflow).

That said, the NPE you just hit has drawn my attention to an (unrelated) bug in 
the openid workflow.  Thanks! :-)

- Chas

On Dec 19, 2012, at 1:20 PM, Murtaza Husain wrote:

> 
> Thanks for catching that Aaron !
> 
> The app currently redirects to the login page now. However I get an error 
> when I try to post to the "/openid" url with 
> {"openid_identifier":"https://www.google.com/accounts/o8/id"} as post data.
> 
> Here is the updated code - 
> 
> (ns faiz.handler
>   (:use compojure.core)
>   (:require [compojure.handler :as handler]
> [compojure.route :as route]
> [ring.util.response :as resp]
> [me.shenfeng.mustache :as mustache]
> [cemerick.friend :as friend]
> (cemerick.friend [workflows :as workflows]
>  [credentials :as creds]
>  [openid :as openid])))
> 
> (mustache/deftemplate index (slurp "public/index-async.html"))
> 
> (def index-data {:title "Invoize." :brand "Faiz" :links [{:url "#/students" 
> :text "Students"} {:url "#/thaalis" :text "Thaalis"}]})
> 
> (defroutes app-routes
>   (GET "/" [] (resp/redirect "/login"))
>   (ANY "/login" [] (resp/file-response "landing.html" {:root "public"}))
>   (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
>   (GET "/index" [] (friend/authenticated (index index-data)))
>   (route/files "/" {:root "public"})
>   (route/not-found "Not Found"))
> 
> (def app-routes-with-auth
>   (-> app-routes
>   (friend/authenticate
>{:workflows [(openid/workflow :openid-uri "/openid" :realm 
> "http://invoize.com"; :credential-fn identity)]})))
> 
> (def app
>   (handler/site app-routes-with-auth))
> 
> 
> Below is the stacktrace -
> 
> java.lang.NullPointerException
> 
> openid.clj:124cemerick.friend.openid/workflow[fn]
> friend.clj:174cemerick.friend/authenticate*[fn]
> core.clj:2432 clojure.core/map[fn]
> LazySeq.java:42   clojure.lang.LazySeq.sval
> 
> 
> Thanks,
> Murtaza
> 
> 
> 
> 
> On Wednesday, December 19, 2012 7:37:04 PM UTC+5:30, Aaron Cohen wrote:
> 
> 
> 
> On Wed, Dec 19, 2012 at 8:40 AM, Murtaza Husain  
> wrote:
> (defroutes app-routes
>   (GET "/" [] (resp/redirect "/landing"))
>   (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
>   (GET "/index" [] (index index-data))
>   (route/files "/" {:root "public"})
>   (route/not-found "Not Found"))
> 
> (def mock-app
>   (-> app-routes
>   (friend/authenticate
>{:allow-anon? false
> :login-uri? "/landing"
> :workflows [(openid/workflow :openid-uri "/openid" :realm 
> "http://invoize.com";)]})))
> 
> 
> 
> I'm not fully conversant with all the libraries, but don't you actually need 
> to use mock-app somewhere?
>  
> (def app
>   (handler/site app-routes))
> 
> 
> -- 
> 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 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

Re: How to structure a Clojure day for noobs?

2012-12-19 Thread Nando
What about Clooj?
http://dev.clojure.org/display/doc/getting+started+with+Clooj

Is it too buggy, or lacking in features, to start out with?

On Tue, Dec 18, 2012 at 11:27 AM, ulsa  wrote:

> Good point.
>
> I really would like themselves to be able to set up their own environment.
> I think it gives them a sense of control. However, as a fallback, it would
> be great with a virtual machine with everything working. I'll consider that.
>
> I believe you can get a similar level of interactivity in both IntelliJ
> and Eclipse, but I agree that Emacs is still the master.
>
>
> On Tuesday, 18 December 2012 04:31:32 UTC+1, Peter wrote:
>
>> 1. install Leiningen and learn the basics
>> 2. get everyone an editing environment, with the option of using either
>> Emacs, IntelliJ, or Eclipse
>>
>> I would have people do this in advance, or provide a canned environment
>> that has a better chance of "just working". There's decent odds that these
>> two steps will eat up a bunch of your time and leave people feeling left
>> out when their install/editor/integration is not quite right.
>>
>> Personally I found the C-x-e of evaluating an s-exp in emacs to be the
>> magic that makes clojure a bajillionty times better than any other
>> programming language, so I'm partial to something like the emacs starter
>> kit. But something like labrepl or eclipse+counterclockwise might be easier
>> for people to start with.
>>
>> On Mon, Dec 17, 2012 at 3:26 AM, Marko Topolnik wrote:
>>
>>>
>>> I think, however, that there is a risk of a disconnect, where newcomers
 don't really grasp that there is a JVM running and that code is actually
 compiled and injected into it, and that it's for real. They are used to
 mickey mouse interactive tools that don't provide the real thing, and
 struggle to bridge the apparent gap between running code in the REPL and
 "properly compiling and running" files. There is no gap, but one needs to
 explain that, I think.
>>>
>>>
>>> I think this is a pivot point for everything in Clojure. The harder the
>>> mental switch, the more important to make it right away. Without
>>> understanding that, it will be very hard to maintain a clear picture of how
>>> everything fits together, especially when you start changing functions and
>>> reloading them.
>>>
>>> --
>>> 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
>>>
>>
>>
>>
>> --
>> The king’s heart is like a stream of water directed by the Lord; He
>> guides it wherever He pleases.
>>
>  --
> 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
>



-- 
Nando Breiter

*Aria Media
via Rompada 40
6987 Caslano
Switzerland
*

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

Re: Best way to include a passwords file in a project?

2012-12-19 Thread Manuel Paccagnella
I'm not sure that a password file is an optimal solution for this problem. 
Maybe the 12 factors , and in particular the 
config  one, could give you some ideas.

Personally I think that credentials are environment-specific, not 
application-specific. So I'd place them in an external storage service 
(like a DB). Or, to make things simple, put them in a file somewhere in the 
system and load it through an environment variable (see 12 factors, III).

This is as simple as writing:

(load-passwords-from-file (System/getenv "PASSWORD_FILE"))

Hope it helps :)

Il giorno martedì 18 dicembre 2012 03:21:31 UTC+1, Marco Munizaga ha 
scritto:
>
> I'm currently doing something like src/project/passwords.clj and git 
> ignoring that, does anyone have a better solution? maybe a way to place the 
> passwords.clj alongside project.clj in the root directory? Would this be 
> possible through leiningen profiles?
>
>
> 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

Re: Little namespace question

2012-12-19 Thread Alan Shaw
Thanks again. This version is easier for my non-macro brain to follow.

-A



On Wed, Dec 19, 2012 at 8:58 AM, juan.facorro wrote:

> The following example shows an implementation of *eval-in* as a function.
>
> There are a some *println* added to show the namespace where the code is
> running at each point.
>
> ;;
> (ns another-ns)
>
> (defn X [w h]
>   {:w w :h h})
> ;;
> (ns this-ns)
>
> (defn eval-in [code ns]
>   (let [orig-ns *ns*]
> (println *ns*) ; we are in this-ns
> (in-ns (symbol ns))
> (println *ns* (resolve *ns* 'X)) ; not anymore, now it's another-ns
> (let [ret (eval (read-string code))]
>   (println *ns* (resolve *ns* 'X) ret) ; it's still another-ns but now
> we have the return value
>   (in-ns (ns-name orig-ns))
>   (println *ns*) ; back to this-ns
>   ret)))
>
> (def generator "(X 20 20)")
> (println (eval-in generator "another-ns"))
> (println (eval-in "(X 20 20)" "another-ns"))
> ;;
>
> Cheers,
>
> Juan
>
>
> On Wednesday, December 19, 2012 4:22:58 AM UTC-3, nodename wrote:
>
>> As an aside, I'm curious about whether this could have been implemented
>> without a macro.
>>
>> -A
>>  On Dec 18, 2012 11:06 PM, "Alan Shaw"  wrote:
>>
>>> Thanks very much Juan, that's some good study material for me.
>>>
>>> -A
>>>  On Dec 18, 2012 10:45 PM, "juan.facorro"  wrote:
>>>
 The macro sees it arguments as *symbols* and does not resolve to the
 corresponding *var* until evaluation, so the value for the local *code* var
 in the macro is actually the *symbol** generator.*

 The *eval-in* macro uses the *read-string* function to evaluate the
 code you provide, this function expects a string but it's getting the*
 **symbol** generator* instead, since that's what the macro got as a
 first argument.

 Here's a modified version of the *eval-in* macro, that delays the
 evaluation of the call to *read-string*:

 (require '[clojure.pprint :as p])

 (defmacro eval-in
   [code ns]
   `(do
  (in-ns '~(symbol ns))
  (let [ret# (eval *(read-string ~code)*)] ; This line was changed
(in-ns '~(ns-name *ns*))
ret#)))

 (p/pprint (macroexpand '(eval-in generator "another-ns")))

 Here's the output:

 (do
  (clojure.core/in-ns 'another-ns)
  (clojure.core/let
   [ret__1879__auto__
(clojure.core/eval *(clojure.core/read-string generator)*)] ; The
 unquoting of code resulted in the symbol generator
   (clojure.core/in-ns 'test-eval)
   ret__1879__auto__))

 If you want to use a var as an argument for the code, you could resolve
 the var before changing namespaces, delaying the read-string until the
 forms evaluation:

 (ns another-ns)

 (defn X [w h] [w h])
 ;---
 (ns this-ns
   (:require [clojure.pprint :as p]))

 (defmacro eval-in
   [code ns]
   `(let [code# ~code]
  (in-ns '~(symbol ns))
   (let [ret# (eval (read-string code#))]
(in-ns '~(ns-name *ns*))
ret#)))

 (def generator "(X 300 300)")
 (p/pprint (eval-in generator another-ns))

 Hope it helps,

 Juan


 On Wednesday, December 19, 2012 1:13:00 AM UTC-3, nodename wrote:
>
> From yesterday:
>
> (defmacro eval-in
>   "Eval a Clojure form in a different namespace and switch back to
> current namespace.
>
>Args:
>code - Clojure form as string
>ns - Target namespace as string"
>   [code ns]
>   `(do
>  (in-ns '~(symbol ns))
>  (let [ret# (eval '~(read-string code))]
>(in-ns '~(ns-name *ns*))
>ret#)))
>
>
>
> user=> (def generator "(X 400 400)")
> #'user/generator
> user=> (def image (eval-in generator "clevolution.version.version0-***
> *1-1"))
> CompilerException java.lang.ClassCastException: clojure.lang.Symbol
> cannot be cast to java.lang.String, compiling:(NO_SOURCE_PATH:1)
>
> user=> (def image (eval-in "(X 400 400)" "clevolution.version.version0-
> 1-1"))
> #'user/image
>
> So it's OK to pass the explicit string but not the symbol. What am I
> not getting here?
>
> -A
>
>
> On Tue, Dec 18, 2012 at 12:48 AM, Alan Shaw  wrote:
>
>> Now I do, and the macro worked!
>> I believe I have a problem using the macro from a function, but
>> leaving that for tomorrow.
>>
>> Thanks BG!
>>
>> -A
>>
>>
>>
>> On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose <
>> b.g...@gmail.com> wrote:
>>
>>> Do you have target ns "clevolution.version.version0-1-1"
>>> required?
>>>
>>> -BG
>>>
>>> On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw 
>>> wrote:
>>> > BG,
>>> > The macro doesn't seem to d

Re: Best way to include a passwords file in a project?

2012-12-19 Thread Alex Baranosky
I don't like the environment variable approach because of the dependency on
global state makes deploying harder.

I'd usually have a config file like config.clj whose contents were just a
Clojure map.  When loading the application I'd pass in the location of the
config file as a parameter, and read-string the file at run-time.  That
said, it can sometimes be convenient for development to have some default
config file location, so you don't always need to pass the config location
in.

Alex

On Wed, Dec 19, 2012 at 12:13 PM, Manuel Paccagnella <
manuel.paccagne...@gmail.com> wrote:

> I'm not sure that a password file is an optimal solution for this problem.
> Maybe the 12 factors , and in particular the
> config  one, could give you some ideas.
>
> Personally I think that credentials are environment-specific, not
> application-specific. So I'd place them in an external storage service
> (like a DB). Or, to make things simple, put them in a file somewhere in the
> system and load it through an environment variable (see 12 factors, III).
>
> This is as simple as writing:
>
> (load-passwords-from-file (System/getenv "PASSWORD_FILE"))
>
> Hope it helps :)
>
> Il giorno martedì 18 dicembre 2012 03:21:31 UTC+1, Marco Munizaga ha
> scritto:
>
>> I'm currently doing something like src/project/passwords.clj and git
>> ignoring that, does anyone have a better solution? maybe a way to place the
>> passwords.clj alongside project.clj in the root directory? Would this be
>> possible through leiningen profiles?
>>
>>
>> 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 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

Re: Two clojure with emacs questions

2012-12-19 Thread Jack Moffitt
On Wed, Dec 19, 2012 at 9:52 AM, Jonathon McKitrick
 wrote:
> I was wondering if I could make changes in emacs, C-c C-k, and refresh the
> web page to see the results.

You'll probably want to use ring-serve for this. To some degree
lein-ring also offers this functionality as it uses wrap-reload
middleware that comes with ring.

Here's a link to some docs:
https://github.com/ring-clojure/ring/wiki/Interactive-Development

jack.

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


Re: Little namespace question

2012-12-19 Thread Dave Ray
A function seems to work fine unless I don't understand your requirement:

  ; normal version that takes code forms and symbols
  (defn eval-in
[code ns]
(let [old (-> *ns* str symbol)]
  (try
(in-ns ns)
(eval code)
(finally
  (in-ns old)

  ; sugary version that takes strings
  (defn eval-strs [code-str ns-str]
(eval-in (read-string code-str) (symbol ns-str)))

and now try it out:

  user=> (eval-strs "(def z 500)" "bar")
  #'bar/z
  user=> (in-ns 'bar)
  #
  bar=> z
  500

Making this bullet-proof and deciding whether it's actually a good
design is left as an exercise for the reader.

Cheers,

Dave

On Tue, Dec 18, 2012 at 11:22 PM, Alan Shaw  wrote:
> As an aside, I'm curious about whether this could have been implemented
> without a macro.
>
> -A
>
> On Dec 18, 2012 11:06 PM, "Alan Shaw"  wrote:
>>
>> Thanks very much Juan, that's some good study material for me.
>>
>> -A
>>
>> On Dec 18, 2012 10:45 PM, "juan.facorro"  wrote:
>>>
>>> The macro sees it arguments as symbols and does not resolve to the
>>> corresponding var until evaluation, so the value for the local code var in
>>> the macro is actually the symbol generator.
>>>
>>> The eval-in macro uses the read-string function to evaluate the code you
>>> provide, this function expects a string but it's getting the symbol
>>> generator instead, since that's what the macro got as a first argument.
>>>
>>> Here's a modified version of the eval-in macro, that delays the
>>> evaluation of the call to read-string:
>>>
>>> (require '[clojure.pprint :as p])
>>>
>>> (defmacro eval-in
>>>   [code ns]
>>>   `(do
>>>  (in-ns '~(symbol ns))
>>>  (let [ret# (eval (read-string ~code))] ; This line was changed
>>>(in-ns '~(ns-name *ns*))
>>>ret#)))
>>>
>>> (p/pprint (macroexpand '(eval-in generator "another-ns")))
>>>
>>> Here's the output:
>>>
>>> (do
>>>  (clojure.core/in-ns 'another-ns)
>>>  (clojure.core/let
>>>   [ret__1879__auto__
>>>(clojure.core/eval (clojure.core/read-string generator))] ; The
>>> unquoting of code resulted in the symbol generator
>>>   (clojure.core/in-ns 'test-eval)
>>>   ret__1879__auto__))
>>>
>>> If you want to use a var as an argument for the code, you could resolve
>>> the var before changing namespaces, delaying the read-string until the forms
>>> evaluation:
>>>
>>> (ns another-ns)
>>>
>>> (defn X [w h] [w h])
>>> ;---
>>> (ns this-ns
>>>   (:require [clojure.pprint :as p]))
>>>
>>> (defmacro eval-in
>>>   [code ns]
>>>   `(let [code# ~code]
>>>  (in-ns '~(symbol ns))
>>>   (let [ret# (eval (read-string code#))]
>>>(in-ns '~(ns-name *ns*))
>>>ret#)))
>>>
>>> (def generator "(X 300 300)")
>>> (p/pprint (eval-in generator another-ns))
>>>
>>> Hope it helps,
>>>
>>> Juan
>>>
>>>
>>> On Wednesday, December 19, 2012 1:13:00 AM UTC-3, nodename wrote:

 From yesterday:

 (defmacro eval-in
   "Eval a Clojure form in a different namespace and switch back to
 current namespace.

Args:
code - Clojure form as string
ns - Target namespace as string"
   [code ns]
   `(do
  (in-ns '~(symbol ns))
  (let [ret# (eval '~(read-string code))]
(in-ns '~(ns-name *ns*))
ret#)))



 user=> (def generator "(X 400 400)")
 #'user/generator
 user=> (def image (eval-in generator
 "clevolution.version.version0-1-1"))
 CompilerException java.lang.ClassCastException: clojure.lang.Symbol
 cannot be cast to java.lang.String, compiling:(NO_SOURCE_PATH:1)

 user=> (def image (eval-in "(X 400 400)"
 "clevolution.version.version0-1-1"))
 #'user/image

 So it's OK to pass the explicit string but not the symbol. What am I not
 getting here?

 -A


 On Tue, Dec 18, 2012 at 12:48 AM, Alan Shaw  wrote:
>
> Now I do, and the macro worked!
> I believe I have a problem using the macro from a function, but leaving
> that for tomorrow.
>
> Thanks BG!
>
> -A
>
>
>
> On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose 
> wrote:
>>
>> Do you have target ns "clevolution.version.version0-1-1" required?
>>
>> -BG
>>
>> On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw  wrote:
>> > BG,
>> > The macro doesn't seem to do the trick. The function X is interned
>> > in the
>> > target namespace, but:
>> >
>> > user=> (def image (eval-in "(X 400 400)"
>> > "clevolution.version.version0-1-1"))
>> > CompilerException java.lang.RuntimeException: Unable to resolve
>> > symbol: X in
>> > this context, compiling:(NO_SOURCE_PATH:1)
>> >
>> >
>> > On Mon, Dec 17, 2012 at 11:53 PM, Alan Shaw 
>> > wrote:
>> >>
>> >> Oh yes, the something.something is fixed so I can just prepend it,
>> >> thanks.
>> >> (Hadn't noticed your macro takes the ns as a string!)

Re: Best way to include a passwords file in a project?

2012-12-19 Thread Wei Hsu
I second Manuel's environment variable approach. On 
herokuthis is easy to set 
with

heroku config:add PASSWORD_FILE="/etc/passwords"

For more complex deployments, you can use automation systems like Pallet or 
Chef to manage environment variables.

On Wednesday, December 19, 2012 1:40:18 PM UTC-8, Alex Baranosky wrote:
>
> I don't like the environment variable approach because of the dependency 
> on global state makes deploying harder.
>
> I'd usually have a config file like config.clj whose contents were just a 
> Clojure map.  When loading the application I'd pass in the location of the 
> config file as a parameter, and read-string the file at run-time.  That 
> said, it can sometimes be convenient for development to have some default 
> config file location, so you don't always need to pass the config location 
> in.
>
> Alex
>
> On Wed, Dec 19, 2012 at 12:13 PM, Manuel Paccagnella <
> manuel.pa...@gmail.com > wrote:
>
>> I'm not sure that a password file is an optimal solution for this 
>> problem. Maybe the 12 factors , and in 
>> particular the config  one, could give 
>> you some ideas.
>>
>> Personally I think that credentials are environment-specific, not 
>> application-specific. So I'd place them in an external storage service 
>> (like a DB). Or, to make things simple, put them in a file somewhere in the 
>> system and load it through an environment variable (see 12 factors, III).
>>
>> This is as simple as writing:
>>
>> (load-passwords-from-file (System/getenv "PASSWORD_FILE"))
>>
>> Hope it helps :)
>>
>> Il giorno martedì 18 dicembre 2012 03:21:31 UTC+1, Marco Munizaga ha 
>> scritto:
>>
>>> I'm currently doing something like src/project/passwords.clj and git 
>>> ignoring that, does anyone have a better solution? maybe a way to place the 
>>> passwords.clj alongside project.clj in the root directory? Would this be 
>>> possible through leiningen profiles?
>>>
>>>
>>> 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 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

Re: Best way to include a passwords file in a project?

2012-12-19 Thread Sean Grove
Hey Alex, I accidentally hit a button to subscribe you a mailing list while
reading this thread, please ignore it. Sorry about that!


On Wed, Dec 19, 2012 at 1:40 PM, Alex Baranosky <
alexander.barano...@gmail.com> wrote:

> I don't like the environment variable approach because of the dependency
> on global state makes deploying harder.
>
> I'd usually have a config file like config.clj whose contents were just a
> Clojure map.  When loading the application I'd pass in the location of the
> config file as a parameter, and read-string the file at run-time.  That
> said, it can sometimes be convenient for development to have some default
> config file location, so you don't always need to pass the config location
> in.
>
> Alex
>
> On Wed, Dec 19, 2012 at 12:13 PM, Manuel Paccagnella <
> manuel.paccagne...@gmail.com> wrote:
>
>> I'm not sure that a password file is an optimal solution for this
>> problem. Maybe the 12 factors , and in
>> particular the config  one, could give
>> you some ideas.
>>
>> Personally I think that credentials are environment-specific, not
>> application-specific. So I'd place them in an external storage service
>> (like a DB). Or, to make things simple, put them in a file somewhere in the
>> system and load it through an environment variable (see 12 factors, III).
>>
>> This is as simple as writing:
>>
>> (load-passwords-from-file (System/getenv "PASSWORD_FILE"))
>>
>> Hope it helps :)
>>
>> Il giorno martedì 18 dicembre 2012 03:21:31 UTC+1, Marco Munizaga ha
>> scritto:
>>
>>> I'm currently doing something like src/project/passwords.clj and git
>>> ignoring that, does anyone have a better solution? maybe a way to place the
>>> passwords.clj alongside project.clj in the root directory? Would this be
>>> possible through leiningen profiles?
>>>
>>>
>>> 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 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 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

Re: ClojureCLR errors on Mono Linux

2012-12-19 Thread Shantanu Kumar
Here are the steps how to reproduce the issue on 32-bit Ubuntu 12.04:

1. lein new lein-clr foo
2. cd foo
3. # edit project.clj to download the dependencies using :clj-dep
4. lein clr -v compile :all
5. lein clr -v test

It will show the exact commands being executed. Are the same Clojure 
binaries supposed to work on 32-bit systems?

Shantanu

On Wednesday, 19 December 2012 13:19:55 UTC+5:30, Shantanu Kumar wrote:
>
> Thanks David, and sorry for the insufficient bug details. I tested this on 
> 64-bit Ubuntu where it works fine; however, the problem shows up on 32-bit 
> Ubuntu.
>
> I will post the exact steps in the evening on how to replicate the issue 
> on 32-bit Ubuntu.
>
> Shantanu
>
> On Wednesday, 19 December 2012 02:00:53 UTC+5:30, dmiller wrote:
>>
>> Shantanu,
>>
>> I created an Ubuntu 12.10 VM running in VirtualBox on my Win7 PC.  
>> I installed Mono 2.10.8.
>> I downloaded the zip for ClojureCLR 1.4.0 Debug-4.0.
>> Extracted.
>> > mono Clojure.Main.exe  
>> Runs with no problem.
>>
>> > mono Clojure.Compile.exe test.junk
>> Runs with no problem.
>>
>> From the errors you report, I can only guess that some pre-1.4 DLLs are 
>> being found somehow and loaded.  
>> For example,  the field clojure.lang.RT.OutVar did not exist in 
>> ClojureCLR 1.3.
>>
>> I do not know how else to help.
>>
>> -David
>>  
>>
>>
>> On Saturday, December 15, 2012 10:17:59 PM UTC-6, Shantanu Kumar wrote:
>>>
>>> This is when using ClojureCLR 1.4.0 Debug-4.0 version.
>>>
>>> Shantanu
>>>
>>> On Sunday, 16 December 2012 09:45:21 UTC+5:30, Shantanu Kumar wrote:

 Hi,

 I noticed the following ClojureCLR errors using Mono 2.10 on Ubuntu 
 12.04 (they do not happen on Windows using either .NET or Mono):

 1. when running Clojure.Compile.exe:

 Exception: System.MissingFieldException: Field 'clojure.lang.RT.OutVar' 
 not found.

 2. when using Clojure.Main.exe:

 Exception: System.TypeLoadException: Could not load type 
 'Clojure.CljMain' from assembly 'Clojure.Main, Version=1.0.0.0, 
 Culture=neutral, PublicKeyToken=null'.

 It would be great if anybody can let me know what's going on.

 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

Fair conjunction and parallel solvers in core.logic

2012-12-19 Thread Jamie Brandon
Last week I figured out how to add fair conjunction and a parallel
solver (via fork-join) to core.logic. I just wrote up an explanation
of how it works which may be interesting:

http://scattered-thoughts.net/blog/2012/12/19/search-trees-and-core-dot-logic/

https://github.com/jamii/core.logic/tree/flexible-search

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


Re: [ANN] lein-stencil 0.1.0

2012-12-19 Thread Matthew O. Smith
I renamed the project to lein-resource as that better matches the intent of 
the project rather than an implmentation detail

*https://github.com/m0smith/lein-resource

*

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

Re: Fair conjunction and parallel solvers in core.logic

2012-12-19 Thread David Nolen
Great write up! :)

David


On Wed, Dec 19, 2012 at 5:52 PM, Jamie Brandon  wrote:

> Last week I figured out how to add fair conjunction and a parallel
> solver (via fork-join) to core.logic. I just wrote up an explanation
> of how it works which may be interesting:
>
>
> http://scattered-thoughts.net/blog/2012/12/19/search-trees-and-core-dot-logic/
>
> https://github.com/jamii/core.logic/tree/flexible-search
>
> --
> 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 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

compojure in production

2012-12-19 Thread Maris

How can I run my compojure app without leiningen ?

I want to use dedicated jetty server (not war file). 

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

Re: Two clojure with emacs questions

2012-12-19 Thread Jonathon McKitrick
Yes, then you are using nrepl and not SLIME/Swank.  I use that, too, and 

> I haven't encountered hangs with (in-ns ...) forms yet.  If you have 
> your project accessible somewhere, I'm happy to try to reproduce the 
> issue. 
>

I have a bit more information.

The interface hangs running in Carbon Emacs, but not in -nw mode.
Sounds like a bug report is due?
 

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

Re: Little namespace question

2012-12-19 Thread Dave Ray
It does, right?

On Wednesday, December 19, 2012, Alan Shaw wrote:

> But returning the evaluation was a requirement...
>
>
> On Wed, Dec 19, 2012 at 2:58 PM, Alan Shaw  wrote:
>
> No, there was no requirement that it be a macro. Thanks!
>
> -A
>
>
>
> On Wed, Dec 19, 2012 at 7:40 AM, Dave Ray  wrote:
>
> A function seems to work fine unless I don't understand your requirement:
>
>   ; normal version that takes code forms and symbols
>   (defn eval-in
> [code ns]
> (let [old (-> *ns* str symbol)]
>   (try
> (in-ns ns)
> (eval code)
> (finally
>   (in-ns old)
>
>   ; sugary version that takes strings
>   (defn eval-strs [code-str ns-str]
> (eval-in (read-string code-str) (symbol ns-str)))
>
> and now try it out:
>
>   user=> (eval-strs "(def z 500)" "bar")
>   #'bar/z
>   user=> (in-ns 'bar)
>   #
>   bar=> z
>   500
>
> Making this bullet-proof and deciding whether it's actually a good
> design is left as an exercise for the reader.
>
> Cheers,
>
> Dave
>
> On Tue, Dec 18, 2012 at 11:22 PM, Alan Shaw  wrote:
> > As an aside, I'm curious about whether this could have been implemented
> > without a macro.
> >
> > -A
> >
> > On Dec 18, 2012 11:06 PM, "Alan Shaw"  wrote:
> >>
> >> Thanks very much Juan, that's some good study material for me.
> >>
> >> -A
> >>
> >> On Dec 18, 2012 10:45 PM, "juan.facorro" 
> wrote:
> >>>
> >>> The macro sees it arguments as symbols and does not resolve to the
> >>> corresponding var until evaluation, so the value for the local code
> var in
> >>> the macro is actually the symbol generator.
> >>>
> >>> The eval-in macro uses the read-string function to evaluate the code
> you
> >>> provide, this function expects a string but it's getting the symbol
> >>> generator instead, since that's what the macro got as a first argument.
> >>>
> >>> Here's a modified version of the eval-in macro, that delays the
> >>> evaluation of the call to read-string:
> >>>
> >>> (require '[clojure.pprint :as p])
> >>>
> >>> (defmacro eval-in
> >>>   [code ns]
> >>>   `(do
> >>>  (in-ns '~(symbol ns))
> >>>  (let [ret# (eval (read-string ~code))] ; This line was changed
> >>>(in-ns '~(ns-name *ns*))
> >>>ret#)))
> >>>
> >>> (p/pprint (macroexpand '(eval-in generator "another-ns")))
> >>>
> >>> Here's the output:
> >>>
> >>> (do
> >>>  (clojure.core/in-ns 'another-ns)
> >>>  (clojure.core/let
> >>>   [ret__1879__auto__
> >>>(clojure.core/eval (clojure.core/read-string generator))] ; The
> >>> unquoting of code resulted in the symbol generator
> >>>   (clojure.core/in-ns 'test-eval)
> >>>   ret__1879__auto__))
> >>>
> >>> If you want to use a var as an argument for the code, you could resolve
> >>> the var before changing namespaces, delaying the read-string until the
> forms
> >>> evaluation:
> >>>
> >>> (ns another-ns)
> >>>
> >>> (defn X [w h] [w h])
> >>> ;---
> >>> (ns this-ns
> >>>   (:require [clojure.pprint :as p]))
> >>>
> >>> (defmacro eval-in
> >>>   [code ns]
> >>>   `(let [code# ~code]
> >>>  (in-ns '~(symbol ns))
> >>>   (let [ret# (eval (read-string code#))]
> >>>(in-ns '~(ns-name *ns*))
> >>>ret#)))
> >>>
> >>> (def generator "(X 300 300)")
>
>

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

Re: Need help in geeting cemerick/friend working with openid

2012-12-19 Thread Murtaza Husain

I have changed the parameter name to 'identifier', however I am still 
hitting the NPE, any ideas? 

I have placed the code on github - https://github.com/murtaza52/cfaiz.git, 
if you would like to take a look. 

Thanks,
Murtaza

On Thursday, December 20, 2012 12:12:27 AM UTC+5:30, Chas Emerick wrote:
>
> The parameter name is 'identifier' (not 'openid_identifier') by default 
> (which you can customize if you want by specifying a :user-identifier-param 
> option in openid/workflow).
>
> That said, the NPE you just hit has drawn my attention to an (unrelated) 
> bug in the openid workflow.  Thanks! :-)
>
> - Chas
>
> On Dec 19, 2012, at 1:20 PM, Murtaza Husain wrote:
>
>
> Thanks for catching that Aaron !
>
> The app currently redirects to the login page now. However I get an error 
> when I try to post to the "/openid" url with {"openid_identifier":"
> https://www.google.com/accounts/o8/id"} as post data.
>
> Here is the updated code - 
>
> (ns faiz.handler
>   (:use compojure.core)
>   (:require [compojure.handler :as handler]
> [compojure.route :as route]
> [ring.util.response :as resp]
> [me.shenfeng.mustache :as mustache]
> [cemerick.friend :as friend]
> (cemerick.friend [workflows :as workflows]
>  [credentials :as creds]
>  [openid :as openid])))
>
> (mustache/deftemplate index (slurp "public/index-async.html"))
>
> (def index-data {:title "Invoize." :brand "Faiz" :links [{:url 
> "#/students" :text "Students"} {:url "#/thaalis" :text "Thaalis"}]})
>
> (defroutes app-routes
>   (GET "/" [] (resp/redirect "/login"))
>   (ANY "/login" [] (resp/file-response "landing.html" {:root "public"}))
>   (GET "/landing" [] (resp/file-response "landing.html" {:root "public"}))
>   (GET "/index" [] (friend/authenticated (index index-data)))
>   (route/files "/" {:root "public"})
>   (route/not-found "Not Found"))
>
> (def app-routes-with-auth
>   (-> app-routes
>   (friend/authenticate
>{:workflows [(openid/workflow :openid-uri "/openid" :realm "
> http://invoize.com"; :credential-fn identity)]})))
>
> (def app
>   (handler/site app-routes-with-auth))
>
>
> Below is the stacktrace -
>
> java.lang.NullPointerExceptionopenid.clj:124
> cemerick.friend.openid/workflow[fn]friend.clj:174
> cemerick.friend/authenticate*[fn]core.clj:2432clojure.core/map[fn]
> LazySeq.java:42clojure.lang.LazySeq.sval
>
> Thanks,
> Murtaza
>
>
>
>
> On Wednesday, December 19, 2012 7:37:04 PM UTC+5:30, Aaron Cohen wrote:
>>
>>
>>
>>
>> On Wed, Dec 19, 2012 at 8:40 AM, Murtaza Husain <
>> murtaza...@sevenolives.com> wrote:
>>>
>>> (defroutes app-routes
>>>   (GET "/" [] (resp/redirect "/landing"))
>>>   (GET "/landing" [] (resp/file-response "landing.html" {:root 
>>> "public"}))
>>>   (GET "/index" [] (index index-data))
>>>   (route/files "/" {:root "public"})
>>>   (route/not-found "Not Found"))
>>>
>>> (def mock-app
>>>   (-> app-routes
>>>   (friend/authenticate
>>>{:allow-anon? false
>>> :login-uri? "/landing"
>>> :workflows [(openid/workflow :openid-uri "/openid" :realm "
>>> http://invoize.com";)]})))
>>>
>>>
>>
>> I'm not fully conversant with all the libraries, but don't you actually 
>> need to use mock-app somewhere?
>>  
>>
>>> (def app
>>>   (handler/site app-routes))
>>>
>>>
> -- 
> 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 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

Re: compojure in production

2012-12-19 Thread Sun Ning
Check out ring-jetty-adapter  
https://github.com/ring-clojure/ring/tree/master/ring-jetty-adapter

The compojure app can be treated as a ring app.

On Thu 20 Dec 2012 08:22:19 AM CST, Maris wrote:


How can I run my compojure app without leiningen ?

I want to use dedicated jetty server (not war file).

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


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To 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


Re: clojure-contrib migrations

2012-12-19 Thread Alasdair MacLeod

On Monday, 17 December 2012 23:44:12 UTC, Christopher Meiklejohn wrote: 
>
> [...]I'd like to offer to step up and maintain clojure-contrib.graph, 
> mainly starting with converting the defstructs over to defrecords [...]
>
Out of interest - why use records rather than plain maps?

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

Re: Little namespace question

2012-12-19 Thread Alan Shaw
Oh! yes it does!

-A



On Wed, Dec 19, 2012 at 6:39 PM, Dave Ray  wrote:

> It does, right?
>
>
> On Wednesday, December 19, 2012, Alan Shaw wrote:
>
>> But returning the evaluation was a requirement...
>>
>>
>> On Wed, Dec 19, 2012 at 2:58 PM, Alan Shaw  wrote:
>>
>> No, there was no requirement that it be a macro. Thanks!
>>
>> -A
>>
>>
>>
>> On Wed, Dec 19, 2012 at 7:40 AM, Dave Ray  wrote:
>>
>> A function seems to work fine unless I don't understand your requirement:
>>
>>   ; normal version that takes code forms and symbols
>>   (defn eval-in
>> [code ns]
>> (let [old (-> *ns* str symbol)]
>>   (try
>> (in-ns ns)
>> (eval code)
>> (finally
>>   (in-ns old)
>>
>>   ; sugary version that takes strings
>>   (defn eval-strs [code-str ns-str]
>> (eval-in (read-string code-str) (symbol ns-str)))
>>
>> and now try it out:
>>
>>   user=> (eval-strs "(def z 500)" "bar")
>>   #'bar/z
>>   user=> (in-ns 'bar)
>>   #
>>   bar=> z
>>   500
>>
>> Making this bullet-proof and deciding whether it's actually a good
>> design is left as an exercise for the reader.
>>
>> Cheers,
>>
>> Dave
>>
>> On Tue, Dec 18, 2012 at 11:22 PM, Alan Shaw  wrote:
>> > As an aside, I'm curious about whether this could have been implemented
>> > without a macro.
>> >
>> > -A
>> >
>> > On Dec 18, 2012 11:06 PM, "Alan Shaw"  wrote:
>> >>
>> >> Thanks very much Juan, that's some good study material for me.
>> >>
>> >> -A
>> >>
>> >> On Dec 18, 2012 10:45 PM, "juan.facorro" 
>> wrote:
>> >>>
>> >>> The macro sees it arguments as symbols and does not resolve to the
>> >>> corresponding var until evaluation, so the value for the local code
>> var in
>> >>> the macro is actually the symbol generator.
>> >>>
>> >>> The eval-in macro uses the read-string function to evaluate the code
>> you
>> >>> provide, this function expects a string but it's getting the symbol
>> >>> generator instead, since that's what the macro got as a first
>> argument.
>> >>>
>> >>> Here's a modified version of the eval-in macro, that delays the
>> >>> evaluation of the call to read-string:
>> >>>
>> >>> (require '[clojure.pprint :as p])
>> >>>
>> >>> (defmacro eval-in
>> >>>   [code ns]
>> >>>   `(do
>> >>>  (in-ns '~(symbol ns))
>> >>>  (let [ret# (eval (read-string ~code))] ; This line was changed
>> >>>(in-ns '~(ns-name *ns*))
>> >>>ret#)))
>> >>>
>> >>> (p/pprint (macroexpand '(eval-in generator "another-ns")))
>> >>>
>> >>> Here's the output:
>> >>>
>> >>> (do
>> >>>  (clojure.core/in-ns 'another-ns)
>> >>>  (clojure.core/let
>> >>>   [ret__1879__auto__
>> >>>(clojure.core/eval (clojure.core/read-string generator))] ; The
>> >>> unquoting of code resulted in the symbol generator
>> >>>   (clojure.core/in-ns 'test-eval)
>> >>>   ret__1879__auto__))
>> >>>
>> >>> If you want to use a var as an argument for the code, you could
>> resolve
>> >>> the var before changing namespaces, delaying the read-string until
>> the forms
>> >>> evaluation:
>> >>>
>> >>> (ns another-ns)
>> >>>
>> >>> (defn X [w h] [w h])
>> >>> ;---
>> >>> (ns this-ns
>> >>>   (:require [clojure.pprint :as p]))
>> >>>
>> >>> (defmacro eval-in
>> >>>   [code ns]
>> >>>   `(let [code# ~code]
>> >>>  (in-ns '~(symbol ns))
>> >>>   (let [ret# (eval (read-string code#))]
>> >>>(in-ns '~(ns-name *ns*))
>> >>>ret#)))
>> >>>
>> >>> (def generator "(X 300 300)")
>>
>>  --
> 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 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

Re: Tail call in multi method?

2012-12-19 Thread bruce li
Very helpful. Thanks so much!

2012/12/18 Chas Emerick 

> On Dec 17, 2012, at 12:39 PM, Ben Wolfson wrote:
>
> > On Mon, Dec 17, 2012 at 9:32 AM, Chas Emerick  wrote:
> >>
> >> What you're trying to do is really a special case of mutual recursion:
> >> because Clojure's methods are separate functions, calling back through
> the
> >> multimethod (and its dispatch fn) will always consume stack space.  The
> >> general solution for this is to use `trampoline`, which will
> continuously
> >> call through functions returned from calling a function until a
> non-function
> >> value is returned.  This would allow you to make your multimethod
> >> mutually-recursive, as long as those recursive calls are made by
> returning a
> >> function (that the user of the multimethod would `trampoline` through):
> >
> > Also as long as you don't want to return a function from the
> multimethod, no?
>
> Correct.  As noted in the docs for `trampoline`:
>
> ...if you want to return a fn as a final value, you must wrap it
> in some data structure and unpack it after trampoline returns.
>
> I can't say I've ever needed to write mutually-recursive higher-order
> functions.  I can only presume that doing so while needing to meet
> trampoline's contract for that corner case would be fairly cumbersome.
>
> IIRC, `trampoline` predated functions supporting metadata by some time.
>  If it were written again now, it might specify that metadata should be
> used to indicate that a function should be called-through, rather than
> returned as a non-intermediate value.  e.g.:
>
> (defn meta-trampoline
>   ([f]
>  (let [ret (f)]
>(if (and (fn? ret) (-> ret meta :trampoline))
>  (recur ret)
>  ret)))
>   ([f & args]
>  (meta-trampoline #(apply f args
>
> With this, you can return whatever you want/need to, as long as you mark
> the self- or mutually-recursive calls with {:trampoline true} metadata:
>
> => (defmethod foo String
>  [x]
>  #(str "I got " x ", you gave me " %))
> #
> => (defmethod foo Long
>  [x]
>  ^:trampoline #(foo (str x)))
> #
> => (meta-trampoline foo 5)
> # >
> => (*1 6)
> "I got 5, you gave me 6"
>
> Cheers,
>
> - Chas
>
> --
> 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 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

Re: Two clojure with emacs questions

2012-12-19 Thread Tassilo Horn
Jonathon McKitrick  writes:

>> Yes, then you are using nrepl and not SLIME/Swank.  I use that, too,
>> and I haven't encountered hangs with (in-ns ...) forms yet.  If you
>> have your project accessible somewhere, I'm happy to try to reproduce
>> the issue.
>
> I have a bit more information.
>
> The interface hangs running in Carbon Emacs, but not in -nw mode.

I'd try the Emacs builds from http://emacsformacosx.com.  AFAICS, Carbon
Emacs is pretty outdated (last release in 2010).

> Sounds like a bug report is due?

Yes, at least if you can reproduce the problem with a pure GNU Emacs
from emacsformacosx.com, starting with emacs -Q and then only loading
the packages needed to reproduce the issue (nrepl.el and maybe
clojure-mode).

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