This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-26
Channels
- # admin-announcements (1)
- # alda (44)
- # aws-lambda (6)
- # beginners (8)
- # boot (187)
- # capetown (5)
- # cider (25)
- # cljs-dev (24)
- # cljsrn (93)
- # clojure (45)
- # clojure-austin (9)
- # clojure-canada (2)
- # clojure-greece (1)
- # clojure-mexico (3)
- # clojure-poland (3)
- # clojure-russia (1)
- # clojure-spec (12)
- # clojure-uk (13)
- # clojurescript (86)
- # cursive (9)
- # datascript (3)
- # datomic (32)
- # defnpodcast (4)
- # devcards (23)
- # editors (3)
- # emacs (5)
- # hoplon (27)
- # immutant (3)
- # lein-figwheel (9)
- # leiningen (4)
- # luminus (10)
- # om (32)
- # onyx (2)
- # other-languages (1)
- # perun (1)
- # protorepl (8)
- # re-frame (13)
- # reagent (2)
- # remote-jobs (2)
- # ring (3)
- # spacemacs (4)
- # spirituality-ethics (3)
- # test-check (16)
- # untangled (65)
- # yada (50)
Can anyone think of a clean way to SHA-256 a Clojure data structure, bearing in mind that when serialized, alternate key orderings in maps or sets would produce different SHAs for equal values.
Nevermind, it looks like Clojure's hash
is already capable of taking care of reordering, even in nested structures. Pretty rad, Clojure. Pretty rad.
@michaeldrogalis: I also saw this in the wild https://github.com/replikativ/hasch
Very cool, thanks @jasonjckn!
(defn transduce-no-init [transducer reducer coll] (transduce transducer reducer (first (transduce transducer conj (list (first coll)))) (rest coll)))
@michaeldrogalis: I think you might get different hash values depending on what jvm version you run or even across different runs on the same jvm. Might be relevant/important to your usage.
From Scala I want a launch a socket repl and I have this in build.sbt:
fork := true
javaOptions := Seq("-Dclojure.server.repl={:port 4555 :accept clojure.core.server/repl :server-daemon false}")
but I can't really explain that part. When I remove the line, nothing happens, because an unused import doesn't trigger Clojure to load?
@mpenet: That would be relevant, yes. Thanks for the heads up. I think I'm going to need to rethink it.
found it via @sdegutis : http://stackoverflow.com/questions/2181774/calling-clojure-from-java/23555959#23555959 (thanks @alexmiller )
Need some CSV parsing advice. The lines I have use quotes around string fields, but leaves integers without. Hence types are encoded in the source. When I parse with clojure.data.csv, all fields ends up as strings, and I loose the type information. Any advice appreciated. Line to illustrate input: “8.5”,”http://your.domain.com”,42,,,”foo”,””,””,”20160725”,”a=b,c=d”
@michaeldrogalis: it s an interesting problem actually. Maybe you could serialize (nippy?) the ds and then compute a checksum of the byte array. It's probably not very efficient tho. Also nippy will not consider equal some types you might like to be (array-map vs hashmap etc)
Yeah, will probably need to just get it to a best effort state. @mpenet Can't imagine most people have this problem 🙂
A lot of people use hashcodes blindly and live with the possibility of breakage it seems
Wild territory.
https://squarecog.wordpress.com/2011/02/20/hadoop-requires-stable-hashcode-implementations/
My end goal is content-addressable EDN. Seems like avoiding hashCode is in my best interest, then.
@borkdude: just loading the Clojure class should be enough to get the runtime going I think. Class.forName(“clojure.java.api.Clojure”)
or whatever the equivalent is in Scala
and you are correct that imports do not trigger load in Java - that just helps Java understand names in the context of the file
@alexmiller: thanks
Man I really like spec. Defining a recursive DSL for executing tasks in parallel or sequentially with resource locking... 13 LOC
Playing with fuzzing for ring compliant client and servers here using spec. Kind of fun
what is the equivalent of (satisfies? IWatchable an-atomlike)
in Clojure?
@martinklepsch: (instance? clojure.lang.IRef (atom 1))
?
Hm, I guess I'll take the missing reactions to my question as a disgusted silence while everyone looks away and pretends they didn't see it. 😉
@ska, I saw your snippet, but what's the question ?
No worries, @pesterhazy ; I don't like that idea myself. It's about having an atom as a value in a map which gets passed around a lot and then updating that atom somewhen somewhere. I'll think of something better.
I don't think there's anything wrong with that idea per se, but it depends on how you want to use it.
@michaeldrogalis: have you seen https://github.com/replikativ/hasch ?
@danielcompton: Someone suggested that earlier. That's what I ended up using 🙂