This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-07
Channels
- # admin-announcements (4)
- # beginners (11)
- # boot (94)
- # cider (12)
- # cljs-dev (87)
- # clojure (64)
- # clojure-austin (1)
- # clojure-australia (3)
- # clojure-canada (1)
- # clojure-dev (7)
- # clojure-russia (28)
- # clojurescript (292)
- # datomic (2)
- # editors (1)
- # events (4)
- # hoplon (35)
- # instaparse (56)
- # ldnclj (10)
- # off-topic (141)
- # re-frame (2)
- # reagent (2)
is there a simple way to create an inputstream from a string?
(ByteArrayInputStream. (.getBytes "Testing”))
is the only one I know off the top of my head.
I agree. I've spent too much time looking. Thanks for the help!
@ballpark: I would like to amend that recommendation to (ByteArrayInputStream. (.getBytes "Testing" StandardCharsets/UTF_8))
. Out of the box it uses whatever your system default charset is, which is probably UTF-8, but not guaranteed.
And, not to be too religious, but you want UTF-8: http://utf8everywhere.org/
got it. Thanks!
Hi, any core.cache user here? I just wanted to make use of this lib and found out that it does throw exception on the minimal example shown on github. With clojure 1.7.0 it throws exception (reported in CCACHE-41) but I found no indication that it should not work with 1.6.0. But to my disappointment, I get " Unable to convert: class clojure.core.cache.FIFOCache to Object[]".
@ballpark: I think with https://github.com/ztellman/byte-streams, (to-input-stream “Testing”)
should work? utf8 is the default
Am I correct in thinking that local lein repos (using file:// protocol) don't check the .m2 cache?
Actually, I’m not even sure that makes sense. Here’s a better question: when lein (or Maven/Aether) is resolving a dep, what is the order it checks? .m2, then the repos in order as defined in project.clj/:repositories?
@martin.hynar: we use core.cache in a few places with both 1.6 and 1.7, haven't seen that issue
@martin.hynar: which code specifically are you running?
@cfleming: howdy! I'm not positive, but I'm pretty sure it checks .m2, then the repos in order, as you said. I don't think it would make sense otherwise, since .m2 is a cache
@martin.hynar: the example works fine for me on 1.7:
user=> (require '[clojure.core.cache :as cache])
nil
user=> (def C (cache/fifo-cache-factory {:a 1, :b 2}))
#'user/C
user=> C
{:a 1, :b 2}
user=> (if (cache/has? C :c)
#_=> (cache/hit C :c)
#_=> (cache/miss C :c 42))
{:a 1, :b 2, :c 42}
user=> (cache/evict C :b)
{:a 1}
@ragge: Exactly the same as you pasted in. Found out, that only 0.6.4 suffers with that, tried to downgrade to 0.6.3 and no such problem appears (no matter what version of Clojure I use). What version of core.cached are you using?
@martin.hynar: the project I was looking at is actually using 0.6.4
@martin.hynar: just tried that with 0.6.4 and clj 1.8.0-alpha4, works fine
@martin.hynar: might be worth checking if you have some aot compiled classfiles laying around...
@martin.hynar: rm -rf target/
is a good start
I dont want to believe that, removing target did the trick.
did you maybe have 0.6.3 stuff aot compiled, then upgrade to 0.6.4? that would explain why reverting to 0.6.3 worked again
no, I created lein new app and added core.cache 0.6.4 dependency. Then started repl and copied the example.
Any templates out there for new projects using Component with either compojure/pedestal?
@tcrawley: Actually, I’m wondering if that’s right. I suspect it goes through the repos one by one, and for remote repos checks the cache and then the repo - I think for local repos it probably doesn’t check the cache.
https://github.com/sveri/closp looks promising
@gmorpheme: Nice. Thanks!
afhammad: Actually I um using system, which is a small wrapper on component. However, the component definitions should be the same
afhammad: you can find the handler component, which loads the compojure routes, here: https://github.com/sveri/closp/blob/master/resources/leiningen/new/closp/clj/components/handler.clj
I have just released 0.2.0 version of ClojureCL, a ClojureCL library for GPU high-performance computing. http://clojurecl.uncomplicate.org
Aaaand, I've also released new version 0.3.0 of Neanderthal, with an GPU engine for Matrix computations
tutorial and discussion on the following link: https://news.ycombinator.com/item?id=10022776
Anyone have any experience hooking up the stuartsierra component library with the ring init hook? I would like for this to work so I can do hot deployments to a container (I'm using tomcat).
I'm getting a "GC overhead limit exceeded" error while trying to load a rather large (~500Mb) CSV file into a map. Does anyone know why this is happening, and what I might be able to do about it? Here's the offending code, which I realize is a bit naive, but I did expect it to work: (->> (:path-to-csv-file conf) (slurp) (s/trim-newline) (clojure-csv/parse-csv) (map #(vector (first %) (json/read-str (second %) :key-fn keyword))) (into {}))
does anybody have an example of a Java library they would like to use but can't because it has an API that doesn't play along with Clojure semantics?
@danielpcox: Well, to start with, slurp
is going to read the entire 500 MB file into memory. That's probably a problem right there.
and then trim-newline will copy it
@danielpcox: Throw more RAM at it, or use https://github.com/clojure/data.csv/ and process it lazily
Anyone have any better options to parsing (simple, sane) XML into a vectors/maps, other than using zippers and xml-seq
? It seems like this is on the right track, but it’d be nice to have something with a bit better “DSL”: https://github.com/thebusby/into-edn
It’s decent but seems very boilerplatey when you get to 10+ XML templates, a bit tedious. It may be that a lot of the ugliness can be macro’d away.
@paulohp: is this your work: https://github.com/ohpauleez/clj-bitbucket ?
thanks @stuartsierra and @jeffmk, I do have memory to spare here, so loading 500Mb is only ugly, not damaging. it doesn't seem to be running out of RAM, but when I googled the error it said that if GC is taking 99% of the total CPU used and recovers less than 2% of the heap, then it's assumed to be making no progress and this OutOfMemoryError is thrown. Someone did suggest increasing the heap size, so perhaps that's all I need to do. This is old software of mine, and I can't actually remember why I'm using clojure-csv instead of data.csv...
actually, I think the reason I didn't use data.csv was because it didn't seem to support appending to a CSV file, which I needed for this application
@danielpcox: data.csv operates in terms of a java.io.Writer, so appending to an existing file should depend only on opening the file in "append" mode.
thanks
FWIW I found an obscure library that does quite a nice conversion of XML->Clojure maps/vectors. https://github.com/cpoile/x2j/tree/cpoile
(x2j/xml-to-clj "<book><title>Clojure for Idiots</title><author>Me</author></book>”)
=> {:book {:author "Me", :title “Clojure for Idiots”}}
Am I correct in my thinking that you can't do (map (partial recur ...) some-seq) because then recur is not in the tail position?
@cddr: correct.