This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-19
Channels
- # ai (4)
- # announcements (1)
- # babashka (6)
- # beginners (31)
- # biff (1)
- # calva (11)
- # cider (9)
- # clerk (6)
- # clojure (40)
- # clojure-europe (49)
- # clojure-nl (1)
- # clojure-norway (30)
- # clojurescript (17)
- # conjure (1)
- # core-async (2)
- # datalevin (28)
- # emacs (1)
- # events (4)
- # fulcro (7)
- # gratitude (1)
- # guix (4)
- # hyperfiddle (19)
- # juxt (10)
- # luminus (4)
- # malli (4)
- # missionary (11)
- # nbb (3)
- # pedestal (7)
- # reagent (27)
- # reitit (2)
- # releases (1)
- # shadow-cljs (32)
- # tools-deps (6)
- # xtdb (5)
Is there a very simple searchlib? I want so say given: [dark cloud 2, darc kloud, dark cloud] , search for the entry of "dark cloud" for example, and get the results in order of relevance. I dont need full lucene, I dont need indexing or anything like that, I'll be searching over small strings on a small collection.
https://cljdoc.org/d/datalevin/datalevin/0.8.16/doc/search-engine Datalevin's search could be a great fit for this
and just to put options out there, something like clj-fuzzy might provide an algorithm that'd be usable in your context, like sorting by levenshtein distance or whatever. clj-fuzzy hasn't been updated in a while, but that might be because it's one of those libraries that doesn't really need to change much (because it's largely string algorithms)
This might be somewhat of a fringe requirement, but does anyone know of any project (preferably Clojure of course) that lets you configure a given GitHub repo declaratively from a edn or json-file?
I often find myself wanting to apply the same settings to most/all of my personal repos, such as
• protect main-branch
• allow non-trunk rebase from PR UI
• automatically delete head branches
I could do it using gh
, but if someone has solved this in a data-driven way, where I could just store my preferred repo config in git and apply it at will, would be even nicer
Terraform? https://registry.terraform.io/providers/integrations/github/latest/docs
I'm not a huge fan of terraform because its DSL is weird but it's ubiquitous, so 🤷 If you go down that path there's also https://github.com/luchiniatwork/terra which supposedly allows you to write terraform configurations with EDN syntax but I haven't used it myself and it hasn't been active for years so I'm not sure how well it supports modern Terraform
That said, it's probably simpler to use the https://docs.github.com/en/rest/quickstart?apiVersion=2022-11-28 directly (plain HTTP calls). It won't be declarative and you'll have to write your own utility functions but it will fit your use case like a glove (and you'll understand exactly how it works)...
Yeah was wondering if IaC might be the way to go here... It just felt a bit like over-engineering to just keep my personal projects tidy, but maybe not? Pulumi also seems to https://www.pulumi.com/registry/packages/github/api-docs/repository/, and from a blog post from last year, seems to support Clojure indirectly via the java sdk > Pulumi Adds Support for Java, one of the Largest Language Ecosystems in the Cloud > With new support for Java, Pulumi expands reach to the large community of Java developers who previously have not been able to use infrastructure as code to tame cloud complexity. Organizations can now use all JVM-based languages such as Java, Scala, Clojure, Groovy, Kotlin to build, deploy, and manage cloud infrastructure. I'll keep tabs on the IaC route and think about it! Thanks for the reply 🙂
Oh, I missed the part where you mentioned personal projects... I'd probably go down the HTTP API route if I were you if it's just to tweak a few settings in new repos. You'd lose state management but I don't think it's a dealbreaker for personal projects. However, I also don't think IaC is overkill, especially if you have a lot of personal repos and you set it up gradually.
I think IaC tools (Pulumi/Terraform) are perfect for this use case. You can use Pulumi with YAML which, trading off some flexibility for the nice, static, declarative style.
Whats particularly interesting, given that I just cloned tools.deps in a lot of areas, is that clojure just fails in this case
clojure -Sdeps '{:deps {org.jboss/jandex {:mvn/version "3.1.2"}}}' -Stree
Error building classpath. Could not find artifact org.jboss:jandex:jar:3.1.2 in central ( )
Yeah, that's been a fairly long-standing feature request for tools.deps. I just ran into it with the MySQL connector lib which changed to a relocation on a patch release (8.0.31).
https://ask.clojure.org/index.php/7836/tools-deps-does-not-handle-maven-relocations?show=7836#q7836
It’s a nontrivial fix
Is the thing that makes it nontrivial that lib names are detached from coordinates usually?
it just affects a lot of assumptions in the code
Presumably, this case is similar to the b.o.m. case? You have a coord that has no associated JAR but leads to what look like transitive dependencies...
no, you really need to replace it's identity entirely (lib and coord) with an alternate
there is danger in including both the original and relocated coords in your deps tree if you don't canonicalize them to the same thing
since this was logged I've added a canonicalization phase that should be able to support this, but I have not really tried to make that happen yet and I suspect there are paths that don't canonicalize
the problem with groupIds that start with a number has similar scope issues - this means you can't use a symbol to represent the lib (as we do everywhere now)
The mysql/mysql-connector-java case is particularly problematic there since 8.0.30 resolves as-is and com.mysql/mysql-connector-j is a "different" group/artifact so tools.deps wouldn't even realize they are the same library. And the 8.0.31 resolves via relocation to the other coords. Ugh!
(~/clojure/mysql)-(!2015)-> cat deps.edn
{:deps {mysql/mysql-connector-java {:mvn/version "8.0.30"}
com.mysql/mysql-connector-j {:mvn/version "8.0.31"}}}
Mon Jun 19 11:25:26
(~/clojure/mysql)-(!2016)-> clojure -Stree
org.clojure/clojure 1.11.1
. org.clojure/spec.alpha 0.3.218
. org.clojure/core.specs.alpha 0.2.62
mysql/mysql-connector-java 8.0.30
. com.google.protobuf/protobuf-java 3.19.4
com.mysql/mysql-connector-j 8.0.31
. com.google.protobuf/protobuf-java 3.19.4
And then if you run clojure -Tantq outdated :upgrade true
and innocently accept all the upgrades, they both end up on 8.0.33 and tools.deps can no longer resolve the first one.
It's a tricky one to solve.
(imagine either of these coming in as transitive deps!)
Is there a way to do this? (def [a b c] [1 2 3]) I know I could do (def a 1) (def b 2) (def c 3) or (def temp-coll [1 2 3]) (def a (nth temp-col 0)) (def b (nth temp-col 1)) (def c (nth temp-col 2)) or something clever with "binding" This is when poking with the repl, and then presumably I will convert to a "let" later in the code's life....
are you typing these forms directly into the REPL? if you are, I'd suggest using a (comment ...)
form in a source file to contain the let binding you're building up rather than using temporary defs to prototype a function.
defining vars from the REPL can make things a little tricky to reproduce and debug, and writing a macro to make that easier might be solving the wrong problem.
For a one-off:
user=> (doseq [[s v] '{a 1, b 2, c 3}] (intern *ns* s v))
nil
user=> b
2
(note that it's a map in there so you can't rely on its order)https://clojuredocs.org/clojure.template/do-template this is a bit newbie friendly compared to writing a macro. you can get most of the behaviour that you displayed. hope this helps
(clojure.template/do-template
[name val]
(def name val) a 1 b 2 c 3)
this will give you vars a b c
with vals 1 2 3
For this I use cider-eval-region
, by default bound to <kbd>C-c C-v r</kbd>
Created a small macro for this (bindings are like let instead of two vectors):
(defmacro deflet
[bindings]
(let [defs (->> (partition-all 2 bindings)
(map (fn [[s v]] (list 'def s v))))]
`(do ~@defs)))
(macroexpand-1 '(deflet [a 1 b 2 c 3]))
=> (do (def a 1) (def b 2) (def c 3))
PS: I didn’t know about clojure.template, thanks for pointing it out !