This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-29
Channels
- # announcements (1)
- # babashka (83)
- # beginners (67)
- # chlorine-clover (22)
- # cider (11)
- # circleci (6)
- # clj-kondo (12)
- # cljs-dev (137)
- # cljsrn (15)
- # clojure (124)
- # clojure-europe (40)
- # clojure-italy (1)
- # clojure-nl (3)
- # clojure-norway (1)
- # clojure-serbia (3)
- # clojure-spec (19)
- # clojure-uk (14)
- # clojuredesign-podcast (5)
- # clojurescript (80)
- # conjure (49)
- # core-async (62)
- # cursive (18)
- # datascript (1)
- # datomic (64)
- # docker (28)
- # emacs (20)
- # figwheel-main (249)
- # fulcro (95)
- # graalvm (2)
- # jobs-discuss (11)
- # joker (2)
- # juxt (4)
- # lambdaisland (9)
- # leiningen (1)
- # meander (14)
- # mount (6)
- # off-topic (16)
- # pathom (46)
- # re-frame (35)
- # reagent (6)
- # reitit (5)
- # shadow-cljs (28)
- # spacemacs (6)
- # sql (18)
- # tools-deps (26)
- # vim (8)
- # xtdb (23)
- # yada (1)
Nice! What’s your idea behind it? Command line webscraping?
Funny enough, the featured article on wikipedia, which is scraped in the example, mentions "pod" 😉 https://en.wikipedia.org/wiki/Main_Page
serendipity
Yesterday I came across Cucumber again. I was thinking what if this could work with Graalvm. Getting https://github.com/babashka/pod-babashka-etaoin to work would be an important part here
you can now use the filewatcher pod with bootleg, to re-compile your static website. and then use the etaoin pod to refresh a browser, to preview it.
babashka + bootleg with it’s new pod support are kind of blowing my mind, awesome stuff 👏 🚀
I fear singularity
We should stop it here
When running a script babashka establishes some namespace bindings, which is great. When turning a script into a namespace it is kind of tedious to recreate the same bindings. I’m wondering if there could be an easier way to do that like (default-bindings!)
or similar (that approach would unfortunately trip up clj-kondo I think)
These are only there in the user
namespace. Once you use your own ns
form, you lose them.
I suggest not to use the user aliases in a script: https://github.com/borkdude/babashka#explicit-requires
I see, that makes sense I guess. Guess I’ll have to write a babashka script that adds requires for the user aliases to a script file 😛
Mostly kidding but I guess that wouldn’t be too hard to do 😛
I think the last point in that link is the most pertinent:
> Writing compatible code gives you the option to run the same script with clojure
having bb be a lightweight replacement for lein run
is wonderful
Is there a way to access *input*
in a namespace’s -main
?
This var only exists in the user namespace, and again, is mostly there for one-liners. If you really need it, and can't use something like (edn/read *in*)
or something, then you can use user/*input*
.
Would you like a PR adding a one-line note about this here: https://github.com/borkdude/babashka#input-and-output-flags ?
Would this mean that -I
/`-i` and -m
are generally incompatible?
If so then a warning in this case might be better than adding to the docs?
but the suggestion is to use it for one-liners since it can be kind of tedious to read from stdin in them
Is load-pod
idempotent?
Interesting. Not that I’d need it but how would you dispatch stuff to a different pod?
The story around having multiple pod instances of the same executable isn't completely clear cut yet, but I wanted to leave this option open
yeah I can see how you wouldn’t want to commit to just one instance
Reusing the same pod across multiple namespaces is probably going to be a little difficult but stuff is fast so maybe it doesn’t even matter
btw are you using https://github.com/retrogradeorbit/bootleg/releases/tag/v0.1.9? it's faster than 0.1.8.
yes, I’m following the repo & releases, saw the conversation about delayed requires etc. good stuff!
(require '[babashka.pods :as pods])
(pods/load-pod "bootleg")
(ns mkl.frontmatter
(:require [clojure.string :as str]
[ :as io]
[clj-yaml.core :as yaml]
[pod.retrogradeorbit.bootleg.glob :as glob]))
is this the right way to use pods inside namespaces?if you do the load in the first required namespace, then the requires should just work in all the remaining ones
Right but I’m thinking that I might use the mains of these namespaces independently in which case that wouldn’t work
Made me wonder if maybe a --load-pod
type CLI option would be a good idea
true. but you could make a stateful function which checks if the pod was already loaded, right?
(let [loaded? (volatile! false)]
(defn load-pod []
(when-not @loaded?
(pods/load-pod ...)
(vreset! loaded? true)))))))))
Eventually that might make sense, but I'd rather wait a bit with adding more CLI args, to give it a bit more thought
makes sense… 🙂 I’m gonna play around with that approach a little bit
Aside: I had a typo (def -main []
which ran correctly but caused an NPE just before it would otherwise exit with 0. Not sure if this is something that is to be expected but thought it was interesting that it still worked fine at first sight but then caused an error
BABASHKA_PRELOADS="(pods/load ...)"
that’s neat!This is what I ended up with btw: https://github.com/martinklepsch/martinklepsch.org/commit/4401f73599348f77a157eb9b3264b649db7f9d7d
If you're going for a top level side effect, then I think even the volatile isn't needed, since the namespace is going to be loaded only once
I just deleted code from the snippet you gave me without thinking much hahaha
The cljc.java-time library is now compatible with babashka! https://github.com/henryw374/cljc.java-time/issues/10#issuecomment-636101690
Hopefully I haven’t missed something obvious: What’s the recommended way to use bb to set environment variables in the shell it’s running from?
I am writing a script to assume an AWS role, which involves trading a password and an MFA code for a session token. Then that session token is set as an environment variable in the shell while you do work with it.
Yes, unfortunately, although I think in my case I have a workaround with aws configure
. Thank you for your help!
It would be nice to be able to set variables like you can using source
in bash, although I’m not close to expert enough to understand how that would be done.
but you can't set environment variables for the shell which calls babashka. unless you spit out some file and source that later
Right, the latter seems like the workaround if you need to set up a separate environment
Oh awesome, thank you