This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-14
Channels
- # architecture (19)
- # beginners (3)
- # calva (2)
- # cherry (2)
- # clj-kondo (2)
- # clojure (58)
- # clojure-europe (15)
- # clojure-norway (1)
- # conjure (1)
- # data-oriented-programming (9)
- # data-science (10)
- # emacs (9)
- # hyperfiddle (1)
- # nbb (9)
- # off-topic (1)
- # shadow-cljs (24)
- # sql (14)
- # squint (58)
- # testing (13)
- # xtdb (10)
I see . I thought some interface is required to be implemented by the argument. Turns out not.
@U11BV7MTK I saw too many places in metabase
’s codebase on arglists. What’s the main purpose? documentation? ( I can only think of).https://github.com/metabase/metabase/blob/master/enterprise/backend/src/metabase_enterprise/serialization/serialize.clj/#L35
Yes documention. Since the function is defined with partial and not a defn form it would not have arglist documentation automati
Are you using cider? Calva does not have the arglist for multimethod showing. Actually this probably is not a Calva problem, it is the cider-nrepl not showing it, but I am not using Cider so I am not sure how actually the Cider behaves.
@U0ETXRFEW sounds like cider can do it.
Though, for some reason Calva loses track on the current argument when the lists are provided as lists. Providing them as vectors work. Very strange.
Cool. Must be something wrong on my side. Btw, how do you get the colorflu one, two ?
The colorful current arg markup is probably something that the theme needs to implement. I'm not quite sure though. I'm using GitHub Dark default.
Maybe you forgot to evaluate the defmulti
after adding the arglists, @UGC0NEP4Y?
what could be happening? I've done this sort of thing before
java -jar my-uberjar-standalone.jar clojure.main -m my.main
{:clojure.main/message
"Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).\nclojure.main, (No such file or directory)\n",
:clojure.main/triage
{:clojure.error/class java.io.FileNotFoundException,
:clojure.error/line -2,
:clojure.error/cause "clojure.main, (No such file or directory)",
:clojure.error/symbol java.io.FileInputStream/open0,
:clojure.error/source "FileInputStream.java",
:clojure.error/phase :execution},
my/main.clj
(actual name redacted) does exist in my uberjar
(I'm intentionally skipping AOT, and indeed I get a .clj file and no .class files for the project itself)Because you're using -jar
, it is running clojure.main
automcatically, so the rest of your command-line is being passed as arguments to clojure.main/-main
as strings: "clojure.main"
, "-m"
, "my.main"
So it looks for a Clojure script to run called clojure.main
and cannot find that.
You want -cp
instead of -jar
@U45T93RA6
java -jar my-standalone.jar -m my.main
worked as well. I have to use -jar for devops reasons.
Thanks much for the hint! :)
I wonder if the implicit setting of clojure.main
as a :main from Leiningen's side was a reasonable choice (maybe you have to set something?)
I had never encountered this before as I'm more used to -cp
-jar
runs -main
from whatever class is specified in the MANIFEST.MF
file in the JAR for Main-Class:
which I think most Clojure tooling defaults to clojure.main
if you don't specify a different class (namespace).
It used to be the clojure jar itself set that and tools that made uberjars might pull it over through that. But now you need spec so that won't work anymore
@U064X3EF3 Can you clarify what "won't work anymore"?
Using only the Clojure jar with -jar
Which we're not talking about in this thread 🙂
I know, but we used to set it, and then during uber some tools would pull it over into the uber manifest, which could be how / why lein did this now
Ah, wow, that seems fragile...
does anyone have join-paths snippet that would be reasonable for most cases of paths, I know the problem is quite complex and difficult to converge in generic way, still looking for good candidates to cover 95% 🙂
You mean file system paths? If so,
might be suitable.
Alternatively, you can use java.nio.file.Paths/get
, although given that it's a variadic function, the interop isn't as nice.
I mean most paths, including urls... but without understanding the nature of urls, rather looking for common separators
The /
part is pretty universal in most things we commonly refer to as "path" (Even Windows reading a file path will typically read /
just fine, even if it writes back out a \
in its place.) Beyond that you need to know the rules of your protocol.
If by "path", you really mean URI (i.e an absolute local "file" path would look like
), then https://github.com/lambdaisland/uri could be helpful. The API does include join
, which follows RFC 3986 rules for path merging.
I've been pretty deep in that code and can verify it follows RFC 3986 spec quite closely. The only major flaw I've managed to find so far in regards to said spec is he encodes spaces with +
instead of %20
. That comes from the HTML Forms spec, and IMHO should be outside the scope of a lib that makes no other reference to HTML, and only even mentions HTTP in usage examples.
If a web handler is part of a https://github.com/stuartsierra / https://github.com/stuartsierra/component is it possible to reload it outside the component lifecycle? It would be nice to speed up the reload by having clojure tools namespace repl do the work, which on my tiny projects works given you hand the handler ref and not the value e.g do this: #'handler
or this (fn [x] (handler x)
not this handler .
But on a larger project, once that handler is part of component lifecycle it doesn't seem to get affected by a ns refresh.
Cljfmt is popular but there is also https://github.com/kkinnear/zprint which offer lots of fine controls and https://github.com/greglook/cljstyle (which is a rewrite of cljfmt).
By chance is there a good tool for formatting stdin to stdout? Maybe https://github.com/borkdude/jet?
cljfmt has an open issue https://github.com/weavejester/cljfmt/issues/255.
jet is more for edn data transforms/searches, but it does have a --pretty option for pretty printing edn.
Anyone aware of any resources/advice to ease porting a Django app?
I’m a fairly recent convert to Clojure{,Script}; I imagine this would just be a Ring app. It has to talk to a local mysql database and it has to drop mail in the local mail queue too
Have done it around 5 years ago. Don't think there's anything that makes it easier, but the rewrite itself was pretty straightforward even though I used to use a significant chunk of Django functionality at the time, along with the Rest Framework.
I would just call it a rewrite and not a port and get started, but it’s a requirement that I not force the users to recreate their accounts
I had to do the same. It ended up in me extending the right multimethods of buddy
so it can parse and create digests of the right format.
Alternatively, you can just add a DB migration that simply converts the digests (assuming you're using the most trivial user account storage - password digest in the DB).
That should be doable. Would recommend something like integrant, Component, or similar tool to manage stateful resources like the mysql db connection
@U2FRKM4TW I am, and when I first picked up clojure I did fool around with buddy and arrive at some functions that would serve. Maybe that’s just the thing to do. @U8WFYMFRU Will investigate these, thanks!
I guess I should just jump in. From where I now stand, just upgrading to Django 4.0 and python3 doesn’t seem like fun.