This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-11
Channels
- # announcements (21)
- # aws (2)
- # babashka (20)
- # beginners (47)
- # bristol-clojurians (2)
- # calva (63)
- # cider (24)
- # clj-kondo (22)
- # cljs-dev (3)
- # cljsrn (6)
- # clojars (3)
- # clojure (147)
- # clojure-europe (21)
- # clojure-france (2)
- # clojure-italy (3)
- # clojure-losangeles (1)
- # clojure-nl (3)
- # clojure-spec (2)
- # clojure-uk (70)
- # clojurescript (37)
- # core-logic (6)
- # cursive (4)
- # data-science (2)
- # datomic (99)
- # events (1)
- # figwheel-main (20)
- # fulcro (26)
- # graalvm (6)
- # graphql (5)
- # kaocha (8)
- # leiningen (20)
- # meander (22)
- # nrepl (4)
- # off-topic (27)
- # pathom (5)
- # pedestal (3)
- # re-frame (20)
- # reagent (4)
- # shadow-cljs (43)
- # spacemacs (11)
- # tools-deps (55)
- # tree-sitter (6)
- # vim (8)
- # xtdb (18)
- # yada (14)
Is there a standalone way to install clojure deps/cli without homebrew?
Maybe this might help? https://clojure.org/guides/getting_started
Maybe the Linux sh script would also just work on Mac. No idea though - it might be a good idea to read through the script before you actually run it with sudo
.
You might have trouble unarchiving the archive though, as the OS sees it as something different than a plain old archive. Just unarchive it however you can and follow the instructions after that.
the linux script should also work on mac
No, it wonāt
install
and sed
will complain about given arguments. On mac coreutils
and gnu-sed
packages are required to run linux-install script
or to use original install and sed arguments should be changed like that:
for the install
-D should be replaced with -d
for the sed
-e -> -E
My patch to make linux-install cross-platform is here - https://clojure.atlassian.net/browse/TDEPS-36
People who have used one of the many saml20-clj
libraries to add SAML support to your projects, which one did you use? Thereās 23 forks of https://github.com/vlacs/saml20-clj of which the kirasystems
one seems to be the most up-to-date ā but metabase
also has a somewhat active fork.
Iāve used org.opensaml/opensaml-saml-impl {:mvn/version "3.3.0"}
before, but I donāt know why exactly. I think I copied it from another project. It was only to parse the saml response
So opensaml 2 was EOLāed back in 2016, all the clojure wrappers are based on that. Opensaml 3 is mildly incompatible so itās probably not a small feat to migrate.
Our very own @U07QKGF9P suggests in https://news.ycombinator.com/item?id=22496736 to āoutsource that infrastructure to a vendorā, mentioning Cognito, but Iām not sure this is a solution for everyone.
From the same thread: āMy best advice for safely using SAML is: use a library thatĀ everyone usesĀ and that is well tested. This is a place where I might stand up aĀ separate service in a different languageĀ to get a popular SAML library rather than the shady one that is most convenient for your preferred platform.ā ā but stopping short from actually endorsing a language or library š
My research so far brings up OpenSAML, CAS, PAC4J, OneLogin ā all Java-based libraries that deal with this, no Clojure wrappers that I could find, all require quite a lot of effort to build something, and itās still not clear if you open yourself up to security issues if you try to use them any way.
How would you like to use Saml? Can you use AWS Cognito for instance?
We have all our login/signup/SAML infrastructure already setup. But, the overhead of keeping it up-to-date regarding security, plus the constant stream of requests like MFA and other modern measures makes me want to look elsewhere. Cognito is a possibility since we are on AWS already.
anyone has a config they are happy with for zprint? preferably something not too disruptive and that matches cljfmt, emacs indentation?
for example, if I accidentally typed: (range 10000000000). Hitting C-c to stop the repl does no good.
you could configure the repl to not realize entire sequence by configuring https://clojuredocs.org/clojure.core/*print-length*
The behavior of different ways of starting the REPL is different here, I am pretty sure. If I start a REPL from macOS Terminal using clj
and type an expression like that, and press C-c, it quits the whole JVM, so also quits the REPL.
Clojure itself does not (and I think can not) control how different REPL environments handle this.
on a side note, if you want to get back in when things are stuck (e.g. to see some value), you can try this: https://github.com/sogaiu/alc.start-repl
Hi all, wondering if anyone has answer why sometimes derive
throws an error if child already has an ancestor, and sometimes it doesn't:
(-> (make-hierarchy)
(derive :a :b)
(derive :a :b)
=> fine
(-> (make-hierarchy)
(derive :a :b)
(derive :b :c)
(derive :a :c))
=> error
Is there some ambiguity involving transitive relationships that this is trying to protect against?diamond inheritance?
I don't actually know the answer to your question off the top of my head
I'm assuming the first case is basically treated as a no op but the second triggers a check for multiple inheritance paths
Just checked out the source, and the first case is indeed a no-op. The error condition does not seem like it would guard against ambiguities like diamond inheritance, but this was still very helpful for me. Thanks!
Trying to understand the functionality here: https://github.com/juxt/pack.alpha#onej Highlighting
$ clj -A:pack mach.pack.alpha.one-jar output.jar
$ java -jar output.jar
I imagine this outputs a jar and then we run the jar using "java -jar output.jar".
so the options list:
-m, --main STRING clojure.main Override the default main of clojure.main. You MUST use AOT compilation with this.
Which then i assume mean the default is clojure.main. So were going to run clojure.main and not necessarily execute anything in the specific jar?
So then if you do want to specify a default main you have to use AOT.
Finding a link on AOT https://clojure.org/guides/deps_and_cli#aot_compilation
Those docs might assume some background i dont have. Is it suggesting that you have to call gen-class on every function? I'm not sure in general how to full fill the contract purposed by the option above of using AOT compliation.clojure.main being the default means you can use clojure.main to launch your clojure code without aot compiling
https://github.com/clojure/clojure-site/blob/22ae089533d3ee443dfbe1d0654b956036fd66e7/content/guides/running_a_clojure_program.adoc might be helpful, it doesn't deal with pack.alpha specifically but generally discusses the issues around running a clojure program
it does look like pack.alpha specifically does some extra stuff so it can be given a clojure namespace to start without aot compiling it
ah, it depends on which uberjar method you use, the Capsule one says aot is not required, the OneJAR one says it is
i interperated it to say that if you didn't specify a main namespace then it used clojure.main. Then when you run the java command you need to pass that namespace like you said here: java -jar output.jar -m your.main.namespace
correct, but if you look at the docs for Capsule it says you don't need a gen-class in the main namespace (which is equivalent to saying it doesn't need to be aot compiled) while as you noted, the OneJAR options say the main namespace must be aot compiled
you might want to consider something with fewer bells and whistles like https://github.com/seancorfield/depstar
yea, maybe. The role of clojure.main here is that it reads your clojure files at run time right? The alternative is that you compile the clojure ahead of time so that the above step isn't necessary?
but clojure.main isn't special, it is just a class file, and the jvm understands class files not clojure, so you can generate your own class file in an number of different ways, use that instead, but then also have that load clojure code
Is there a way to suppress warnings? Specifically WARNING: name already refers to: #'clojure.core/name in namespace: r.manufacturer, being replaced by: #'r.manufacturer/name
. I understand the warning but in my case it's not a problem and I don't want to see the warning
^^ (ns ... (:refer-clojure :exclude [name]))
Cheers thank you @U050MP39D @U064X3EF3
if I use gen-class like this, will the method evalString be available from Java?
(ns sci.impl.native-lib
(:require [sci.core :as sci])
(:gen-class))
(defn -evalString [s]
(sci/eval-string s))
I think it will actually - using in ns takes a bunch of defaults
I'm asking because I keep getting:
src-java-native/borkdude/sci/SciNativeLib.java:18: error: cannot find symbol
sci.impl.native_lib.evalString(expr);
but not for -main
Why donāt you just use javap to look at what the class has?
I will change my answer to no based on reading the gen-class docstring :)
main is special and defaults to true if used in ns
You need to annotate the method with ^:static
And add to :methods
reading docs ftw
Hello everyone. How can I set Java array item to nil? I tried (aset (int-array 3) 0 nil)
but it throws an error
> Execution error (IllegalArgumentException) at chapter1.stack.extended-stack/eval17432 (REPL:59).
> No matching method aset found taking 3 args
Also is there a way to initialize an array with nils, not with some monodic values (like 0 for int for example)
Oh I see! Thank you!
Is there a way to do auto-wrapping for primitive types in Clojure?
just trying to implement stack with extandable array. To create an array I need to use some type, but to avoid loitering I need to assoc unused elements to nilā¦ Which make a restriction to which types can be used. Iād like to do autoboxing here, like if you create stack with Integer/TYPE
as a type, use Integer
actually
letās say I want to write function with this semantic:
(box Integer) ;; Integer
(box Integer/TYPE) ;; still Integer
if you are still playing with datastructure implementation, I would highly recommend just ignoring primitives and getting it running the easy/dumb/slow way with ordinary boxed vectors
yes, looks like itās the simpliest solution
Specially if you want your data structure to be persistent, it makes sense to base it off existing persistent things.
Yes, but if I want to have a generick stack, if I use primitive types with java they will be autoboxedā¦ just want to reproduce the same behaviour
yes, I want to have Stack<T>
Create a stack of Object
, then put only T
into it.
That's what Java does. (if I understand correctly)
That is correct. The compiler also ensures you only ever put T. But at runtime, it's all objects.
Oh great! thank you!
not that I would ever run into it, but this kinda surprises me
user=> (aset my-longs 1 9)
Reflection warning, NO_SOURCE_PATH:1:1 - call to static method aset on clojure.lang.RT can't be resolved (argument types: [Ljava.lang.Object;, int, long).
9
user=> (aset my-longs 1 (Long. 9))
9
This must be a special situation then. It does not autobox when setting to Java array.
yeah that's what I meant was surprising š well actually it does autobox, but it has to reflect first
this isn't really a Clojure specific question, but for those of you out there who write Clojure related blog posts, what's your platform of choice? is there a good alternative to Medium?
@joshkh I use Octopress for generation and host on GitHub under my org name. With my original domain pointing to it. http://corfield.org
How do I find the ns of a keyword?
user=> (namespace :foo/bar)
"foo"
I should have known this haha
if this were linked from (doc keyword)
I would have given more of an RTFM answer, but honestly there's no straightforward way to ask clojure itself about that particular task
(apropos "namespace")
would have helped if you'd thought to try it though :D
Haha. Interesting with apropos. So much to learn š
similarly, there's find-doc
for searching not only function names but also doc strings by regex
@joshkh I used Hylia (https://hylia.website/) but found the Netlify CMS to be buggy. So I just do it with markdown.
cool, markdown seems the way to go. and i like @U04V70XH6ās github pages solution. sounds like a good solution to use both.
Netlify itself is great tbh. I would always use Netlify.. havenāt seen anything better. I just mean their open source CMS which Hylia comes pre-configured with. You could easily remove it
besides telnet
are there other ways to interact with a socket repl? Is it possible to send code to a socket repl and get the response back via some command line tool?
I was under the impression that most connected to nREPL, I use vim-fireplace which I believe only works with nREPLs
in this case though Iām more interested in interacting with it via the command line
tubular is a cli socket repl client https://github.com/mfikes/tubular
Atom + Chlorine can connect to Socket REPL, as can Emacs + inf-clojure. Probably something in VScode + Calva, too, but I haven't checked.
I use nc, but that is basically a more scriptable telnet
If you really want to invoke a command from the terminal and interact with a socket REPL, those are not in that category.
in vim I can do :w !nc localhost 5555
and that sends my current buffer to my socket repl
which is all I need much of the time
there's also a vim plugin for socket repl
@U051SS2EU I did see`nc` when I was searching, I tried running it and it gave me nothing though
nc host port
- point it at the host and port of your repl
https://github.com/jebberjeb/clojure-socketrepl.nvim the vim socket repl plugin is only for neovim I guess
on stdout, yes
this seems pretty nice ~/C/clj-scratch $ clj -A:tubular -m tubular.core -p 5555 16:39:40
if you want to do anything interactive and happen to be limited to cli AND can't do ssh port forwarding. rather specific š
@U051SS2EU got it, thanks, bit weird to get the user prompt I suppose
@U0CLLU3QT so as you can see from the screenshot it doesn't just return 2 - it also prints prompts, but 2 is in there
yeah - it's really oriented to be an interactive tool
when using an nrepl I use fireplace#platform().Query(ā¦)
a bunch, I was hoping for a socket repl cli equivalent of that I suppose š
it's possible to run something other than clojure.core.server/repl - might be straightforward to make a minimal server function that's identical except it doesn't offer a prompt(?)
sounds like the jebberjeb clojure-socketrepl :EvalForm command might be closer to what you want if you are OK with using neovim