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)))
But using the pod interface does that work as well?
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?
Hiccup wasn't part of babashka when I wrote that. Feel free to send a PR
Is there a way to do #!/usr/bin/env --stream -io in the script or something equivalent?
@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*)))"
}
nifty :)
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 🙂
This is some advanced i/o flag usage :)
You can probably write this as a single bb script though
without the i/o flags
yes, but then it will not be one liner lol
squeeze-lines.clj
- yeah, you're right, one-liners are fun ;)
did you write squeeze-lines.clj? or is it just a tease?
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*))
cool that helps
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
I would be nice to be able to do more than the basic 8 colors
what was that one called again...
^ @nate
aha!
thank you!
Feel free to add the clojure-term-colors to the issue
And I guess we should add ref
sure, I'll add a comment
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)
yeah, it's a very old lib
btw, my bb + lambda experiment is on hold - Lambda doesn't support pulling images from linked accounts 😢
@lukaszkorecki 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.htmlThis is from the GraalVM slack, channel native-image
To clarify - this is not specific to GraalVM, as this is a limitation of Lambda+Docker in general
Yeah, just wanted to bring it to his attention ;)
@borkdude if they're talking about container images, that will be supported in the future, but obviously I can't say exactly when
this was his reply
Yeah, there's a thread in AWS support forum, no more information beyond that
Knowing them and my luck - it will be fixed tomorrow 😉
and that's a blocker for us
ah, that's a bummer. what is a "linked account"? and the layer approach?
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
Associate and Counted should also be added here: https://github.com/babashka/babashka/blob/f335716d1d24e2d2bf9c345ff773d985ad8f2a35/src/babashka/impl/classes.clj#L252
Let's continue in babashka-sci-dev, I'll invite you there
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
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
but I need to be able to highlight with more than the base 8
I'll probably pick a good set from the 256 color palette and just give them names
I figured out how to print out the codes, it's just a series of characters
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
it's probably in my top 5 plugins from a usage POV