Re: Can I use reduce here?

2014-12-12 Thread Mathias Picker
Hi Robin,

thanks for the example of reduce above! That was what I was looking for.
I will try it out once I'm at my desk again.


/ Mathias

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


Can I use reduce here?

2014-12-12 Thread Mathias Picker
Hi all,

a short question from a newbie. I have a data structure like:

"mytitle1"; "2015-02-01"
"mytitle2"; "2015-03-12"
"";2015-03-28"
"mytitle3; "2015-01-12"

and want something like this

[{:title "mytitle1" :events [{:date "2015-02-01}]}
 {:title "mytitle2" :events [{:date "2015-03-12"} {:date "2015-03-28"}]}
 {:title "mytitle3" :events [{:date "2015-01-12"}]}]

I can recurse through the csv manually, but I have a dim feeling this might 
be a job for reduce, but can't wrap my head around it...

Can anyone give me a hint if and how this could be done? Or just tell me 
that I'm mistaken?

If I'm wrong about reduce, anything which uses part of the standard lib to 
make this a more elegant solution would be interesting.


Thanks,

Mathias

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


clj-pdf: how to serve a pdf with ring

2014-03-23 Thread Mathias Picker


I'm trying to serve a clj-http generated document directly via 
ring/compojure.


I thought ring.util/piped-output-stream would work, but it seems I'm not 
understanding something here...

This:

(defn laminat-pdf-t
 [natno]
(piped-input-stream
 (fn [output-stream])
(pdf
 [ {:title (str "Omanimali-Kuscheltierpass" natno)
:orientation :landscape
 :size :a6
 :author "Omanimali - Stefanie Tuschen"
:register-system-fonts true
 }
;; [:svg {} (clojure.java.io/file
;; (str "/einbuergern/" natno "/svg" ))]
[:paragraph "Some Text"] ]
output-stream)))

(defn laminat-pdf
 "generate individualized cuddly toy passport page"
[natno]
{:headers {"Content-Type" "application/pdf"}
:body (laminat-pdf-t natno)})

leads to an empty response...

What do I need to do differently?

Thanks,

Mathias

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


Re: core.async and performance

2013-12-01 Thread Mathias Picker
Did you look into Pulsar https://github.com/puniverse/pulsar ? 

I'm using core.async in the browser, but I don't see it as a multithreading 
mechanism. Pulsar puts an erlang-like api around the quasar 
lightweight threads and actors for java. Looks really nice, and seems a 
good fit for dse type apps, but I haven't used it yet, just have it on my 
todo list to check out.


Look here 
https://groups.google.com/forum/#!msg/clojure/1xxxTti6Vi0/VjIngrSnG8MJ for 
an interesting performance comparison for a core.async implemented on top 
of pulsar, which might give you some hints how both projects might fare for 
your use case.

Cheers, Mathias

-- 
-- 
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: binding and core.async? (trying to use shoreleave-remote in go block)

2013-09-05 Thread Mathias Picker
I just tried this test case (from Anderkent on IRC):

(def pingc (chan))

(def ^:dynamic *text* "OUPS BAD ASYNC")

(binding [*text* "good boy"]
  (go (while true
(
> Hi all,
>
> I'm fighting with shoreleave-remote-ring running on a non default context 
> (immutant), and me not being able to rebind 
> shoreleave.remotes.http-rpc/*remote-uri* inside a go block.
>
> If you look at https://gist.github.com/mathiasp/6448753, you will find a 
> code snippet in the init function which works as expected:
>
>  (binding [srh/*remote-uri* "/opnenablement/_shoreleave"]
> ;;; this works as expected, goes to /opnenablement/_shoreleave
> (srm/rpc (save-config "myConfig") [result]
>  :on-success (js/alert (str "Success: " result))
>  :on-error (js/alert (str "Error: " result
>
> but the same code does not work inside the go block.
>
> Binding anything inside the go block gives me an error ("nth not supported 
> on this type: Symbol"), and putting the binding anywhere outside it does 
> not have any effect, the rpc call goes to /_shoreleave, ignoring the 
> binding of *remote-uri* to /opnenablement/_shoreleave. If I look in the 
> compiled javascript, the binding seems to get redefined just fine...???
>
> I'm banging my head on the for two hours allready, maybe you  can give me 
> some help.
>
> I'm new to clojure and core.async, so maybe, hopefully, I'm missing 
> something obvious?
>
> Thanks, Mathias
>

-- 
-- 
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: binding and core.async? (trying to use shoreleave-remote in go block)

2013-09-05 Thread Mathias Picker
I allready go some help on IRC, define a function with the binding and rpc 
call inside it and then calling that function in my go block works.

I'm now trying to test a simple code snippet Anderkent gave me to see is 
this is a bug, but that will have to wait till tomorrow or so...

Am Donnerstag, 5. September 2013 13:18:39 UTC+2 schrieb Mathias Picker:
>
> Hi all,
>
> I'm fighting with shoreleave-remote-ring running on a non default context 
> (immutant), and me not being able to rebind 
> shoreleave.remotes.http-rpc/*remote-uri* inside a go block.
>
> If you look at https://gist.github.com/mathiasp/6448753, you will find a 
> code snippet in the init function which works as expected:
>
>  (binding [srh/*remote-uri* "/opnenablement/_shoreleave"]
> ;;; this works as expected, goes to /opnenablement/_shoreleave
> (srm/rpc (save-config "myConfig") [result]
>  :on-success (js/alert (str "Success: " result))
>  :on-error (js/alert (str "Error: " result
>
> but the same code does not work inside the go block.
>
> Binding anything inside the go block gives me an error ("nth not supported 
> on this type: Symbol"), and putting the binding anywhere outside it does 
> not have any effect, the rpc call goes to /_shoreleave, ignoring the 
> binding of *remote-uri* to /opnenablement/_shoreleave. If I look in the 
> compiled javascript, the binding seems to get redefined just fine...???
>
> I'm banging my head on the for two hours allready, maybe you  can give me 
> some help.
>
> I'm new to clojure and core.async, so maybe, hopefully, I'm missing 
> something obvious?
>
> Thanks, Mathias
>

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


binding and core.async? (trying to use shoreleave-remote in go block)

2013-09-05 Thread Mathias Picker
Hi all,

I'm fighting with shoreleave-remote-ring running on a non default context 
(immutant), and me not being able to rebind 
shoreleave.remotes.http-rpc/*remote-uri* inside a go block.

If you look at https://gist.github.com/mathiasp/6448753, you will find a 
code snippet in the init function which works as expected:

 (binding [srh/*remote-uri* "/opnenablement/_shoreleave"]
;;; this works as expected, goes to /opnenablement/_shoreleave
(srm/rpc (save-config "myConfig") [result]
 :on-success (js/alert (str "Success: " result))
 :on-error (js/alert (str "Error: " result

but the same code does not work inside the go block.

Binding anything inside the go block gives me an error ("nth not supported 
on this type: Symbol"), and putting the binding anywhere outside it does 
not have any effect, the rpc call goes to /_shoreleave, ignoring the 
binding of *remote-uri* to /opnenablement/_shoreleave. If I look in the 
compiled javascript, the binding seems to get redefined just fine...???

I'm banging my head on the for two hours allready, maybe you  can give me 
some help.

I'm new to clojure and core.async, so maybe, hopefully, I'm missing 
something obvious?

Thanks, Mathias

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