This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-02
Channels
- # announcements (9)
- # babashka (67)
- # beginners (62)
- # bitcoin (2)
- # clara (1)
- # clj-kondo (62)
- # cljfx (6)
- # cljs-dev (25)
- # clojars (17)
- # clojure (142)
- # clojure-australia (2)
- # clojure-europe (42)
- # clojure-gamedev (2)
- # clojure-nl (31)
- # clojure-poland (10)
- # clojure-spec (14)
- # clojure-uk (30)
- # clojurescript (3)
- # conjure (1)
- # cursive (10)
- # data-science (1)
- # datascript (4)
- # datomic (9)
- # depstar (7)
- # fulcro (17)
- # girouette (15)
- # graalvm (44)
- # honeysql (20)
- # jackdaw (3)
- # jobs (8)
- # jobs-discuss (10)
- # juxt (5)
- # lein-figwheel (1)
- # lsp (175)
- # malli (19)
- # pedestal (2)
- # reagent (31)
- # reitit (2)
- # remote-jobs (3)
- # reveal (12)
- # sci (77)
- # shadow-cljs (22)
- # specter (6)
- # startup-in-a-month (2)
- # tools-deps (1)
- # xtdb (21)
From the quick start from bootleg: https://github.com/retrogradeorbit/bootleg/blob/master/examples/quickstart/example-combine.clj
(mustache "quickstart.html"
(assoc (yaml "fields.yml")
:body (markdown "simple.md" :html)))
Crispin, bootleg author, provided me with an answer:
(require '[babashka.pods :as pods])
(pods/load-pod 'retrogradeorbit/bootleg "0.1.9")
(require '[pod.retrogradeorbit.bootleg.markdown :as md])
(def md-text
"# Hello
- This is a list
- Another item"
)
(md/markdown md-text :data :html)
Wasn't there an example of serving static content from bb, possibly via http kit server?
@holyjak I have an image viewer example here: https://github.com/babashka/babashka/blob/master/examples/image_viewer.clj
any special reason for not using hiccup on the html generation?
@i.slack There are some tricks using exec
#!/bin/sh
#_(
"exec" "bb" "$0" hello "$@"
)
(prn *command-line-args*)
./script.clj 1 2 3
("hello" "1" "2" "3")
thanks I will keep it as bash function for this one then:
function truncate-lines {
bb --stream -io "(subs *input* 0 (min ${1:-$COLUMNS} (count *input*)))"
}
Another one I use all the time:
function squeeze-lines {
bb --stream -io "(let [c #{\space \tab \-}] (->> *input* (partition-by c) (map (fn [[f :as r]] (if (c f)
(str f) (apply str r)))) (apply str)))"
}
of cause if you do not stuck on windows you can just do $ colrm for first one and $ tr -s ' -' for second 🙂
just a suggestion that instead of bash fns you can write a script and put it on your path
you will probably need (line-seq (io/reader *in*))
or (str/split-lines (slurp *in*))
is there a preferred babashka-compatible library for colorizing output in the terminal? https://github.com/ams-clj/clansi fails to load because of ref
, https://github.com/trhura/clojure-term-colors seems to work
how would you (like to) refer to the other colors? i've never found the 88/256 number schemes to be very intuitive so i'm curious how you think about them (or how you use them in another context)
I have a wonderful vim plugin that lets me highlight words in a variety of colors, and that helps me track multiple identifiers at once.
I was considering writing a babashka script that would do the same thing when looking at a log file
oh cool, I found a listing of them with names and the 256-code number: http://jonasjacek.github.io/colors/
yeah, i do that with vim sometimes. i also wrote a script to colorize multiple terms in perl many years ago. i also wrote an ansi parser in perl. but i haven't thought about that in years
https://github.com/inkarkat/vim-mark is the plugin that I use
off topic but have you seen bat
? It syntax highlights things to terminal
although that lib is so old when atoms probably were not the defacto mutability solution /cc @skuro (clansi: developed at the Amsterdam Clojure meetup it seems)
btw, my bb + lambda experiment is on hold - Lambda doesn't support pulling images from linked accounts 😢
@U0JEFEZH6 Did you check lambda layers? I was experimenting with Sci and nodejs for lambda before and I think layers are shareable cross account
Layers support resource-based policies for granting layer usage permissions to specific AWS accounts, AWS Organizations, or all accounts.
https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.htmlTo clarify - this is not specific to GraalVM, as this is a limitation of Lambda+Docker in general
@U04V15CAJ if they're talking about container images, that will be supported in the future, but obviously I can't say exactly when
In AWS you can setup permissions for one account to pull/push images from another, this is useful if you're using a multi-account setup (we have an account per environment, for example). This way you can push images to one account, and all others can pull them, without duplicating storage. It's all still protected via IAM of course
Currently for Lambda to pull an image, the ECR image repository has to be in the same account
@wilkerlucio OK, I think we can add them here: https://github.com/babashka/babashka/blob/f335716d1d24e2d2bf9c345ff773d985ad8f2a35/src/babashka/impl/reify.clj#L42 Please also add an accompanying test in babashka.main-test somewhere at the bottom
one consideration here, so far I see Babashka mimics the JVM API/protocols, but the protocols from CLJS are better (due to CLJS coming later, the protocols there are better broken down, I remember David Nolen talking about would be great if Clojure used those, but were too late for Clojure, for compatibility)
so I wonder if a better idea would be to mimic CLJS protocols instead, but I have no idea how that impacts the Babashka dev on itself
Associate and Counted should also be added here: https://github.com/babashka/babashka/blob/f335716d1d24e2d2bf9c345ff773d985ad8f2a35/src/babashka/impl/classes.clj#L252