Fork me on GitHub
#clojure
<
2019-06-21
>
rgm00:06:49

so I’m hunting for a good feature flags / dark launch lib and the Java lib page on http://featureflags.io/java-feature-flags/ is a bit sad-looking, and there’s no category at all on clojure toolbox. Anyone have any good recommendations? I’ve rolled my own in the past but I’m hoping I don’t have to again.

eval-on-point01:06:37

I'm implementing datafy for a deeply composite/nested class and have noticed that for a fair amount of the subclasses that bean is getting me pretty close to where I need to be. Is there any reason why these two are separated? I am thinking that datafy should maybe call bean on types that don't implement the protocol

seancorfield04:06:20

Right now Datafiable has just six implementations: Throwable, IRef, Namespace, Class, nil, and Object -- the last one being the "default behavior" (of doing nothing) for any type that isn't one of the others.

seancorfield04:06:04

So datafy only works for things that implement the protocol (because it's a protocol function) but that includes the Object "God Type`.

seancorfield04:06:57

To have calling bean make sense, you'd have to specialize datafy (implement the protocol specifically) for a lot of types where you actually do just want the underlying object back -- basically every single type that represents data. Number, Map, Array, String, and hundreds more.

👍 4
seancorfield04:06:25

As an example @UF9E03ZEX if you call bean on a String:

user=> (bean "hello")
{:bytes #object["[B" 0x87cb1d8 "[B@87cb1d8"], :class java.lang.String, :empty false}
which is definitely not what you want.

seancorfield04:06:47

Similarly,

user=> (bean 1234)
{:class java.lang.Long}
👀

andy.fingerhut02:06:29

Looking at old code is often a reminder of one's earlier ignorance. I probably wouldn't write a function like this again today:

(defn hash-from-pairs [pairs]
  (zipmap (map first pairs) (map second pairs)))

🌟 4
andy.fingerhut02:06:53

Not that it is wrong, just that (into {} pairs) would do.

tomaas07:06:12

hi, I have this issue. I open two different app's routes in two different tabs. I would like to set different cookies on those tabs. However they also get overwritten with last page loaded. https://github.com/ring-clojure/ring/wiki/Cookies if add :path "whatever", it does not appear in browser cookies. Why? Is there a way to resolve this?

dmaiocchi08:06:03

Hi all, i was asking me the meaning of the ns irresponsible, e.g https://clojars.org/irresponsible/tentacles , is the clj-commons org behind this or it is only for special projects?

dmaiocchi08:06:54

e.g I see that project belong to clj-common now, but other projects of this organization are named as expected like https://clojars.org/clj-commons/secretary

dmaiocchi08:06:47

my simple question is why the naming irresponsible/tentacles for that project, or it is a name convention I'm missing? :thinking_face: tia

andy.fingerhut08:06:13

I don't know the story, but will make a guess that some time after it was owned by Raynes, it was taken over by someone with a Github user id of irresponsible, and from there it moved to be under clj-commons.

clj 4
andy.fingerhut08:06:50

There is at least one commit around 2017 some time changing a line in the README from Raynes/tentacles to irresponsible/tentacles, and a 1-sentence explanation of why it changed maintainership then.

dmaiocchi08:06:43

thx Andy for this!

dmaiocchi08:06:04

we might change the namespace to clj-common then

rborer09:06:25

Hi @UHHHJ7FFX, thanks for you contribution. I raised the same question into #clj-commons https://clojurians.slack.com/archives/CE1A21MPF/p1561109199002400 after you submitted your PR 😄

clj 4
rborer09:06:45

so feel free to join the discussion there

dmaiocchi09:06:19

thx ! reading

dmaiocchi09:06:08

I was even not awayre of the channel

dmaiocchi17:06:32

yes thx nate for sharing. Really sad about it when discovered

dmaiocchi08:06:23

ok! thx. so it was a coincidence of a special ID of github 😁

pyr09:06:50

when using clojure + tools.deps as a cli, what workflow would you recommend for quickly adding deps on the fly

aisamu12:06:46

You need a special version that has add-libs

pyr09:06:29

I tend to always have a repl running but end up restarting it everytime i want to change the deps profile

misha11:06:45

is there a an out of the box way to read edn string containing aliased shortened keyword ::foo/bar into edn clojure data structure verbatim? or will it always try to expand into qualified keyword based on aliases in current namespace, where read is happening?

4
Alex Miller (Clojure team)12:06:56

edn does not support auto-resolved keywords at all

Alex Miller (Clojure team)12:06:47

:: keywords are not part of edn

Alex Miller (Clojure team)12:06:53

if you want to read files using the clojure reader as clojure data, then you can set the reader up with a custom resolver, but the resolver is still going to resolve to a keyword (not an autoresolved keyword)

Alex Miller (Clojure team)12:06:38

generally, I find it best with edn data on disk to just use fully-qualified keywords

misha13:06:50

yeah, seeing Schrödinger keyword in string is a bad news indeed.

andy.fingerhut16:06:28

Are there any subtle/interesting/non-obvious examples of functions of data sets that can be calculated in parallel using Clojure parallel reducers, or "almost can" but cannot be done so correctly? Is it the same class of functions that you can use something like Hadoop or Google Map-Reduce to calculate, I guess?

bronsa16:06:47

take/drop can be implemented by lifting the ordering requirement

andy.fingerhut16:06:15

ok, that definitely isn't obvious to me 🙂

Alex Miller (Clojure team)17:06:05

assuming you don't care which you get :)

andy.fingerhut17:06:58

My brain is limping along trying to figure out how, and it is probably because I'm missing something pretty big about reducers. The data set is split up into blocks that are each processed in parallel, with no information passing between the parallel threads (yet). Each calculates a result, which is then combined together with the others via the user's provided function. That function is just counting number of kept/dropped elements during combining?

andy.fingerhut17:06:05

I might be off even there.

hiredman17:06:22

if you haven't seen tesser it is a neat library that isn't based on reducers/transducers but is another way of specifying folds (I think released around the reducers time frame) that can run the folds in parallel or generate hadoop map reduce jobs, and it has interesing fold combinators that can be implemented for reducers/transducers but don't exist in the standard library

hiredman17:06:24

facet and fuse are really neat

andy.fingerhut17:06:22

Thanks for that pointer -- I had not heard of it before. The README docs have fun-looking not-commonly-seen-style of figures for on line docs.

lboliveira22:06:29

Hello! Can someone please point me what I am doing wrong?

(defrecord Hex [bytes])

(defn to-hex [bytes]
  (->> bytes
       (map #(format "%02x" (byte %)))
       (clojure.string/join "")))

(defmethod print-dup filter_db.core.Hex[o w]
  (.write w (str "#hex[" (to-hex (:bytes o)) "]")))

(defrecord Record [hex])

(defmethod print-dup filter_db.core.Record[o w]
  (.write w (str "#record[" (:hex o) "]")))

(binding [*print-dup* true]
  [(pr-str (Hex. (into-array Byte/TYPE [0])))
   (pr-str
     (Record.
       (Hex. (into-array Byte/TYPE [0]))))])

; actual -> ["#hex[00]" "#record[filter_db.core.Hex@85514e1d]"]
; expected -> ["#hex[00]" "#record[#hex[00]"]

seancorfield22:06:16

@lboliveira Because inside the print-dup for your record, you're just calling str on the hex object, so it doesn't go through the print machinery.

seancorfield22:06:51

Change (:hex o) to (pr-str (:hex o)) and I think it'll work as expected.

lboliveira22:06:44

thank you 😃