Re: I'm trying to make proper urls, but I seem to be failing at it.

2014-02-25 Thread Rob Day
What are url-encode and url-decode doing wrong? They look like they
should work (e.g.
https://github.com/ring-clojure/ring-codec/blob/master/test/ring/util/test/codec.clj#L21).

On 25 February 2014 07:14, David Toomey  wrote:
> I'm building a site and I would like to allow users to create and account,
> and I would like them to have an option to use whitespaces in their handle.
> Apparently I am doing something way wrong here, so it is possible that I
> messed up something somewhere else.
>
> When I create a user, for example "some user", this user name is inserted
> into a database. The site is set up so that users can have profiles. This
> person's profile would be this:
>
>   www.mysite/some user
>
> That is bad. I am hoping to have profile pages look like this:
>
>  www.mysite/some%20user
>
> or:
>
>   www.mysite/some-user
>
> I attempted to use (url-encode), (url-decode), regex, and all sorts of
> things. Nothing I have tried has worked.
>
> I'm actually kind of surprised that this isn't baked into Compojure itself,
> but I digress.
>
> Thanks;
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Robert K. Day
robert@merton.oxon.org

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


Re: why not apply-macro

2014-02-25 Thread 刘家财
hi JW,
First thank you for your reply.
my origin question is somethine about redis.here i refer 
https://github.com/ptaoussanis/carmine 
I follow this two line
 (def server1-conn {:pool {} :spec {}}) ; See `wcar` docstring 
for opts

(defmacro wcar* [& body] `(car/wcar server1-conn ~@body))

then I can exec some redis commands,but I want to exec commands dynamicly.
for example I here a vector [["foo" "bar"]["hello" "world"]]
i want to exec following commands
(wcar* (car/set "foo" "bar") (car/set "hello" "world"))
so i have write a macro like this

(defmacro batchly-redis [cmd params] 
  (let [car-fns (map #(cons cmd %) params)]
`(wcar* ~@car-fns)))


then I can invoke this macro using this way
(batchly-redis cat/set [["foo" "bar"]["hello" "world"]])
in this way,my macro works ok.but here my vector is coming from the return 
of other fn ,so as you said above,this will not work, because marco 
evaluates args at compile time.Do your have some ideas on my problem.
Really thanks


在 2014年2月24日星期一UTC+8下午6时29分09秒,Jozef Wagner写道:
>
> Well the evil thing is that apply-macro evaluates arguments at compile 
> time. Example where this won't work follows
>
> (defn foo [numbers]
>   (apply-macro + numbers))
>
> JW
>
>
> On Mon, Feb 24, 2014 at 10:27 AM, 刘家财 >wrote:
>
>> I have one problem using Clojure
>> we all know there is a apply for a fn to prepend intervening arguments to 
>> args. 
>> such as (apply + [2 3]) will equals to (+ 2 3)
>> this is really handy,
>> BUT,this is no apply-macro fn to use,I find a contrib(
>> https://github.com/clojure/clojure-contrib/blob/73accf597eafb8dfcb642702a3b98b057bbdbbdf/src/main/clojure/clojure/contrib/apply_macro.clj#L34)
>>  
>> which has somethine like this,but deprecated.
>> and says it is evil,I can't understand why the docs says it was evil?
>> Is there anything harmful? Can someone show me some examples?
>> Thank U
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


Re: Email delivery libs not working

2014-02-25 Thread The Dude (Abides)
I managed to get Postal delivery working with Mandrill, still use of 
templates with formatting v helpful. Mailer and Postal have a slight 
problem on recognizing the meta info for smtp auth.

So with some fiddling figured out how to merge Clostache into Postal for 
html templates with dynamic vars as follows:

dependencies:  [com.draines/postal "1.11.1"]
 [de.ubercode.clostache/clostache "1.3.1"]

(:use   clostache.parser)
(:require  [postal.core :as postal]

(postal/send-message 
^{:host "smtp.mandrillapp.com"
  :user "your mandrill acct email address"
  :pass "your mandrill api key"
  :port 587}
 {:type "text/html" 
  :from "from email address"
  :to "to email address"
  :subject (render "Hi from {{firstname}}" {:firstname (session/get 
:firstname)})
  :body [{:type "text/html; charset=utf-8"
  :content (render-resource 
"email/templates/hello.html.mustache" 
   {:name "Uncle Scooby" :memberid (session/get :member-id)}) 
}] })

The hello.html.mustache template file:

Hello {{name}},

My member id is: {{memberid}}

Best,
Scrappy Doo.

The template path root is the app src folder. So your 
app/src/email/templates/hello.html.mustache

So this works but the use of Clostache still seems a bit boilerplatish. 
Does anyone know of a more elegant option if possible.

Thank you for the other tips, will try out the native java and the other 
Mandrill code option, see which is the best overall approach long term.

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


Re: Email delivery libs not working

2014-02-25 Thread Michael Klishin
2014-02-25 14:08 GMT+04:00 The Dude (Abides) :

> (postal/send-message
> ^{:host "smtp.mandrillapp.com"
>   :user "your mandrill acct email address"
>   :pass "your mandrill api key"
>   :port 587}
>  {:type "text/html"
>   :from "from email address"
>   :to "to email address"
>   :subject (render "Hi from {{firstname}}" {:firstname (session/get
> :firstname)})
>   :body [{:type "text/html; charset=utf-8"
>   :content (render-resource
> "email/templates/hello.html.mustache"
>{:name "Uncle Scooby" :memberid (session/get :member-id)})
> }] })
>

Let me just say that the choice to use metadata to pass crucial connection
arguments
in Postal was wrong.

We will be replacing Postal in ClojureWerkz Mailer for this reason.
-- 
MK

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

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


Re: why not apply-macro

2014-02-25 Thread James Reeves
You could just write it as a function and leave out wcar*.

(defn batchly-redis [cmd params]
  (doseq [params]
(apply cmd params)))

Then to execute:

(wcar* (batchly-redis cat/set parameters))

As far as I can tell, wcar is just a container macro, like with-open, in
that it initiates the connection and then cleans up after itself. Within
wcar, you can execute functions in whatever way you want.

- James


On 25 February 2014 09:00, 刘家财  wrote:

> hi JW,
> First thank you for your reply.
> my origin question is somethine about redis.here i refer
> https://github.com/ptaoussanis/carmine
> I follow this two line
>  (def server1-conn {:pool {} :spec {}}) ; See `wcar`
> docstring for opts
>
> (defmacro wcar* [& body] `(car/wcar server1-conn ~@body))
>
> then I can exec some redis commands,but I want to exec commands dynamicly.
> for example I here a vector [["foo" "bar"]["hello" "world"]]
> i want to exec following commands
> (wcar* (car/set "foo" "bar") (car/set "hello" "world"))
> so i have write a macro like this
>
> (defmacro batchly-redis [cmd params]
>   (let [car-fns (map #(cons cmd %) params)]
> `(wcar* ~@car-fns)))
>
>
> then I can invoke this macro using this way
> (batchly-redis cat/set [["foo" "bar"]["hello" "world"]])
> in this way,my macro works ok.but here my vector is coming from the return
> of other fn ,so as you said above,this will not work, because marco
> evaluates args at compile time.Do your have some ideas on my problem.
> Really thanks
>
>
> 在 2014年2月24日星期一UTC+8下午6时29分09秒,Jozef Wagner写道:
>>
>> Well the evil thing is that apply-macro evaluates arguments at compile
>> time. Example where this won't work follows
>>
>> (defn foo [numbers]
>>   (apply-macro + numbers))
>>
>> JW
>>
>>
>> On Mon, Feb 24, 2014 at 10:27 AM, 刘家财  wrote:
>>
>>> I have one problem using Clojure
>>> we all know there is a apply for a fn to prepend intervening arguments
>>> to args.
>>> such as (apply + [2 3]) will equals to (+ 2 3)
>>> this is really handy,
>>> BUT,this is no apply-macro fn to use,I find a contrib(
>>> https://github.com/clojure/clojure-contrib/blob/
>>> 73accf597eafb8dfcb642702a3b98b057bbdbbdf/src/main/clojure/
>>> clojure/contrib/apply_macro.clj#L34) which has somethine like this,but
>>> deprecated.
>>> and says it is evil,I can't understand why the docs says it was evil?
>>> Is there anything harmful? Can someone show me some examples?
>>> Thank U
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>>
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>>
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Why is Clojure faster than Java at this task?

2014-02-25 Thread Jonathan Barnard
I recently did a benchmark (admittedly in hindsight not a particularly good 
one) that involved comparison of an implementation of the same small 
program in 
Javaand 
in 
Clojure,
 
in which most of the time is spent in bignum operations. The results are at 
this 
link(the
 tables at the top; ignore the rest). The Clojure implementation 
appears to consistently perform better than the Java implementation (at 
least on this setup, x86-64 Linux with OpenJDK 1.7.0_25). I'd be interested 
to learn what Clojure does to make it perform faster than Java in this 
case, so I thought here might be a good place to ask.

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


Re: Email delivery libs not working

2014-02-25 Thread exel...@gmail.com
Let me know whenever its updated, dynamic email and img resize v heavy use 
cases. 

You guys are doing an amazing job with all the libs, most of them higher end 
stuff. I've never done msg queuing or used a graph db, so looking forward to 
expanding. Its a polygot reality hereon.

P.


On Feb 25, 2014, at 2:12 AM, Michael Klishin wrote:

> 2014-02-25 14:08 GMT+04:00 The Dude (Abides) :
> (postal/send-message 
> ^{:host "smtp.mandrillapp.com"
>   :user "your mandrill acct email address"
>   :pass "your mandrill api key"
>   :port 587}
>  {:type "text/html" 
>   :from "from email address"
>   :to "to email address"
>   :subject (render "Hi from {{firstname}}" {:firstname (session/get 
> :firstname)})
>   :body [{:type "text/html; charset=utf-8"
>   :content (render-resource "email/templates/hello.html.mustache" 
>{:name "Uncle Scooby" :memberid (session/get :member-id)}) }] 
> })
> 
> Let me just say that the choice to use metadata to pass crucial connection 
> arguments
> in Postal was wrong.
> 
> We will be replacing Postal in ClojureWerkz Mailer for this reason.
> -- 
> MK
> 
> http://github.com/michaelklishin
> http://twitter.com/michaelklishin
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Clojure" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/clojure/U8U8WfV0GR8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

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


Re: why not apply-macro

2014-02-25 Thread 刘家财
Hi James,
I really appreciate your code,it really help me much.
just a little modification:

(defn batchly-redis [cmd params]
  (doseq [p params]
(apply cmd p)))

doseq requires an even number of args

在 2014年2月25日星期二UTC+8下午6时33分48秒,James Reeves写道:
>
> You could just write it as a function and leave out wcar*.
>
> (defn batchly-redis [cmd params]
>   (doseq [params]
> (apply cmd params)))
>
> Then to execute:
>
> (wcar* (batchly-redis cat/set parameters))
>
> As far as I can tell, wcar is just a container macro, like with-open, in 
> that it initiates the connection and then cleans up after itself. Within 
> wcar, you can execute functions in whatever way you want.
>
> - James
>
>
> On 25 February 2014 09:00, 刘家财 > wrote:
>
>> hi JW,
>> First thank you for your reply.
>> my origin question is somethine about redis.here i refer 
>> https://github.com/ptaoussanis/carmine 
>> I follow this two line
>>  (def server1-conn {:pool {} :spec {}}) ; See `wcar` 
>> docstring for opts
>>
>> (defmacro wcar* [& body] `(car/wcar server1-conn ~@body))
>>
>> then I can exec some redis commands,but I want to exec commands dynamicly.
>> for example I here a vector [["foo" "bar"]["hello" "world"]]
>> i want to exec following commands
>> (wcar* (car/set "foo" "bar") (car/set "hello" "world"))
>> so i have write a macro like this
>>
>> (defmacro batchly-redis [cmd params] 
>>   (let [car-fns (map #(cons cmd %) params)]
>> `(wcar* ~@car-fns)))
>>
>>
>> then I can invoke this macro using this way
>> (batchly-redis cat/set [["foo" "bar"]["hello" "world"]])
>> in this way,my macro works ok.but here my vector is coming from the 
>> return of other fn ,so as you said above,this will not work, because marco 
>> evaluates args at compile time.Do your have some ideas on my problem.
>> Really thanks
>>
>>
>> 在 2014年2月24日星期一UTC+8下午6时29分09秒,Jozef Wagner写道:
>>>
>>> Well the evil thing is that apply-macro evaluates arguments at compile 
>>> time. Example where this won't work follows
>>>
>>> (defn foo [numbers]
>>>   (apply-macro + numbers))
>>>
>>> JW
>>>
>>>
>>> On Mon, Feb 24, 2014 at 10:27 AM, 刘家财  wrote:
>>>
 I have one problem using Clojure
 we all know there is a apply for a fn to prepend intervening arguments 
 to args. 
 such as (apply + [2 3]) will equals to (+ 2 3)
 this is really handy,
 BUT,this is no apply-macro fn to use,I find a contrib(
 https://github.com/clojure/clojure-contrib/blob/
 73accf597eafb8dfcb642702a3b98b057bbdbbdf/src/main/clojure/
 clojure/contrib/apply_macro.clj#L34) which has somethine like this,but 
 deprecated.
 and says it is evil,I can't understand why the docs says it was evil?
 Is there anything harmful? Can someone show me some examples?
 Thank U


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

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

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

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

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

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

ANN: Chord 0.3.0 - WebSockets as core.async channels

2014-02-25 Thread James Henderson
I've just pushed v0.3.0 of Chord, a library to make a WebSockets appear as 
a bi-directional core.async channels.

More info on GitHub .

New since 0.2.2:

   - Messages over the channel treated as EDN by default (although option 
   to fall back to previous raw strings) - this saves wrapping every write 
   with `pr-str` and every read with `edn/read-string`

As usual, feedback welcome!

Cheers,

James

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


Image Resizer lib exception error

2014-02-25 Thread The Dude (Abides)
Hi, I'm trying to use Image Resizer and am goofing up on the syntax 
somewhere:

(defn update-profile [firstname lastname email file]
  (let [member-id (session/get :member-id) 
redirecturl  (str "/member/" member-id)
original-file-path(str (img-path) "/" (:filename file))
new-file-name   (add-timestamp (:filename file))
new-name-filepath (str (img-path) "/" new-file-name)]
  (upload-file (img-path) (update-in file [:filename] add-timestamp))
  (-> new-name-filepath
((resize-fn 100 100)))
  (memberdb/update-member member-id firstname lastname email (str 
new-file-name))
  (resp/redirect redirecturl)
  ))

I get the following error:

java.lang.IllegalArgumentException
No matching method found: read
Reflector.java:80clojure.lang.Reflector.invokeMatchingMethod
Reflector.java:207clojure.lang.Reflector.invokeStaticMethodutil.clj:10
image-resizer.util/buffered-imageresize.clj:31
image-resizer.resize/resize-fn[fn]members.clj:101
sikhpyar.routes.members/update-profile2members.clj:168
sikhpyar.routes.members/fncore.clj:94compojure.core/make-route[fn]
core.clj:40compojure.core/if-route[fn]core.clj:25
compojure.core/if-method[fn]core.clj:107compojure.core/routing[fn]
core.clj:2443clojure.core/somecore.clj:107compojure.core/routing

Does anyone have any experience with this lib and the correct way to employ 
it, I'm not making much progress from the readme docs. Thanks.

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


Re: Image Resizer lib exception error

2014-02-25 Thread Moritz Ulrich

Just from the looks of the exception, you might need to pass an
input-stream or reader instead of a path.

The Dude (Abides) writes:

> Hi, I'm trying to use Image Resizer and am goofing up on the syntax 
> somewhere:
>
> (defn update-profile [firstname lastname email file]
>   (let [member-id (session/get :member-id) 
> redirecturl  (str "/member/" member-id)
> original-file-path(str (img-path) "/" (:filename file))
> new-file-name   (add-timestamp (:filename file))
> new-name-filepath (str (img-path) "/" new-file-name)]
>   (upload-file (img-path) (update-in file [:filename] add-timestamp))
>   (-> new-name-filepath
> ((resize-fn 100 100)))
>   (memberdb/update-member member-id firstname lastname email (str 
> new-file-name))
>   (resp/redirect redirecturl)
>   ))
>
> I get the following error:
>
> java.lang.IllegalArgumentException
> No matching method found: read
> Reflector.java:80clojure.lang.Reflector.invokeMatchingMethod
> Reflector.java:207clojure.lang.Reflector.invokeStaticMethodutil.clj:10
> image-resizer.util/buffered-imageresize.clj:31
> image-resizer.resize/resize-fn[fn]members.clj:101
> sikhpyar.routes.members/update-profile2members.clj:168
> sikhpyar.routes.members/fncore.clj:94compojure.core/make-route[fn]
> core.clj:40compojure.core/if-route[fn]core.clj:25
> compojure.core/if-method[fn]core.clj:107compojure.core/routing[fn]
> core.clj:2443clojure.core/somecore.clj:107compojure.core/routing
>
> Does anyone have any experience with this lib and the correct way to employ 
> it, I'm not making much progress from the readme docs. Thanks.


-- 
Moritz Ulrich


pgpzSjHvaFY_D.pgp
Description: PGP signature


Re: Image Resizer lib exception error

2014-02-25 Thread Michael Klishin
2014-02-25 16:46 GMT+04:00 Moritz Ulrich :

> Just from the looks of the exception, you might need to pass an
> input-stream or reader instead of a path.
>

which can be instantiated with

http://clojuredocs.org/clojure_core/clojure.java.io/input-stream

and

http://clojuredocs.org/clojure_core/clojure.java.io/reader

-- 
MK

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

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


Re: Why is Clojure faster than Java at this task?

2014-02-25 Thread Rob Day
It looks like an improvement in clojure.lang.BigInt over
java.math.BigInteger - BigInt's add() method seems to do a long + long
add if it doesn't overflow
(https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/BigInt.java#L142)
and only fall back to BigInteger's add method (which has no such
optimisation - 
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/math/BigInteger.java#BigInteger.add%28java.math.BigInteger%29)
if the overhead of BigInteger is actually needed.

If you use clojure.lang.BigInt in your Java code, I suspect Java will be faster.

On 25 February 2014 10:38, Jonathan Barnard
 wrote:
> I recently did a benchmark (admittedly in hindsight not a particularly good
> one) that involved comparison of an implementation of the same small program
> in Java and in Clojure, in which most of the time is spent in bignum
> operations. The results are at this link (the tables at the top; ignore the
> rest). The Clojure implementation appears to consistently perform better
> than the Java implementation (at least on this setup, x86-64 Linux with
> OpenJDK 1.7.0_25). I'd be interested to learn what Clojure does to make it
> perform faster than Java in this case, so I thought here might be a good
> place to ask.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Robert K. Day
robert@merton.oxon.org

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


Re: I'm trying to make proper urls, but I seem to be failing at it.

2014-02-25 Thread Dave Della Costa
You can use the default Java classes which are available:

=> (-> (java.net.URI. "http" "www.mysite" "/some user" nil) .toURL
.toString)
"http://www.mysite/some%20user";
=>

ring-codec is easy too:

(https://github.com/ring-clojure/ring-codec)

=> (str "www.mysite/" (ring.util.codec/url-encode "some user"))
"www.mysite/some%20user"
=>


(2014/02/25 16:14), David Toomey wrote:
> I'm building a site and I would like to allow users to create and
> account, and I would like them to have an option to use whitespaces in
> their handle. Apparently I am doing something way wrong here, so it is
> possible that I messed up something somewhere else.
> 
> When I create a user, for example "some user", this user name is
> inserted into a database. The site is set up so that users can have
> profiles. This person's profile would be this:
> 
>   www.mysite/some user
> 
> That is bad. I am hoping to have profile pages look like this:
> 
>  www.mysite/some%20user
> 
> or:
> 
>   www.mysite/some-user
> 
> I attempted to use (url-encode), (url-decode), regex, and all sorts of
> things. Nothing I have tried has worked.
> 
> I'm actually kind of surprised that this isn't baked into Compojure
> itself, but I digress.
> 
> Thanks;
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

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


Re: Why is Clojure faster than Java at this task?

2014-02-25 Thread Alex Miller
Hi Jonathan,

I provided the Clojure pull request btw. I think Rob's explanation is 
correct.

Alex


On Tuesday, February 25, 2014 7:20:46 AM UTC-6, Rob Day wrote:
>
> It looks like an improvement in clojure.lang.BigInt over 
> java.math.BigInteger - BigInt's add() method seems to do a long + long 
> add if it doesn't overflow 
> (
> https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/BigInt.java#L142)
>  
>
> and only fall back to BigInteger's add method (which has no such 
> optimisation - 
> http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/math/BigInteger.java#BigInteger.add%28java.math.BigInteger%29)
>  
>
> if the overhead of BigInteger is actually needed. 
>
> If you use clojure.lang.BigInt in your Java code, I suspect Java will be 
> faster. 
>
> On 25 February 2014 10:38, Jonathan Barnard 
> > wrote: 
> > I recently did a benchmark (admittedly in hindsight not a particularly 
> good 
> > one) that involved comparison of an implementation of the same small 
> program 
> > in Java and in Clojure, in which most of the time is spent in bignum 
> > operations. The results are at this link (the tables at the top; ignore 
> the 
> > rest). The Clojure implementation appears to consistently perform better 
> > than the Java implementation (at least on this setup, x86-64 Linux with 
> > OpenJDK 1.7.0_25). I'd be interested to learn what Clojure does to make 
> it 
> > perform faster than Java in this case, so I thought here might be a good 
> > place to ask. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@googlegroups.com 
> > Note that posts from new members are moderated - please be patient with 
> your 
> > first post. 
> > To unsubscribe from this group, send email to 
> > clojure+u...@googlegroups.com  
> > For more options, visit this group at 
> > http://groups.google.com/group/clojure?hl=en 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Clojure" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to clojure+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
>
>
> -- 
> Robert K. Day 
> rober...@merton.oxon.org  
>

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


How to override the default port on 3000?

2014-02-25 Thread action
I do like this:
#lein new compojure-app guestbook
#cd guestbook
#lein ring server

The server runs on port 3000 by default. 
But how to override the default port?
Such as runs on port 80?

thinks


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


Help with data structures and dereferencing

2014-02-25 Thread Robert Quinn


new to clojure, in the process of unlearning years of OO.  sorry for the 
long post.

struggling with a design/impl and hoping to get some outside opinions so I 
can understand my options (clojure better)

basic concepts are straightforward and in a nutshell I'm modeling entities 
and relationships  (aren't we all)

---

created a pool of entities (people and groups) implemented as maps.  each 
map has a :rels which is set of relationships to other entities.  the pool 
is an atom.

first approach; relationships are in the entity, add RHS entities into the 
LHS :rels.  the state of the RHS can change, I need the latest state of RHS 
not as it was when the relationship was created. I decided not to make each 
entity a ref (ref, atom, agent), it seemed too fine grained. *thoughts?*

each entity has a uuid

second approach, a pool of relationships (:lhs uuid :rhs uuid :type x). 
pool has all the relationships, also an atom.  the pool has lots of 
benefits it "improves" other parts of the code.

it doesn't solve the original problem, just moves it around, i still can't 
put the actual RHS, so i'm using the uuid as a reference, i look up RHS get 
the latest. (second guessing why didn't i make them atoms and use @uuid).

now my relationships aren't embedded in my entity, that doesn't feel right, 
anyone dealing with the entity should still be able to say... (:rels 
entity) and get the relationships, so i add a function to :rels that 
returns all the relationship based on the uuid of the LHS, this works 
great. syntax changes and requires me to use ((:rels entity)).

*the problem is... (assumes everything within a single process)*

I want to pass this data structure around and now dereferencing is bleeding 
out.  Instead of passing around a data structure, I'm passing around a data 
structure that has functions embedded in it.  which seems like a cool idea, 
but now the callee needs to know that :rels returns a function, when it's 
supposed to have data in it. (which is the same thing?) but I don't know 
how to treat it seamlessly.  (i have not considered eval).

for the :rels it's not too bad.  doesn't feel like I'm using all the power 
correctly, but it works.

*additional problem is, my rels look like this.*

(:lhs uuid :rhs uuid :type x)

 :lhs and :rhs "should be" entities, not references.  more functions?  I 
make :lhs and :rhs return functions which dereference entities. of course 
that makes selecting from rel-pool much harder 

that's when I knew I had to seek professional help [image: (smile)]

even with a long post hard to capture all the requirements... 


   1. the pools aren't supposed to be "public" so I can't have all the 
   callee functions understanding how to do the dereference.  
   2. the :rels function isn't one function, the truth is the rels-pool 
   doesn't have all relationships, some are virtual, the function creates them 
   on the fly, each entity could have it's own version of "get-relationships"
   
any help is appreciated.

i've considered

   - creating a function that "denormalizes" the data before sending it out 
   to.  now its fully formed but i lose some recency (not much diff i know)
   - centralizing all the derefs functions - so the callee knows that all 
   the data isn't embedded but the functions don't live in structure, just the 
   uuids... that works well for LHS/RHS deref, but makes the per entity 
   virtual relationships much harder.  
   - rethinking my atom granularity and using @ but i don't think that 
   really helps


thanks for reading

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


[GSoC]: How to participate

2014-02-25 Thread Daniel Solano Gómez
Hello, all,

There were a number of questions about how to participate in Clojure's
Google Summer of Code effort in my last GSoC post, enough that I felt it
warranted its own thread.  There is a section on the wiki about getting
involved [1], but I'll make a few suggestions here.


Everyone


Please talk about GSoC at your Clojure user group meetings.  If you
happen to work at a university, the GSoC team has some materials
available [2] if you are interested in putting on a promotional event.


Mentors
===

If you are interested in being a mentor, even as a secondary/backup
mentor, there are a few things you can do:

1. Sign up to be a mentor on Melange [3].  You will need to sign in with
a Google account, create a profile, and request a connection with
Clojure.

2. If you have any ideas that are not on our Project Ideas page [4],
please add them.  If you don't have write access to the wiki, feel free
to post them to this mailing list with '[GSoC Idea]', and we'll add it
for you.

3. Feel free to talk about GSoC on other project mailing lists.

4. Engage with students who express an interest in a project that might
interest you.


Students


The student application period will be from the 10th to 21st of March.
>From now through then, you should research your project, get know
members, and engage the community.  Posting your project ideas to this
mailing list is a great way to achieve the last two.  Remember that
having a good rapport with your mentors and the community is one of the
most important criteria for being selected as a GSoC student.

As far as project ideas go, check out the project ideas page [4], but
don't feel restricted to that.  You can do any project so long as you
can find a suitable mentor, and it both involves Clojure programming and
has a reasonable scope.


I hope this helps.  Thanks for helping out with Clojure's GSoC effort.

Sincerely,

Daniel


[1]: 
http://dev.clojure.org/display/community/Google+Summer+of+Code+2014#GoogleSummerofCode2014-Gettinginvolved
[2]: 
https://www.google-melange.com/gsoc/document/show/gsoc_program/google/gsoc2014/help_page#3._What_can_I_do_to_spread_the_word
[3]: https://www.google-melange.com/gsoc/homepage/google/gsoc2014
[4]: http://dev.clojure.org/display/community/Project+Ideas

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


Re: How to override the default port on 3000?

2014-02-25 Thread Timothy Washington
Try this.

*lein ring server-headless   ;; port 80 usually requires
root permissions*



Tim Washington
Interruptsoftware.com 


On Tue, Feb 25, 2014 at 9:21 AM, action  wrote:

> I do like this:
> #lein new compojure-app guestbook
> #cd guestbook
> #lein ring server
>
> The server runs on port 3000 by default.
> But how to override the default port?
> Such as runs on port 80?
>
> thinks
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: Image Resizer lib exception error

2014-02-25 Thread The Dude (Abides)
Hi Moritz and Michael, thanks for the pointer in the right direction. 
Almost there except for 1 point I think. The whole operation is made of 2 
functions, one to upload/resize/save and the other to provide a unique 
filename by original filename + timestamp.

(defn add-timestamp [filename]
 (let [ext-position (.lastIndexOf filename ".")
   timestamp(tc/to-long (time/now))]
   (if (pos? ext-position)
 (str (.substring filename 0 ext-position)
  "-" timestamp (.substring filename ext-position))
 (str filename "-" timestamp

(defn update-profile2 [firstname lastname email file]
  (let [member-id (session/get :member-id) 
redirecturl   (str "/member/" member-id)
originalfile  (str (img-path) "/" (:filename file))
new-file-name (add-timestamp (:filename file))
photofile (str (img-path) "/" new-file-name)]
  (upload-file (img-path) *(update-in file [:filename] new-file-name))*
  (resize (file (with-open [rdr (clojure.java.io/reader photofile)])) 100 
100)
  (memberdb/update-member member-id firstname lastname email (str 
new-file-name))
  (resp/redirect redirecturl)))

I checked output of new-file-name and photofile, they do provide the new 
file name alone or with full path.

Where I'm still goofing up is applying new-file-name to the update-in 
function, prob cause its 6am :) Been at it too long, likely missing the 
obvious.

If I can update the filename to *new-file-name*, the *with-open reader *should 
read the file so it can be resized.

Pardeep.

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


Re: Image Resizer lib exception error

2014-02-25 Thread The Dude (Abides)
Hi Moritz and Michael, thanks for the pointer in the right direction. 
Almost there except for 1 point I think. The whole operation is made of 2 
functions, one to upload/resize/save and the other to provide a unique 
filename by original filename + timestamp.

(defn add-timestamp [filename]
 (let [ext-position (.lastIndexOf filename ".")
   timestamp(tc/to-long (time/now))]
   (if (pos? ext-position)
 (str (.substring filename 0 ext-position)
  "-" timestamp (.substring filename ext-position))
 (str filename "-" timestamp

(defn update-profile2 [firstname lastname email file]
  (let [member-id (session/get :member-id) 
redirecturl   (str "/member/" member-id)
originalfile  (str (img-path) "/" (:filename file))
*new-file-name* (add-timestamp (:filename file))
photofile (str (img-path) "/" new-file-name)]
  (upload-file (img-path) *(update-in *file [:filename] *new-file-name*))   
<--- this is where I'm stuck, changing the name of the uploaded file
  (resize (file (with-open [rdr (clojure.java.io/reader photofile)])) 100 
100)
  (memberdb/update-member member-id firstname lastname email (str 
new-file-name))
  (resp/redirect redirecturl)))

I checked output of new-file-name and photofile, they do provide the new 
file name alone or with full path.

Where I'm still goofing up is applying *new-file-name* to the 
*update-in*function, prob cause its now 6am :) 

If I can update the filename to *new-file-name *value, the *with-open*reader 
should read the file so it can be resized.

Pardeep.

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


Re: How to override the default port on 3000?

2014-02-25 Thread Jason Stewart
The lein-ring plugin accepts a port number as an argument:

lein ring server 8080

Note, that in order to bind to port 80, you will need elevated (root)
privileges.


On Tue, Feb 25, 2014 at 9:21 AM, action  wrote:

> I do like this:
> #lein new compojure-app guestbook
> #cd guestbook
> #lein ring server
>
> The server runs on port 3000 by default.
> But how to override the default port?
> Such as runs on port 80?
>
> thinks
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: How to override the default port on 3000?

2014-02-25 Thread Josh Kamau
you can also change this line on your project.clj

:ring {:handler myproject.handler/app :port 8080}

Josh



On Tue, Feb 25, 2014 at 5:23 PM, Jason Stewart wrote:

> The lein-ring plugin accepts a port number as an argument:
>
> lein ring server 8080
>
> Note, that in order to bind to port 80, you will need elevated (root)
> privileges.
>
>
> On Tue, Feb 25, 2014 at 9:21 AM, action  wrote:
>
>> I do like this:
>> #lein new compojure-app guestbook
>> #cd guestbook
>> #lein ring server
>>
>> The server runs on port 3000 by default.
>> But how to override the default port?
>> Such as runs on port 80?
>>
>> thinks
>>
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: Help with data structures and dereferencing

2014-02-25 Thread Dave Della Costa
Is there no way to simply structure the maps inside your main atom in
such a way that you can look up your entities?

{lhs-uuid1 {rhs-uuid1 ["values"] rhs-uuid2 ["values"]}}

(get-in @myatom [lhs-uuid1 rhs-uuid2])

You can wrap this in a function that does some other work to look it up
if need be, if the result of the above is nil (for example)...etc.

Seems like you're making things more complicated than they need to be
here, but it's hard to know without knowing more about your data.

But if I were you I would start there, as I've found thinking hard about
the structure of your data and and using the facilities provided by the
standard library usually helps simplify things tremendously.

(2014/02/25 23:14), Robert Quinn wrote:
> new to clojure, in the process of unlearning years of OO.  sorry for the
> long post.
> 
> struggling with a design/impl and hoping to get some outside opinions so
> I can understand my options (clojure better)
> 
> basic concepts are straightforward and in a nutshell I'm modeling
> entities and relationships  (aren't we all)
> 
> ---
> 
> created a pool of entities (people and groups) implemented as maps.
>  each map has a :rels which is set of relationships to other entities.
>  the pool is an atom.
> 
> first approach; relationships are in the entity, add RHS entities into
> the LHS :rels.  the state of the RHS can change, I need the latest state
> of RHS not as it was when the relationship was created. I decided not to
> make each entity a ref (ref, atom, agent), it seemed too fine grained.
> *thoughts?*
> 
> each entity has a uuid
> 
> second approach, a pool of relationships (:lhs uuid :rhs uuid :type x).
> pool has all the relationships, also an atom.  the pool has lots of
> benefits it "improves" other parts of the code.
> 
> it doesn't solve the original problem, just moves it around, i still
> can't put the actual RHS, so i'm using the uuid as a reference, i look
> up RHS get the latest. (second guessing why didn't i make them atoms and
> use @uuid).
> 
> now my relationships aren't embedded in my entity, that doesn't feel
> right, anyone dealing with the entity should still be able to say...
> (:rels entity) and get the relationships, so i add a function to :rels
> that returns all the relationship based on the uuid of the LHS, this
> works great. syntax changes and requires me to use ((:rels entity)).
> 
> *the problem is... (assumes everything within a single process)*
> 
> I want to pass this data structure around and now dereferencing is
> bleeding out.  Instead of passing around a data structure, I'm passing
> around a data structure that has functions embedded in it.  which seems
> like a cool idea, but now the callee needs to know that :rels returns a
> function, when it's supposed to have data in it. (which is the same
> thing?) but I don't know how to treat it seamlessly.  (i have not
> considered eval).
> 
> for the :rels it's not too bad.  doesn't feel like I'm using all the
> power correctly, but it works.
> 
> *additional problem is, my rels look like this.*
> 
> (:lhs uuid :rhs uuid :type x)
> 
>  :lhs and :rhs "should be" entities, not references.  more functions?  I
> make :lhs and :rhs return functions which dereference entities. of
> course that makes selecting from rel-pool much harder 
> 
> that's when I knew I had to seek professional help (smile)
> 
> even with a long post hard to capture all the requirements... 
> 
>  1. the pools aren't supposed to be "public" so I can't have all the
> callee functions understanding how to do the dereference.  
>  2. the :rels function isn't one function, the truth is the rels-pool
> doesn't have all relationships, some are virtual, the function
> creates them on the fly, each entity could have it's own version of
> "get-relationships"
> 
> any help is appreciated.
> 
> i've considered
> 
>   * creating a function that "denormalizes" the data before sending it
> out to.  now its fully formed but i lose some recency (not much diff
> i know)
>   * centralizing all the derefs functions - so the callee knows that all
> the data isn't embedded but the functions don't live in structure,
> just the uuids... that works well for LHS/RHS deref, but makes the
> per entity virtual relationships much harder.  
>   * rethinking my atom granularity and using @ but i don't think that
> really helps
> 
> 
> thanks for reading
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and s

weird repl behavior

2014-02-25 Thread dabd
I am using the latest CIDER 0.6.0alpha (package: 20140224.735) (Clojure 
1.5.1, nREPL 0.2.1) on Windows.
I noticed suddenly my repl started to miss some println messages in my code.
A simple test like this shows:

> (do (println "hello") (println "there"))
hello

It won't print the second message for some reason.
Why is this happening?

Thanks.

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


Re: Help with data structures and dereferencing

2014-02-25 Thread Robert Quinn
David, 

thanks for the reply.  I started down that path.  

RHS is an entity itself.  Its state changes over time, with Identity 
independent of its relationships, it can be related to many entities (LHS). 
 So its state has to live in one place or employ synchronization (complex 
watchers?).  I remember seeing a reference to zipper functionality that 
seemed to imply a possible solution, I'll try to find that again..

Thanks,

Robert





On Tuesday, February 25, 2014 10:26:30 AM UTC-5, David Della Costa wrote:
>
> Is there no way to simply structure the maps inside your main atom in 
> such a way that you can look up your entities? 
>
> {lhs-uuid1 {rhs-uuid1 ["values"] rhs-uuid2 ["values"]}} 
>
> (get-in @myatom [lhs-uuid1 rhs-uuid2]) 
>
> You can wrap this in a function that does some other work to look it up 
> if need be, if the result of the above is nil (for example)...etc. 
>
> Seems like you're making things more complicated than they need to be 
> here, but it's hard to know without knowing more about your data. 
>
> But if I were you I would start there, as I've found thinking hard about 
> the structure of your data and and using the facilities provided by the 
> standard library usually helps simplify things tremendously. 
>
> (2014/02/25 23:14), Robert Quinn wrote: 
> > new to clojure, in the process of unlearning years of OO.  sorry for the 
> > long post. 
> > 
> > struggling with a design/impl and hoping to get some outside opinions so 
> > I can understand my options (clojure better) 
> > 
> > basic concepts are straightforward and in a nutshell I'm modeling 
> > entities and relationships  (aren't we all) 
> > 
> > --- 
> > 
> > created a pool of entities (people and groups) implemented as maps. 
> >  each map has a :rels which is set of relationships to other entities. 
> >  the pool is an atom. 
> > 
> > first approach; relationships are in the entity, add RHS entities into 
> > the LHS :rels.  the state of the RHS can change, I need the latest state 
> > of RHS not as it was when the relationship was created. I decided not to 
> > make each entity a ref (ref, atom, agent), it seemed too fine grained. 
> > *thoughts?* 
> > 
> > each entity has a uuid 
> > 
> > second approach, a pool of relationships (:lhs uuid :rhs uuid :type x). 
> > pool has all the relationships, also an atom.  the pool has lots of 
> > benefits it "improves" other parts of the code. 
> > 
> > it doesn't solve the original problem, just moves it around, i still 
> > can't put the actual RHS, so i'm using the uuid as a reference, i look 
> > up RHS get the latest. (second guessing why didn't i make them atoms and 
> > use @uuid). 
> > 
> > now my relationships aren't embedded in my entity, that doesn't feel 
> > right, anyone dealing with the entity should still be able to say... 
> > (:rels entity) and get the relationships, so i add a function to :rels 
> > that returns all the relationship based on the uuid of the LHS, this 
> > works great. syntax changes and requires me to use ((:rels entity)). 
> > 
> > *the problem is... (assumes everything within a single process)* 
> > 
> > I want to pass this data structure around and now dereferencing is 
> > bleeding out.  Instead of passing around a data structure, I'm passing 
> > around a data structure that has functions embedded in it.  which seems 
> > like a cool idea, but now the callee needs to know that :rels returns a 
> > function, when it's supposed to have data in it. (which is the same 
> > thing?) but I don't know how to treat it seamlessly.  (i have not 
> > considered eval). 
> > 
> > for the :rels it's not too bad.  doesn't feel like I'm using all the 
> > power correctly, but it works. 
> > 
> > *additional problem is, my rels look like this.* 
> > 
> > (:lhs uuid :rhs uuid :type x) 
> > 
> >  :lhs and :rhs "should be" entities, not references.  more functions?  I 
> > make :lhs and :rhs return functions which dereference entities. of 
> > course that makes selecting from rel-pool much harder 
> > 
> > that's when I knew I had to seek professional help (smile) 
> > 
> > even with a long post hard to capture all the requirements... 
> > 
> >  1. the pools aren't supposed to be "public" so I can't have all the 
> > callee functions understanding how to do the dereference.   
> >  2. the :rels function isn't one function, the truth is the rels-pool 
> > doesn't have all relationships, some are virtual, the function 
> > creates them on the fly, each entity could have it's own version of 
> > "get-relationships" 
> > 
> > any help is appreciated. 
> > 
> > i've considered 
> > 
> >   * creating a function that "denormalizes" the data before sending it 
> > out to.  now its fully formed but i lose some recency (not much diff 
> > i know) 
> >   * centralizing all the derefs functions - so the callee knows that all 
> > the data isn't embedded but the functions don't live in structure, 
> > just the uuids... that works well 

Re: How to override the default port on 3000?

2014-02-25 Thread Rob Day
If you do want to use port 80, it's generally safer to use a reverse
proxy like nginx to listen on port 80 and forward to port 3000 - that
way your code doesn't need root privileges and is less of a security
headache.

On 25 February 2014 14:59, Josh Kamau  wrote:
> you can also change this line on your project.clj
>
> :ring {:handler myproject.handler/app :port 8080}
>
> Josh
>
>
>
> On Tue, Feb 25, 2014 at 5:23 PM, Jason Stewart 
> wrote:
>>
>> The lein-ring plugin accepts a port number as an argument:
>>
>> lein ring server 8080
>>
>> Note, that in order to bind to port 80, you will need elevated (root)
>> privileges.
>>
>>
>> On Tue, Feb 25, 2014 at 9:21 AM, action  wrote:
>>>
>>> I do like this:
>>> #lein new compojure-app guestbook
>>> #cd guestbook
>>> #lein ring server
>>>
>>> The server runs on port 3000 by default.
>>> But how to override the default port?
>>> Such as runs on port 80?
>>>
>>> thinks
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Robert K. Day
robert@merton.oxon.org

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


Re: object identity

2014-02-25 Thread Brian Craft
No, my question isn't "is there a way" to do this. I'm sure there are a 
dozen ways to do it. My question is about a specific way of doing it. In 
particular, if your solution does not involve calling (identical? ..), then 
it's not what I'm asking about.

In om core there's a call to identical? under the :shouldComponentUpdate 
key, which I suspect is what David was talking about in his blog posts 
about avoiding deep compares via immutable data structures. My question is 
about whether that has implications for how you write algorithms that 
update state, and whether the semantics of update-in (or assoc, really) 
that allow it to return the same object if the update would return an 
identical object, are related to this mechanism, if these semantics are 
documented, and if they depend on the data type being assoc'd.



On Monday, February 24, 2014 6:27:02 PM UTC-8, t x wrote:
>
> Perhaps I mis-interpreted your question. 
>
> I thought the question asked was: 
>
>
> GIven: 
>   * pure function "func" 
>   * some object "obj" 
>   * (def a (func obj)) 
>   * (def b (func obj)) 
>
> Example: 
>   * obj = [1 2 3] 
>   * (defn func [lst] (map #(* 2 %) lst)) 
>
> Then: 
>   * is there a O(1) way to check if (= a b) ? 
>
>   In the above, we create two _different_ lists, both of which stores 
> [2 4 6], thus they're equal, but not identical 
>
> Proposed solution: 
>   tag the returned-value with a meta object, where the meta object 
> describes how the object was computed. 
>
>   in this case, both [2 4 6] would have _identical_ meta objects, 
> since they're both from the list [1 2 3] 
>
>
>
>
>
> On Mon, Feb 24, 2014 at 5:56 PM, Brian Craft 
> > 
> wrote: 
> > You're solving a similar problem, but I'm asking specifically about 
> using 
> > object identity, not equality, for tracking changes in a nested 
> structure. 
> > 
> > 
> > On Monday, February 24, 2014 1:42:03 PM UTC-8, t x wrote: 
> >> 
> >> I finally have a chance to give back. :-) 
> >> 
> >> I hacked up a newb's half-React. It does tree diffing + dom updating, 
> >> but not the virtual event handling system. 
> >> 
> >> I ran into this exact problem, and solved it as follows: 
> >> 
> >> 
> >> ## problem definition: 
> >> 
> >> render: data -> dom 
> >> tree-diff: dom * dom -> list of dom-update-actions 
> >> 
> >> we want to avoid "deep tree diffing" on tree-diff 
> >> 
> >> the key idea is as follows: 
> >> 
> >>   when render is called twice with same args, 
> >> 
> >>   * we still have to recompute every time 
> >>   * we don't have to re-compare every time 
> >> 
> >> if render is a pure function, we do somethign like: 
> >> 
> >> (defn render [data] 
> >>   (with-meta (render-pure data) {:pure data})) 
> >> 
> >> (render-pure data) gives us a dom-tree 
> >> we tag it with a meta project, telling us that it came from "data", 
> >> and that it was a pure function 
> >> 
> >> 
> >> then, doing the tree-diff stage, we do: 
> >> 
> >> 
> >> (defn tree-diff [old-dom new-dom] 
> >>   (let [mo (meta old-dom) 
> >> no (meta new-dom)] 
> >> (if (and (:pure mo) (:pure no) (= (:pure mo) (:pure no))) 
> >>   .. ah, they're from the same pure function, thus the same ... 
> >>   ... okay, let's do expensive deep diff))) 
> >> 
> >> 
> >> so basically, we abuse meta objects, record 
> >> 
> >>   * what data gave us this dom tree ? 
> >>   * was the func that gave us the dom tree pure ? 
> >> 
> >> And if so, we just do a equality check on the data -- which are are 
> >> _not_ "regenerating" and thus matches an equality check. 
> >> 
> >> 
> >> Please let me if: 
> >> 
> >>   (a) this resolves the issue 
> >>   (b) I completely misunderstood the question 
> >> 
> >> 
> >> Thanks! 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> On Mon, Feb 24, 2014 at 1:00 PM, Brian Craft  
> wrote: 
> >> > This is vaguely related to David's posts about om/react, where he 
> talks 
> >> > about optimizing state change tracking by checking object identity on 
> >> > immutable objects: deep compares can be avoided if same identity 
> implies 
> >> > no 
> >> > changes. 
> >> > 
> >> > My first thought was that there are many algorithms that will give 
> you a 
> >> > new 
> >> > object every time, even if nothing has changed.  E.g. if your state 
> has 
> >> > an 
> >> > array whose elements must be validated, doing a map over the elements 
> >> > will 
> >> > give you a new array every time, even if it makes no changes. 
> >> > 
> >> > Enforcing non-negative values, for instance: 
> >> > 
> >> > => (let [x {:a [1 -2 3]}] (update-in x [:a] (fn [y] (mapv #(if (< % 
> 0) 0 
> >> > %) 
> >> > y 
> >> > {:a [1 0 3]} 
> >> > 
> >> > In the following case the values are already non-negative, but we 
> still 
> >> > get 
> >> > a new object: 
> >> > 
> >> > => (let [x {:a [1 2 3]}] (identical? x (update-in x [:a] (fn [y] 
> (mapv 
> >> > #(if 
> >> > (< % 0) 0 %) y) 
> >> > false 
> >> > 
> >> > One can imagine trying to rewrite this so it passes through the 
> 

Re: object identity

2014-02-25 Thread David Nolen
I don't really have anything to add to this thread but I will say that Om's
use of identical? is an implementation detail that's likely to change. =
already does an identical? check, ideally Om could use not= in the future
instead of (not (identical? ...)).

David


On Tue, Feb 25, 2014 at 12:54 PM, Brian Craft  wrote:

> No, my question isn't "is there a way" to do this. I'm sure there are a
> dozen ways to do it. My question is about a specific way of doing it. In
> particular, if your solution does not involve calling (identical? ..), then
> it's not what I'm asking about.
>
> In om core there's a call to identical? under the :shouldComponentUpdate
> key, which I suspect is what David was talking about in his blog posts
> about avoiding deep compares via immutable data structures. My question is
> about whether that has implications for how you write algorithms that
> update state, and whether the semantics of update-in (or assoc, really)
> that allow it to return the same object if the update would return an
> identical object, are related to this mechanism, if these semantics are
> documented, and if they depend on the data type being assoc'd.
>
>
>
> On Monday, February 24, 2014 6:27:02 PM UTC-8, t x wrote:
>
>> Perhaps I mis-interpreted your question.
>>
>> I thought the question asked was:
>>
>>
>> GIven:
>>   * pure function "func"
>>   * some object "obj"
>>   * (def a (func obj))
>>   * (def b (func obj))
>>
>> Example:
>>   * obj = [1 2 3]
>>   * (defn func [lst] (map #(* 2 %) lst))
>>
>> Then:
>>   * is there a O(1) way to check if (= a b) ?
>>
>>   In the above, we create two _different_ lists, both of which stores
>> [2 4 6], thus they're equal, but not identical
>>
>> Proposed solution:
>>   tag the returned-value with a meta object, where the meta object
>> describes how the object was computed.
>>
>>   in this case, both [2 4 6] would have _identical_ meta objects,
>> since they're both from the list [1 2 3]
>>
>>
>>
>>
>>
>> On Mon, Feb 24, 2014 at 5:56 PM, Brian Craft  wrote:
>> > You're solving a similar problem, but I'm asking specifically about
>> using
>> > object identity, not equality, for tracking changes in a nested
>> structure.
>> >
>> >
>> > On Monday, February 24, 2014 1:42:03 PM UTC-8, t x wrote:
>> >>
>> >> I finally have a chance to give back. :-)
>> >>
>> >> I hacked up a newb's half-React. It does tree diffing + dom updating,
>> >> but not the virtual event handling system.
>> >>
>> >> I ran into this exact problem, and solved it as follows:
>> >>
>> >>
>> >> ## problem definition:
>> >>
>> >> render: data -> dom
>> >> tree-diff: dom * dom -> list of dom-update-actions
>> >>
>> >> we want to avoid "deep tree diffing" on tree-diff
>> >>
>> >> the key idea is as follows:
>> >>
>> >>   when render is called twice with same args,
>> >>
>> >>   * we still have to recompute every time
>> >>   * we don't have to re-compare every time
>> >>
>> >> if render is a pure function, we do somethign like:
>> >>
>> >> (defn render [data]
>> >>   (with-meta (render-pure data) {:pure data}))
>> >>
>> >> (render-pure data) gives us a dom-tree
>> >> we tag it with a meta project, telling us that it came from "data",
>> >> and that it was a pure function
>> >>
>> >>
>> >> then, doing the tree-diff stage, we do:
>> >>
>> >>
>> >> (defn tree-diff [old-dom new-dom]
>> >>   (let [mo (meta old-dom)
>> >> no (meta new-dom)]
>> >> (if (and (:pure mo) (:pure no) (= (:pure mo) (:pure no)))
>> >>   .. ah, they're from the same pure function, thus the same ...
>> >>   ... okay, let's do expensive deep diff)))
>> >>
>> >>
>> >> so basically, we abuse meta objects, record
>> >>
>> >>   * what data gave us this dom tree ?
>> >>   * was the func that gave us the dom tree pure ?
>> >>
>> >> And if so, we just do a equality check on the data -- which are are
>> >> _not_ "regenerating" and thus matches an equality check.
>> >>
>> >>
>> >> Please let me if:
>> >>
>> >>   (a) this resolves the issue
>> >>   (b) I completely misunderstood the question
>> >>
>> >>
>> >> Thanks!
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> On Mon, Feb 24, 2014 at 1:00 PM, Brian Craft 
>> wrote:
>> >> > This is vaguely related to David's posts about om/react, where he
>> talks
>> >> > about optimizing state change tracking by checking object identity
>> on
>> >> > immutable objects: deep compares can be avoided if same identity
>> implies
>> >> > no
>> >> > changes.
>> >> >
>> >> > My first thought was that there are many algorithms that will give
>> you a
>> >> > new
>> >> > object every time, even if nothing has changed.  E.g. if your state
>> has
>> >> > an
>> >> > array whose elements must be validated, doing a map over the
>> elements
>> >> > will
>> >> > give you a new array every time, even if it makes no changes.
>> >> >
>> >> > Enforcing non-negative values, for instance:
>> >> >
>> >> > => (let [x {:a [1 -2 3]}] (update-in x [:a] (fn [y] (mapv #(if (< %
>> 0) 0
>> >> > %)
>> >> > y
>> >> > {:a [1 0 3]

[ANN] Claypoole: Threadpool Tools for Clojure

2014-02-25 Thread Leon Barrett
The Climate Corporation has open-sourced the library 
claypoole, 
which is a set of threadpool tools for Clojure's parallel functions. For 
instance, you can start futures in a specific threadpool, pmap on a 
threadpool, or even use a parallel for (pfor). We find it to be a helpful 
way of controlling the degree of parallelism we're using.

There is more information on our 
blog
.

Feedback (and pull requests) are welcome.

- Leon

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


Re: Can't start repl with Leiningen

2014-02-25 Thread John Gabriele
On Sunday, February 23, 2014 4:32:54 PM UTC-5, Matej Fröbe wrote:
>
> Hello Clojure users!
>
> I have a problem with running
> *$lein repl*
> After some time I get: *REPL server launch timed out.*
>
> *$lein run myproject* works fine
>
> Leiningen and Java versions are:
>
> *$lein versionLeiningen 2.3.4 on Java 1.7.0_21 OpenJDK Client VM*
>
> I tried deleting stuff in ~/.lein but it doesn't help.
>
> Any suggestions how to solve this?
>
> Thanks,
>
> Matej
>
>
Hi Matej,

Have never seen this problem. You might try starting fresh by deleting your 
local repo (~/.m2) too, and re-downloading the `lein` script.

-- John

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


avoiding reflection with gen-class

2014-02-25 Thread Ilya Kaplun
 

hey guys. i am struggling to understand how to avoid reflection when 
calling a clojure method from java. i tried type hinting "this" in the 
function definition, and that works assuming a version of the class exists 
already, but if I do a clean compilation I get a 
java.lang.ClassNotFoundException. 

an approximation of the code is at http://pastebin.com/FpTyRNTS, also 
pasted below:

(gen-class
  :name com.company.Aclass
  :prefix rad-
  :extends org.eclipse.jetty.util.component.AbstractLifeCycle
  :state state
  :init init
  :constructors {[java.util.Map] []}
  :methods [[getStuff [] java.util.List]]
  )



(defn ^java.util.List rad-getStuff
  [^Aclass this]
  (do
@(.state this)
))

thanks in advance!

Ilya

p.s. i am using clojure 1.5.1

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


Re: Can't start repl with Leiningen

2014-02-25 Thread Matej Fröbe
Hi John,

Thank you for your answer. I have tried this already, but it doesn't help.

Any other suggestions, how to find the cause of the problem?

Matej


Am Dienstag, 25. Februar 2014 19:51:51 UTC+1 schrieb John Gabriele:
>
> On Sunday, February 23, 2014 4:32:54 PM UTC-5, Matej Fröbe wrote:
>>
>> Hello Clojure users!
>>
>> I have a problem with running
>> *$lein repl*
>> After some time I get: *REPL server launch timed out.*
>>
>> *$lein run myproject* works fine
>>
>> Leiningen and Java versions are:
>>
>> *$lein versionLeiningen 2.3.4 on Java 1.7.0_21 OpenJDK Client VM*
>>
>> I tried deleting stuff in ~/.lein but it doesn't help.
>>
>> Any suggestions how to solve this?
>>
>> Thanks,
>>
>> Matej
>>
>>
> Hi Matej,
>
> Have never seen this problem. You might try starting fresh by deleting 
> your local repo (~/.m2) too, and re-downloading the `lein` script.
>
> -- John
>
>

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


Interested in GSOC

2014-02-25 Thread Rohan Prinja
Hi everyone. I'm Rohan Prinja, a third year Computer Science undergrad at IIT 
Bombay . I love programming in Lisp-family languages and 
although I have only recently begun to use Clojure, I'm already quite 
familiar with Racket and Common Lisp. I also have a basic knowledge of the J 
programming language .

I am really interested in furthering my knowledge of Clojure while at the 
same time producing some meaningful contributions and in my opinion, 
contributing to open source via GSoC is the best way for me to do that! I 
went through the project ideas 
list and 
I feel that the Linear Algebra for Clojure project is the best one for me 
because I have a strong foundation in Linear Algebra.

Please give me some suggestions on understanding and learning more about 
the project. So far I've seen the Enter the 
Matrix Clojure 
conj talk and have begun browsing the core.matrix 
sourceon Github. What other things can I 
do?

Thank you!
Rohan Prinja

https://github.com/wenderen

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


Re: Can't start repl with Leiningen

2014-02-25 Thread Zach Oakes
Matej, does this happen to you when you run "lein repl" outside of a 
project? If so, can you show us what your project.clj file looks like? I 
know for a fact that if you have ":eval-in :trampoline" in it, the repl 
will fail with that error.

On Tuesday, February 25, 2014 2:56:04 PM UTC-5, Matej Fröbe wrote:
>
> Hi John,
>
> Thank you for your answer. I have tried this already, but it doesn't help.
>
> Any other suggestions, how to find the cause of the problem?
>
> Matej
>
>
> Am Dienstag, 25. Februar 2014 19:51:51 UTC+1 schrieb John Gabriele:
>>
>> On Sunday, February 23, 2014 4:32:54 PM UTC-5, Matej Fröbe wrote:
>>>
>>> Hello Clojure users!
>>>
>>> I have a problem with running
>>> *$lein repl*
>>> After some time I get: *REPL server launch timed out.*
>>>
>>> *$lein run myproject* works fine
>>>
>>> Leiningen and Java versions are:
>>>
>>> *$lein versionLeiningen 2.3.4 on Java 1.7.0_21 OpenJDK Client VM*
>>>
>>> I tried deleting stuff in ~/.lein but it doesn't help.
>>>
>>> Any suggestions how to solve this?
>>>
>>> Thanks,
>>>
>>> Matej
>>>
>>>
>> Hi Matej,
>>
>> Have never seen this problem. You might try starting fresh by deleting 
>> your local repo (~/.m2) too, and re-downloading the `lein` script.
>>
>> -- John
>>
>>

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


Re: Clojure code for detecting overlap of 3d shapes (specifically tetrahedra)?

2014-02-25 Thread Lee Spector
On Feb 16, 2014, at 5:07 PM, Karsten Schmidt wrote:

> Yer welcome & please do let me know how this works out for you! I've
> updated the gist[1] to delay more parts of the whole computation and
> replace most occurrences of `reduce` with `loop` - altogether leading
> to an almost 2x faster result for the worst case scenario where all
> test clauses are checked. K.
> 
> [1] https://gist.github.com/postspectacular/9021724



Hi Karsten,

I've noticed that intersect-tetrahedra? is sometimes asymmetric. Here's an 
example with randomly generated irregular tetrahedra, but I've noticed it for 
regular tetrahedra as well:

(def t1 [[166 560 158] [889 160 1] [95 683 998] [445 779 516]])

(def t2 [[292 823 490] [868 167 651] [190 869 459] [208 591 753]]) 

(intersect-tetrahedra? t1 t2)

=> true

(intersect-tetrahedra? t2 t1)

=> nil

Do you have any idea why this might be or how it could be fixed?

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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Interested in GSOC

2014-02-25 Thread Maik Schünemann
Hi,

On Tue, Feb 25, 2014 at 8:59 PM, Rohan Prinja  wrote:
> Hi everyone. I'm Rohan Prinja, a third year Computer Science undergrad at
> IIT Bombay. I love programming in Lisp-family languages and although I have
> only recently begun to use Clojure, I'm already quite familiar with Racket
> and Common Lisp. I also have a basic knowledge of the J programming
> language.
>
> I am really interested in furthering my knowledge of Clojure while at the
> same time producing some meaningful contributions and in my opinion,
> contributing to open source via GSoC is the best way for me to do that!
I second you on that. I participated in GSoC last year on the project
Algebraic Expressions
and it was a very good experience and I definitly learned a lot by doing it.
> I went through the project ideas list and I feel that the Linear Algebra for
> Clojure project is the best one for me because I have a strong foundation in
> Linear Algebra.
I would be very happy if you manage to work on this project. Having
support for the
linear algebra operations is a long standing issue in core.matrix.
Also Mike did a fantastic job mentoring me last year ;)
> Please give me some suggestions on understanding and learning more about the
> project. So far I've seen the Enter the Matrix Clojure conj talk and have
> begun browsing the core.matrix source on Github. What other things can I do?
I think it is good to contact Mike Anderson (mikera on this
list) directly for your gsoc specific questions regarding this project
idea and what you can do
to prepare yourself for it. Here are some of my ideas of what you could do:
You should learn how clojure protocols are working and figure out how
the code flows in
core.matrix.
Also, watch the numerical clojure mailing list and get involved
https://groups.google.com/forum/#!forum/numerical-clojure
(There is currently an active discussion about a Data Set
implementation of core.matrix
 which could be a good starting point)

greetings
Maik

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


Re: Clojure code for detecting overlap of 3d shapes (specifically tetrahedra)?

2014-02-25 Thread Karsten Schmidt
Hah! What a classic mistake (not yours)! The bug fix is a single
letter change in the last call to `check-faces-b`. The reference point
to check against should be the 2nd point in tetra `q`. It currently
uses the 1st point `qa`, whereas it should be `qb`. Thanks for
testing! Also just updated the gist once more... I verified symmetric
results of your test case and also compared once more with the C
version.

https://gist.github.com/postspectacular/9021724/revisions

Hth! K.

On 25 February 2014 20:21, Lee Spector  wrote:
> On Feb 16, 2014, at 5:07 PM, Karsten Schmidt wrote:
>
>> Yer welcome & please do let me know how this works out for you! I've
>> updated the gist[1] to delay more parts of the whole computation and
>> replace most occurrences of `reduce` with `loop` - altogether leading
>> to an almost 2x faster result for the worst case scenario where all
>> test clauses are checked. K.
>>
>> [1] https://gist.github.com/postspectacular/9021724
>
>
>
> Hi Karsten,
>
> I've noticed that intersect-tetrahedra? is sometimes asymmetric. Here's an 
> example with randomly generated irregular tetrahedra, but I've noticed it for 
> regular tetrahedra as well:
>
> (def t1 [[166 560 158] [889 160 1] [95 683 998] [445 779 516]])
>
> (def t2 [[292 823 490] [868 167 651] [190 869 459] [208 591 753]])
>
> (intersect-tetrahedra? t1 t2)
>
> => true
>
> (intersect-tetrahedra? t2 t1)
>
> => nil
>
> Do you have any idea why this might be or how it could be fixed?
>
> 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 unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Karsten Schmidt
http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk

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


[ANN] ttlcache, an improved (?) version of core.cache's TTLCache

2014-02-25 Thread Rob Day
Hi all,

I've been looking at DNS caching recently, and based on that, have
made some improvements on top of the TTLCache in core.cache which I
think I'm ready to release - they're at
https://github.com/rkday/ttlcache and
https://clojars.org/uk.me.rkd.ttlcache.

The main improvements are that you can specify a function to extract
TTLs from the cached values (useful for DNS etc. where each record
comes with its own TTL), and that I'm using a priority queue to make
expiry faster when only a few items are expiring. In the best case
(where no items expire and it's O(1) rather than O(N)), it seems to be
150-200x faster on a 5,000-item cache.

I'd appreciate any feedback on whether people think this is a useful
type of cache, how big a problem it is to be slower when expiring
large numbers of items, and whether I've got the benchmarks and big-O
analysis right or whether there's something simple I've missed.

Thanks!
Rob

P.S. I don't think this is yet in a state where I can open a JIRA
request and try and get some of the improvements back into core.cache
- mainly because it's slower when expiring large numbers of keys from
the cache at once. But that's definitely something I'd like to do in
the future if I can speed that up, or if people feel that's an edge
case.

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


ANN Meltdown 1.0.0-beta5 is released

2014-02-25 Thread Michael Klishin
Meltdown [1] is a Clojure interface to Reactor [2], an asynchronous
programming
toolkit for the JVM.

beta5 is a development release that primarily focuses on updating Reactor
to 1.1.0.M1 and fixing issues.

Release notes:
http://blog.clojurewerkz.org/blog/2014/02/26/meltdown-1-dot-0-0-beta5-is-released/

1. https://github.com/clojurewerkz/meltdown
2.
http://spring.io/blog/2013/11/12/it-can-t-just-be-big-data-it-has-to-be-fast-data-reactor-1-0-goes-ga
-- 
MK

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

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


Re: Clojure code for detecting overlap of 3d shapes (specifically tetrahedra)?

2014-02-25 Thread Lee Spector

On Feb 25, 2014, at 5:21 PM, Karsten Schmidt wrote:

> Hah! What a classic mistake (not yours)! The bug fix is a single
> letter change in the last call to `check-faces-b`. The reference point
> to check against should be the 2nd point in tetra `q`. It currently
> uses the 1st point `qa`, whereas it should be `qb`. Thanks for
> testing! Also just updated the gist once more... I verified symmetric
> results of your test case and also compared once more with the C
> version.
> 
> https://gist.github.com/postspectacular/9021724/revisions
> 
> Hth! K.

Fantastic -- it looks great now.

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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Latest web framework for clojure

2014-02-25 Thread Aravindh S
Hi All,
   I have been reading clojure for sometime now. I am at a point where I 
want to learn a web framework. I see many options available for clojure 
where few are built upon others. So if I am to learn one, which framework 
does the community recommend? 

Thanks
Aravindh.S

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


Re: Latest web framework for clojure

2014-02-25 Thread haosdent
Maybe you could try compojure.


On Wed, Feb 26, 2014 at 9:13 AM, Aravindh S wrote:

> Hi All,
>I have been reading clojure for sometime now. I am at a point where I
> want to learn a web framework. I see many options available for clojure
> where few are built upon others. So if I am to learn one, which framework
> does the community recommend?
>
> Thanks
> Aravindh.S
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Best Regards,
Haosdent Huang

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


Re: Latest web framework for clojure

2014-02-25 Thread Gary Trakhman
Luminus is a batteries-included leiningen project template that includes
compojure and other things to get started.

http://www.luminusweb.net/




On Tue, Feb 25, 2014 at 8:18 PM, haosdent  wrote:

> Maybe you could try compojure.
>
>
> On Wed, Feb 26, 2014 at 9:13 AM, Aravindh S wrote:
>
>> Hi All,
>>I have been reading clojure for sometime now. I am at a point where I
>> want to learn a web framework. I see many options available for clojure
>> where few are built upon others. So if I am to learn one, which framework
>> does the community recommend?
>>
>> Thanks
>> Aravindh.S
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Best Regards,
> Haosdent Huang
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: Help with data structures and dereferencing

2014-02-25 Thread Dave Della Costa
You are saying a zipper may be a solution--so do you have a tree or
graph structure?

If your RHS value is something that changes over time but has an
identity independent of its relationship to other nodes, then retrieving
or constructing its value could simply be a function or set of
functions--or just a lookup in a table--once you have access to its key,
could it not?

At least based on your description, it seems like you are complicating
the design by conflating two different things: accessing the most recent
value of the RHS value and establishing ways to look up values based on
their node relationships.

(2014/02/26 1:35), Robert Quinn wrote:
> David, 
> 
> thanks for the reply.  I started down that path.  
> 
> RHS is an entity itself.  Its state changes over time, with Identity
> independent of its relationships, it can be related to many entities
> (LHS).  So its state has to live in one place or employ synchronization
> (complex watchers?).  I remember seeing a reference to zipper
> functionality that seemed to imply a possible solution, I'll try to find
> that again..
> 
> Thanks,
> 
> Robert
> 
> 
> 
> 
> 
> On Tuesday, February 25, 2014 10:26:30 AM UTC-5, David Della Costa wrote:
> 
> Is there no way to simply structure the maps inside your main atom in
> such a way that you can look up your entities?
> 
> {lhs-uuid1 {rhs-uuid1 ["values"] rhs-uuid2 ["values"]}}
> 
> (get-in @myatom [lhs-uuid1 rhs-uuid2])
> 
> You can wrap this in a function that does some other work to look it up
> if need be, if the result of the above is nil (for example)...etc.
> 
> Seems like you're making things more complicated than they need to be
> here, but it's hard to know without knowing more about your data.
> 
> But if I were you I would start there, as I've found thinking hard
> about
> the structure of your data and and using the facilities provided by the
> standard library usually helps simplify things tremendously.
> 
> (2014/02/25 23:14), Robert Quinn wrote:
> > new to clojure, in the process of unlearning years of OO.  sorry
> for the
> > long post.
> >
> > struggling with a design/impl and hoping to get some outside
> opinions so
> > I can understand my options (clojure better)
> >
> > basic concepts are straightforward and in a nutshell I'm modeling
> > entities and relationships  (aren't we all)
> >
> > ---
> >
> > created a pool of entities (people and groups) implemented as maps.
> >  each map has a :rels which is set of relationships to other
> entities.
> >  the pool is an atom.
> >
> > first approach; relationships are in the entity, add RHS entities
> into
> > the LHS :rels.  the state of the RHS can change, I need the latest
> state
> > of RHS not as it was when the relationship was created. I decided
> not to
> > make each entity a ref (ref, atom, agent), it seemed too fine
> grained.
> > *thoughts?*
> >
> > each entity has a uuid
> >
> > second approach, a pool of relationships (:lhs uuid :rhs uuid
> :type x).
> > pool has all the relationships, also an atom.  the pool has lots of
> > benefits it "improves" other parts of the code.
> >
> > it doesn't solve the original problem, just moves it around, i still
> > can't put the actual RHS, so i'm using the uuid as a reference, i
> look
> > up RHS get the latest. (second guessing why didn't i make them
> atoms and
> > use @uuid).
> >
> > now my relationships aren't embedded in my entity, that doesn't feel
> > right, anyone dealing with the entity should still be able to say...
> > (:rels entity) and get the relationships, so i add a function to
> :rels
> > that returns all the relationship based on the uuid of the LHS, this
> > works great. syntax changes and requires me to use ((:rels entity)).
> >
> > *the problem is... (assumes everything within a single process)*
> >
> > I want to pass this data structure around and now dereferencing is
> > bleeding out.  Instead of passing around a data structure, I'm
> passing
> > around a data structure that has functions embedded in it.  which
> seems
> > like a cool idea, but now the callee needs to know that :rels
> returns a
> > function, when it's supposed to have data in it. (which is the same
> > thing?) but I don't know how to treat it seamlessly.  (i have not
> > considered eval).
> >
> > for the :rels it's not too bad.  doesn't feel like I'm using all the
> > power correctly, but it works.
> >
> > *additional problem is, my rels look like this.*
> >
> > (:lhs uuid :rhs uuid :type x)
> >
> >  :lhs and :rhs "should be" entities, not references.  more
> functions?  I
> > make :lhs and :rhs return functions which dereference entities. of
> > course that makes selec

Re: Latest web framework for clojure

2014-02-25 Thread JPH
On 02/26/2014 09:13 AM, Aravindh S wrote:
> Hi All,
>I have been reading clojure for sometime now. I am at a point where I 
> want to learn a web framework. I see many options available for clojure 
> where few are built upon others. So if I am to learn one, which framework 
> does the community recommend? 
>
> Thanks
> Aravindh.S
>
I recommend Luminus (www.luminusweb.net), which is an opinionated mix of
popular clojure libraries.

I also wrote a post as a kind of overview of the various Clojure web
components
(https://hackworth.be/2013/12/10/navigating-clojure-web-stack/). That
was written back when I'd first started with Clojure and trying to
understand how all the pieces fit together, compared to my experiences
with Ruby.

Hope that helps,
JPH

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


Re: clojure.java.shell/sh and expand wildcard

2014-02-25 Thread John Gabriele
On Tuesday, January 21, 2014 11:05:13 PM UTC-5, Michael Gardner wrote:
>
> Try (sh “bash” “-c” “ls *.txt”). 
>
>
Sorry for the belated reply, Michael. Thanks so much for the help; works!

-- John
 

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


Re: Image Resizer lib exception error

2014-02-25 Thread The Dude (Abides)
I got the file naming fixed with:

(upload-file (img-path) (assoc-in file [:filename] new-file-name))

The last part is reading in the uploaded file so it can be resized with 
Image Resizer. I wrote the code as:

(with-open [rdr (clojure.java.io/reader (str (img-path) "/" 
new-file-name))])

As a test on an existing pic, if I put the wrong file path or file name, 
sure enough it shows the error of either not existing. If I put the correct 
path and file name, I get a null exception.

Is my syntax correct or off. Going back to clojure docs to look again.

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


Re: Latest web framework for clojure

2014-02-25 Thread The Dude (Abides)
I would also recommend Luminus as a user friendly start you can generate a 
new project with Selmer for views (Django style), authentication, 
migrations and db persistence out the gate with either mysql, postgres, 
mongo (or H2 as default if you select neither) and Korma as db dsl.

It will give you good understanding of how the moving parts work together 
and the docs are really good.

http://www.luminusweb.net/docs/profiles.md  - to see how to create a 
project with the tools you want

To generate a site with postgres for example:

lein new luminus myapp +site +postgres
Then to fire up the app server:

lein ring server

And you'll see the project in your browser to start experimenting with the 
plumbing. 

The home page will instruct you how to run the migrations as your first step. 

I found it to be an excellent entry to Clojure web dev, mixing in and trying 
different libraries.


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


Re: Why is Clojure faster than Java at this task?

2014-02-25 Thread Jonathan Barnard
Ah, that explanation makes sense, thank you. I imagine it would be quite 
cumbersome to do the same thing in Java, due to the lack of dynamic typing.

On Tuesday, 25 February 2014 21:20:46 UTC+8, Rob Day wrote:
>
> It looks like an improvement in clojure.lang.BigInt over 
> java.math.BigInteger - BigInt's add() method seems to do a long + long 
> add if it doesn't overflow 
> (
> https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/BigInt.java#L142)
>  
>
> and only fall back to BigInteger's add method (which has no such 
> optimisation - 
> http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/math/BigInteger.java#BigInteger.add%28java.math.BigInteger%29)
>  
>
> if the overhead of BigInteger is actually needed. 
>
> If you use clojure.lang.BigInt in your Java code, I suspect Java will be 
> faster. 
>
> On 25 February 2014 10:38, Jonathan Barnard 
> > wrote: 
> > I recently did a benchmark (admittedly in hindsight not a particularly 
> good 
> > one) that involved comparison of an implementation of the same small 
> program 
> > in Java and in Clojure, in which most of the time is spent in bignum 
> > operations. The results are at this link (the tables at the top; ignore 
> the 
> > rest). The Clojure implementation appears to consistently perform better 
> > than the Java implementation (at least on this setup, x86-64 Linux with 
> > OpenJDK 1.7.0_25). I'd be interested to learn what Clojure does to make 
> it 
> > perform faster than Java in this case, so I thought here might be a good 
> > place to ask. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@googlegroups.com 
> > Note that posts from new members are moderated - please be patient with 
> your 
> > first post. 
> > To unsubscribe from this group, send email to 
> > clojure+u...@googlegroups.com  
> > For more options, visit this group at 
> > http://groups.google.com/group/clojure?hl=en 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Clojure" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to clojure+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
>
>
> -- 
> Robert K. Day 
> rober...@merton.oxon.org  
>

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


Re: [GSoC]: How to participate

2014-02-25 Thread haosdent
Very helpful advice. Thank you very much.


On Tue, Feb 25, 2014 at 10:25 PM, Daniel Solano Gómez wrote:

> Hello, all,
>
> There were a number of questions about how to participate in Clojure's
> Google Summer of Code effort in my last GSoC post, enough that I felt it
> warranted its own thread.  There is a section on the wiki about getting
> involved [1], but I'll make a few suggestions here.
>
>
> Everyone
> 
>
> Please talk about GSoC at your Clojure user group meetings.  If you
> happen to work at a university, the GSoC team has some materials
> available [2] if you are interested in putting on a promotional event.
>
>
> Mentors
> ===
>
> If you are interested in being a mentor, even as a secondary/backup
> mentor, there are a few things you can do:
>
> 1. Sign up to be a mentor on Melange [3].  You will need to sign in with
> a Google account, create a profile, and request a connection with
> Clojure.
>
> 2. If you have any ideas that are not on our Project Ideas page [4],
> please add them.  If you don't have write access to the wiki, feel free
> to post them to this mailing list with '[GSoC Idea]', and we'll add it
> for you.
>
> 3. Feel free to talk about GSoC on other project mailing lists.
>
> 4. Engage with students who express an interest in a project that might
> interest you.
>
>
> Students
> 
>
> The student application period will be from the 10th to 21st of March.
> From now through then, you should research your project, get know
> members, and engage the community.  Posting your project ideas to this
> mailing list is a great way to achieve the last two.  Remember that
> having a good rapport with your mentors and the community is one of the
> most important criteria for being selected as a GSoC student.
>
> As far as project ideas go, check out the project ideas page [4], but
> don't feel restricted to that.  You can do any project so long as you
> can find a suitable mentor, and it both involves Clojure programming and
> has a reasonable scope.
>
>
> I hope this helps.  Thanks for helping out with Clojure's GSoC effort.
>
> Sincerely,
>
> Daniel
>
>
> [1]:
> http://dev.clojure.org/display/community/Google+Summer+of+Code+2014#GoogleSummerofCode2014-Gettinginvolved
> [2]:
> https://www.google-melange.com/gsoc/document/show/gsoc_program/google/gsoc2014/help_page#3._What_can_I_do_to_spread_the_word
> [3]: https://www.google-melange.com/gsoc/homepage/google/gsoc2014
> [4]: http://dev.clojure.org/display/community/Project+Ideas
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Best Regards,
Haosdent Huang

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


Re: Latest web framework for clojure

2014-02-25 Thread Jan Herich
It depends also on your requirements. For example if you want your app to 
work in many 
deployment scenarios (standalone Jetty  or Tomcat, J2EE web containers...) 
and you may 
have to use servlet 3.0 API asynchronous features, nothing beats pedestal 
currently.

The concept of interceptors is little harder to grok then simple ring 
handlers (which are reused
to the greatest possible extent anyway), but they really make sense and 
truly decomplect
execution order, unlike traditional ring wrapping handlers.

The routing systems is also more transparent (data based) then Compojure 
macro routing
and the url generation facility is nice.

Sometimes i hear people say that pedestal is "unclojurish" and complex, but 
i think they
just don't get the difference between complex and easy. Overall, i think 
that pedestal 
represents core clojure philosophy better then any other clojure server 
side framework.

Dňa streda, 26. februára 2014 2:13:30 UTC+1 Aravindh S napísal(-a):
>
> Hi All,
>I have been reading clojure for sometime now. I am at a point where I 
> want to learn a web framework. I see many options available for clojure 
> where few are built upon others. So if I am to learn one, which framework 
> does the community recommend? 
>
> Thanks
> Aravindh.S
>

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