This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-26
Channels
- # announcements (2)
- # babashka (55)
- # beginners (107)
- # calva (65)
- # cider (5)
- # clara (4)
- # clj-kondo (17)
- # cljs-dev (38)
- # cljsrn (16)
- # clojure (117)
- # clojure-australia (8)
- # clojure-europe (13)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-provo (2)
- # clojure-sweden (9)
- # clojure-taiwan (1)
- # clojure-uk (41)
- # clojurescript (40)
- # code-reviews (1)
- # conjure (40)
- # cursive (4)
- # datomic (11)
- # events (2)
- # fulcro (33)
- # graalvm (1)
- # jobs (2)
- # jobs-discuss (19)
- # lsp (18)
- # off-topic (58)
- # polylith (2)
- # quil (2)
- # react (28)
- # reagent (35)
- # reitit (3)
- # remote-jobs (1)
- # ring (9)
- # sci (76)
- # shadow-cljs (19)
- # sql (10)
- # testing (5)
- # vim (13)
- # xtdb (5)
I moved to selmer instead for templating...it's amazingly quick with bb! 40 files in 150ms https://github.com/typedclojure/typedclojure/blob/fd7e00a134425e0ee6b13adbc418c0991dd97608/dev/src/typed/dev/selmer.clj#L77-L117 Totally changed my workflow, thanks @borkdude!
(slurp "/path/to/file" :encoding "ISO-8859-1")
what are you trying with?
Yeah can confirm bb raises the java.io.UnsupportedEncodingException with both cp1250 and Windows-1250 @borkdude any ideas?
Seems we need to add -H:+AddAllCharsets
, https://github.com/oracle/graal/issues/1370
@U0BBFDED7 please have a look at the PR above, let us know of your use case, we can consider adding it 🙂
Not sure if I mentioned it here already, but: Maybe you need just a little bit of CLJS in your babashka httpkit app and you don't want to set up a whole new CLJS project for it. Performance and bundle size may not be that important. Then scittle may be suited for you: https://borkdude.github.io/scittle/
It's basically this list: https://github.com/babashka/babashka/releases/download/v0.4.3/babashka-0.4.3-reflection.json which is published at every release
Can that be obtained at runtime, or is that hardcoded somehow? I assume that classes are added to that from time to time?
The churn in classes isn't that high though, so it would probably be ok if you updated this every so often
Having looked at it, it looks like all the namespaces available to the bb runtime are available immediately, i.e. I can see them being returned by all-ns
. Is that correct?
Great. I’m trying to figure out how to best support bb in Cursive, and the problem is the built-in libs. But if I can introspect those that will probably work well.
Users will still have to mark specific files as being bb rather than normal Clojure in some way, but I think that’s ok.
yeah. babashka does have a bb.edn
now which is similar to deps.edn
but this isn't mandatory, so it's still useful to have an option to flag a file as "bb"
for Clojure-LSP we have a similar problem: https://github.com/babashka/babashka/issues/733#issue-811939787
so there currently we have a script to obtain the latest deps in babashka and lsp does analysis on those deps
Ok so there you’re actually getting the deps.edn from github for the built-in deps, correct?
correct. not sure how well it works, it hasn't seen a lot of usage yet I think, but that's the idea
Unfortunately https://raw.githubusercontent.com/babashka/babashka/blob/v0.4.3/deps.edn doesn’t work.
This does work :) https://raw.githubusercontent.com/babashka/babashka/v0.4.3/deps.edn
I suggested to ericdallo that bb could spit out a deps.edn-like structure with its built-in deps and also the deps and paths from bb.edn combined. Maybe that would help too, but he would rather see a complete classpath with all deps downloaded, which is basically what that script does. Feel free to post in that issue as well, if you have some new insights.
typically yes. but it's relatively new and not mandatory for say, single one-off scripts
Is there an xpath like thing for babashka? I'm trying to read the version of a pom file... I want to say something like short and sweet like
(xpath "...pom.xml" "/version[0]" )
but instead, I'm doing
(def pom-file ".../pom.xml")
(def pom (xml/parse (io/input-stream pom-file)))
(def element-type (class pom)) ;; instanceof didnt like class literal
(def children-of-toplevel-pom (filter #(instance? element-type %) (:content pom)))
(def version-element (first (filter #(= "version" (name (:tag %))) children-of-toplevel-pom)))
(def current-version (first (:content version-element)))
Maybe this example helps? https://github.com/babashka/babashka/blob/master/examples/pom_version_get.clj
I think zippers could also help: https://ravi.pckl.me/short/functional-xml-editing-using-zippers-in-clojure/
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {org.clojure/data.zip {:mvn/version "RELEASE"}}})
(require '[clojure.data.zip.xml :as xmlz]
'[clojure.data.xml :as xml]
'[clojure.zip :as zip])
(def xml "<pom><version>1.0.0</version></pom>")
(-> xml
xml/parse-str
zip/xml-zip
(xmlz/xml1-> :pom :version zip/down zip/node))
;; => 1.0.0
I think I had this problem before and solved it in like 5 lines of specter. Haven't tried it with babashka, though.
https://www.reddit.com/r/Clojure/comments/6tod7e/xmlin_your_friendly_xml_navigator/ See the first comment here (not mine)
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {org.clojure/data.zip {:mvn/version "RELEASE"}}})
(require '[clojure.data.zip.xml :as xmlz]
'[clojure.data.xml :as xml]
'[clojure.zip :as zip])
(def xml "<pom><version>1.0.0</version></pom>")
(-> xml
xml/parse-str
zip/xml-zip
(xmlz/xml1-> :pom :version zip/down zip/node))
;; => 1.0.0