Fork me on GitHub
Frank Henard00:08:15

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.


Though every time I do that, I think “there’s got to be a better way”.

Frank Henard00:08:50

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:

Frank Henard01:08:28

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, (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])
user=>  (def C (cache/fifo-cache-factory {:a 1, :b 2}))
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 simple_smile


I dont want to believe that, removing target did the trick.


often does simple_smile


quite easy to end up with a classfile on disk that is different to what you want


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.


@tcrawley: Right, I think that’s the only thing that makes sense.


This is all part of my plan to put lein in a box with ShimDandy


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.


I don’t know how to test that or where to find doc about it, though.


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:


sveri: thanks


afhammad: np, if you have any questions, just go ahead


I have just released 0.2.0 version of ClojureCL, a ClojureCL library for GPU high-performance computing.


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:

Frank Henard15:08:01

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


what is a good graph lib in clojure with dijkstra?


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.

Alex Miller (Clojure team)16:08:13

and then trim-newline will copy it


@danielpcox: Throw more RAM at it, or use 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”:


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.


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, so appending to an existing file should depend only on opening the file in "append" mode.


FWIW I found an obscure library that does quite a nice conversion of XML->Clojure maps/vectors.


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


Is it an acknowledged poor design decision to have the value of a ring param be either a vector or a single value depending on the number of params present?


So if you need to map across the seq and recur, you need to either rearrange the algorithm, or just settle for non-tail-recursive calls