This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-17
Channels
- # announcements (1)
- # babashka (21)
- # beginners (46)
- # calva (21)
- # cherry (10)
- # cider (5)
- # clojure (54)
- # clojure-europe (16)
- # clojure-nl (2)
- # clojure-norway (37)
- # clojure-spec (7)
- # clojure-uk (4)
- # clojurescript (30)
- # conjure (3)
- # cursive (1)
- # datalog (5)
- # datascript (3)
- # datomic (13)
- # emacs (5)
- # fulcro (82)
- # girouette (1)
- # helix (4)
- # hyperfiddle (2)
- # joyride (1)
- # juxt (1)
- # kaocha (4)
- # lambdaisland (3)
- # luminus (1)
- # malli (15)
- # off-topic (60)
- # pathom (3)
- # polylith (1)
- # practicalli (3)
- # releases (1)
- # ring (4)
- # sql (3)
- # squint (85)
In https://clojuredocs.org/clojure.core/doseq it says "doseq does not retain the head of the sequence." What does that mean?
Since clojure builds uber jars. I am wondering. I have 2 projects A, B. Project B depends on project A. Both project A and B have a dependency C, however in different version. Now, in project B I have C as managed dependency. To graph this crap out :): B -> A -> C (v1) B -> C (v2 as managed dep) I am noticing project A fails when being upgraded to use C(v2), will project B work correctly with a managed dependency? I think yes, as project A is uberjar providing its own deps (so the managed dependency is only for nonuberjar deps in dependencies). Right?
uberjar is just an archive with all the source and necessary class files. when you add uberjar as a dependency there is a very high chance it will not work because those files might collide if root project trying to add different version of the same dep
this ☝️ also if you need both A and B to coexist within the same jvm and each use their particular version of C, https://github.com/benedekfazekas/mrandersonhelps with that
Thanks a lot, how do that relate to shaded/unshaded. Like I have some bit of knowledge that java artifacts can be in both forms (shaded/unshaded).
Is there a way to evaluate / refer a Clojure namespace with "instrumentation" applied to each form? I'm wondering if I can evaluate a namespace in order and measure the execution time of every form without wrapping every single form in a (time form)
call.
I've done it in the past, I applied https://github.com/ptaoussanis/tufte over each public var of a given ns sadly it's closed-source but it shouldn't be hard to implement
Yeah I figured I could cobble together something using ns-publics
; that requires me to have everything I want to measure bound to a var, but that's probably good practice for what I'm doing anyway for a fair number of reasons!
Only problem with that approach as far as I can see is that it may require two passes over a namespace that might have expensive computation in it (my use case is data science code): one to produce all the public vars, and a second to profile them.
> that requires me to have everything I want to measure bound to a var
not really, tufte can also work at the form level. You could read
forms from a .clj file, walk
over them, wrap them in tufte, and then eval each top-level form
now the question is: do you really want that? you'd get an exhaustingly detailed result
so it's better to start at the var level, and only focus on the slow vars, then split them, recur
it's not entirely about just identifying bottlenecks / hot spots. ML performance metrics + result coefficients might change on each eval too, so for those erring on the side of "exhaustingly detailed" is maybe OK
> Only problem with that approach as far as I can see is that it may require two passes over a namespace that might have expensive computation in it (my use case is data science code): one to produce all the public vars, and a second to profile them. Producing a public var is generally cheap - that's clojure compiler's job. Not data scientists' :) The profiling itself is very cheap - it's part of tufte's pitch So your code is compiled once, and ran once - just as usual
Hey all, if I wanted to run something like npx node-sass
in a background thread within a .clj file, would that be possible with only using Java’s ProcessBuilder
(https://docs.oracle.com/javase/8/docs/api/java/lang/ProcessBuilder.html) or will I have to use Clojure’s future
as well? Thanks!
you don't need too, it will be a background process, not a jvm thread. You may want to spawn a thread that wait for completion though

I remember seeing a project that's like core.specs.alpha
, but maintained by the community and (at present) covering more functions. Anyone know what I'm talking about and where to find it?
note that using it in all its fullness may have a significant performance impact
That's fine – I'm actually just looking at it for examples on how to write certain kinds of fdefs
And the ones I write will of course only be instrumented during development
then dive in!
what is the clojure way of generating a clojure file from xml? I use str now. I have db entities defined in xml. I want to build specs from them. write to file + format, comets. perhaps runtime only as well
zprint has a lot of options and sane default. For code generation, just building the data structure and writing with pr
should be enough. I don't know any code generation tool in clojure (except rewrite-clj but it could be too complex)
if it's for runtime only, you can have a look at how hugsql does it with def-db-fns
thanks @U02F0C62TC1.
I wonder how I can support comments. ;;
hey, do you have an example of the simplest “do action” when app detect is closing by killing docker container? I don’t need to detect reason. I mention about docker container to show the goal.
(.addShutdownHook (Runtime/getRuntime) (Thread. #(println "shutdown")))
Something better, than this? Or it is the good one.I found this one recently:
clojure.repl/set-break-handler!
([] [f])
Register INT signal handler. After calling this, Ctrl-C will cause
the given function f to be called with a single argument, the signal.
Uses thread-stopper if no function given.
not sure if that could helpI don’t know, but clojure.repl
doesn’t sound like something to use in production application.
> not sure shutdownhook will work when killing container though yeah and I am curious how much time the app have
(defn set-break-handler!
"Register INT signal handler. After calling this, Ctrl-C will cause
the given function f to be called with a single argument, the signal.
Uses thread-stopper if no function given."
([] (set-break-handler! (thread-stopper)))
([f]
(sun.misc.Signal/handle
(sun.misc.Signal. "INT")
(proxy [sun.misc.SignalHandler] []
(handle [signal]
(f (str "-- caught signal " signal)))))))
regardless of namespace that seems straightforwardpretty sure almost no has ever used that :) also, per https://ask.clojure.org/index.php/11576/clojure-repl-set-break-handler-bitrotted I think it does not actually work
❯ clj
Clojure 1.11.1
user=> (clojure.repl/set-break-handler! (fn [sig] (println "received: " sig)))
#object[sun.misc.Signal$SunMiscHandler 0x773dab28 "java.lang.Terminator$1@af78c87"]
user=> received: -- caught signal SIGINT
received: -- caught signal SIGINT
received: -- caught signal SIGINT
received: -- caught signal SIGINT
user=> ;; i hit Ctrl-c for the above
user=> (System/getProperty "java.version")
"17.0.1"
user=>
/shrugi was sending some coworkers my favorites from there and was surprised by it in (dir clojure.repl)
I have been using it to clean up my servers: https://github.com/bob-cd/bob/blob/main/apiserver/src/apiserver/main.clj#L23 but now I'm doubting it. Works well for my needs.
Should I not be using it?
ha. that’s like the one organic usage that http://grep.app found
Which fn splits up a collection by a predicate? By splitting I do not mean to cut it into 2 like split-with, but evaluate each element and return it in the according collection (similar to what split-with does). In the old clojure.contrib seq-utils, there was a fn named "separate", I'm looking for something like that (I've tried using group-by, but that is awkward, because if one of the lists would be empty, then the key is skipped completely, instead of having the key, but with empty collection)
group-by
shouldn't really be a problem if you use the normal clojure idioms, e.g., (if (seq (get results true)) :something ...)
you could also make a little wrapper around group-by
that wraps the pred in a (comp boolean f)
so you always get back true and false. Can then return whatever structure you want: a vector of true coll and false coll, keep the map but ensure it has both true and false keys, etc