We used to have it integrated but never used it. If you have specific questions I can look in our archives if you'd like. Just let me know
REPL driven development question… When I want to test a line in a function that depends on an argument without calling the function, what do you do to provide a value for the argument? Do you just throw in a ‘def’ or is there a better way?
also, with code that exists already, it's often useful to insert a tap>
call into the defn
, then use an add-tap
function that captures values for experimentation
this is my "stethascope" for examining internals of a running system with legacy code
I haven’t ventured into debugging running/deployed code. Tap is new to me, I’ll read about it. Maybe @seancorfield will cover such wizardry in his upcoming talks? Thanks for the suggestion.
@dcreno I will make sure I cover that (since I use Reveal alongside my editor to show all tap>
'd values).
I would do a let
- doesn’t def
create global scope?
What I often do is pull the line out of the function, and execute it in the repl, wrapped in a let
Doesn’t always work of course
@dcreno Put a (comment ,,,)
form immediately after the function. Then put (def addend 4)
inside that comment and evaluate the def
, then you can eval any form inside the function.
That way you're not modifying the "production code", but your scratch code stays visible and available in your code for future use.
And maybe attend one of my online talks in December/January https://corfield.org/blog/2020/11/24/talks-clojures-superpower/ 🙂
Thanks! I know it’s a bit of a silly question but I figured there was a common way.
I like the (comment …)
version.
"Rich Comment Form"
(because Rich Hickey does this too)
(and definitely not a "silly question" -- getting to a really efficient RDD workflow is something that a lot of people struggle with, because it's not like how you work with other languages)
How can fix the error:
clojure -M:uberjar
Compiling yubrshen.unique-errors ...
Compilation of yubrshen.unique-errors failed!
Could not locate yubrshen/unique_errors__init.class, yubrshen/unique_errors.clj or yubrshen/unique_errors.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
I'm use an app template from: https://github.com/seancorfield/clj-new
Here is the related alias for :uberjar:
:uberjar {:extra-deps {seancorfield/depstar {:mvn/version "1.1.128"}}
:main-opts ["-m" "hf.depstar.uberjar" "unique_errors.jar"
"-C" "-m" "yubrshen.unique-errors"]}
It seems that I may need somehow to install unique_errors.jar?
Thanks!What are the file/folder names used? It looks like a classpath error. Your namespace yubrshen.unique-errors
includes a dash which is okay, but your filenames should uses underscores, replacing the dashes.
Hello everyone, is there a way to get the query result without the brackets?
(d/q '[:find (pull ?e [:commit/rev])
:in $ $date
:where
[?e :commit/date ?date]
[(> ?date $date)]]
@conn date)
;; => ([#:commit{:rev "25ed6cb"}]
;; [#:commit{:rev "02a760a"}]
;; [#:commit{:rev "61df934"}]
;; [#:commit{:rev "d6524ab"}])
Like this but without the extra step.
(->> result
(reduce (fn [acc e] (conj acc (first e))) '()))
;; => (#:commit{:rev "4e2cce7"}
#:commit{:rev "13c57d1"}
#:commit{:rev "8a3fd52"})
@lukas.block you can try doing this if it helps:
(map first result)
;; or
(->> result
(map first))
I believe there’s a way to do it in the query without extra work afterwards
hey thank you. The reduce was just an, I have to admit overly complicated example, for an extra step
What is a good tool to ‘make 150 http requests (random order) with N workers’ ? Should I reach out to java.util.concurrent?
Going to do now with what I am familiar with .. java.util.concurrent.ExecutorService
but I am interested in learning more about clojure.async
which also seems to be able to do this
That looks very nice. I'll take a peek.
Client libraries like httpkit allow you to pass an optional thread pool (number of workers). You can then use core.async's async-pipeline to control the number of inflight requests
I need to investigate that. Right now I have a simpler approach:
(defn ping-endpoints [endpoints]
(let [pool (Executors/newFixedThreadPool 8)
tasks (for [url endpoints] #(ping-endpoint url))
futures (.invokeAll pool tasks)]
(for [f futures] (.get f))))
I wish I could just keep all data in memory and not bother with databases
Isn't this basically datomic?
Apparently the 4clojure server is down hmmm
Anyway, am doing qn 39 have a solution to make my own version of interleave but is there a way I can remove vector
? Like by changing concat
to something else?
(defn leave [a b]
(when (and (not-empty a) (not-empty b))
(concat (vector (first a)) (vector (first b))
(leave (rest a) (rest b)))))
You don't care if your data disappears when the power goes off?
I believe quite a few databases are good at keeping recently used data cached in RAM.
I think you can use list* there
yeap list
works too but was wondering if there's a concat that doesn't require elements to be in some form of collection
List* is that
Distinct from list. Often you’ll see lazy-seq cons cons leave
oooo! yeap it works
Also does anyone understand why mapcat vector
works as a replacement for interleave
?
Okay nvm I got it, but I never knew that map applies the f to the first item of each coll then the second items and so on
yeah its a neat feature of map. other languages need a bespke map2, map3, etc