This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-26
Channels
- # announcements (1)
- # babashka (106)
- # beginners (11)
- # biff (7)
- # calva (16)
- # clj-kondo (40)
- # clj-on-windows (5)
- # clj-yaml (10)
- # clojars (4)
- # clojure (37)
- # clojure-austin (22)
- # clojure-australia (1)
- # clojure-europe (40)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-spec (6)
- # clojure-uk (6)
- # clojurescript (13)
- # conjure (11)
- # cursive (14)
- # datalevin (8)
- # datascript (5)
- # emacs (39)
- # events (1)
- # fulcro (55)
- # gratitude (4)
- # holy-lambda (2)
- # humbleui (9)
- # instaparse (1)
- # lsp (3)
- # malli (12)
- # meander (2)
- # membrane (7)
- # nbb (1)
- # off-topic (16)
- # pathom (9)
- # releases (3)
- # sci (14)
- # shadow-cljs (25)
Hey. Did I do something wrong or something isn't right about my env?
Caused by: java.lang.Exception: Cyclic load dependency: [ /clojure/spec/alpha ]->/clojure/walk->[ /clojure/spec/alpha ]->/clojure/main->/clojure/core/server
Clojure 1.11.0
Java openjdk 11.0.16.1 2022-08-12
Went to ~/.m2/repository/org/clojure/clojure
and removed rm -r 1.11.*
and notnow it seems to work...
How could this happen even... how could these Jars get corrupted this way? :thinking_face:
I have malli, XTDB, core.async, and many more. Are there any I should look for?
Also I was trying to hack clojure.walk
and tried to call it using my own functions.
I was interacting with malli primarily when this came up.
And this is given by lein uberjar
so maybe it's somehow related to some kind of recent change in the classpath. Not sure.
It might be best to publish your deps.edn
or project.clj
somewhere to reproduce the problem
I can't reproduce it myself. If it comes up again I'll try to do it. Maybe I'll notice something.
In Emacs/Cider you can navigate into the clj files stored in the jars on the classpath and then edit and save those files, updating the jar file on disk. If you introduce a cyclic dependency and then restart the REPL you'd be able to create this problem. I assume that things like this are also possible with other tools, but I've only done this with Emacs in the past.
I use nvim with Conjure and it could be possible. Edit: No, it doesn't allow to save. But it could still probably be possible somehow.
I think that Emacs by default marks the buffer as read only when you open it from a jar but it didn't used to. But you can toggle read only mode and then save it. I'm afraid I know little too nothing about vim/nvim.
Hey, I am debugging something where I see a clojure.lang.ArraySeq
appearing. Is there another way to get an implicit conversion to ArraySeq
apart from the two following
(type (seq (make-array Integer 5)))
;; => clojure.lang.ArraySeq
(defn foo [& args] (type (seq args)))
(foo 1)
;; => clojure.lang.ArraySeq
The first one is not really implicit. I am wondering if there are cases I am not aware of.
You could try finding references to ArraySeq's constructor and its create
method here: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ArraySeq.java
There are a lot, though.
how would i write a macro that would allow the injection of an argument to the body for example generating a uuid and using it:
(with-uuid [uuid]
;;do something with the uui)
i.e.
(defmacro with-uuid [[uuid] & body]
`(let [uuid ;; somehow assign (java.util.UUID/randomUUID) to binding above]
~@body))
or some suchyou could do something like:
(defmacro with-uuid [uuid & body]
`(let [~uuid (java.util.UUID/randomUUID)]
~@body))
;; usage
(with-uuid foo
(prn foo))
;; #uuid "68c03052-01ef-4284-a7f7-0fdbc63b34f9"
• is there a reason to not just type it out?
• fyi, starting in clojure 1.11, there's random-uuid
• why is the uuid arg wrapped in a vector in your example?the uuid was just a simple example i came up with to try and make my question clearer, i was basically just wondering how to "assign" to a list of bindings
another similar example you can check out is clojure.core/with-open
:
(defmacro with-open
"bindings => [name init ...]
Evaluates body in a try expression with names bound to the values
of the inits, and a finally clause that calls (.close name) on each
name in reverse order."
{:added "1.0"}
[bindings & body]
(assert-args
(vector? bindings) "a vector for its binding"
(even? (count bindings)) "an even number of forms in binding vector")
(cond
(= (count bindings) 0) `(do ~@body)
(symbol? (bindings 0)) `(let ~(subvec bindings 0 2)
(try
(with-open ~(subvec bindings 2) ~@body)
(finally
(. ~(bindings 0) close))))
:else (throw (IllegalArgumentException.
"with-open only allows Symbols in bindings"))))
although assert-args
is private, so you can't use that directly in your implementation
The easy way to do this style of macro is to write a helper function that takes a callback, and then just write to macro to expand to a call to it
The long term problem with the callback approach is it breaks recur, but it is a useful start
yeh thats what we had before, someone wrote a function that accepts a callback, generates an ftp connection and then passes that connection to the callback, i thought it would look cleaner as a macro where you could do
(with-ftp [ftp]
;;do stuff)
similar to
(clojure.java.jdbc/with-db-transaction [tx db]
...)
Do we have a web crawler library for Single Page Application web page? I need to get data from 1 website, but the only one way is to simulate web browser, go through the DOM and extract this data. I can write everything from the beginning, but something has to exist 🙂
This is what I used in the past when I needed to write frontend tests: https://github.com/clj-commons/etaoin
I am a big fan of htmlunit for scraping, because it basically a headless browser written in java, it is just another jar. It does have some limitations to what is it can handle
I've messed around a little with playwright which bundles headless browser builds with it
Neither htmlunit nor playwright have been able to circumvent FedEx's antiscraping stuff which is a bummer
Does it work with Single Page Application. Javascript is needed and clicking on website simulation. @U0NCTKEV8 @U03TPPC0R0T?
Htmlunit can run javascript, playwright uses real browser runtimes, so it can as well
Antiscraping, I dunno, some kind of magic so when I load the page in playwright, using a real browser runtimes, it still detects something different from a real browser engine and the js renders an error page instead of the tracking information
@U0WL6FA77 etaoin uses webdriver to hook to a full Firefox browser so it should work fine with SPA, it's why I chose it.
Regarding the anti-scraping tech, I had success using puppeteer-extra-plugin-stealth
(https://www.npmjs.com/package/puppeteer-extra-plugin-stealth) to get around Cloudflares bot detection page. It might help with Fedex.