Fork me on GitHub
#babashka
<
2021-03-02
>
Burin00:03:26

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)))

borkdude07:03:59

But using the pod interface does that work as well?

borkdude09:03:13

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)

Jakub Holý (HolyJak)13:03:57

Wasn't there an example of serving static content from bb, possibly via http kit server?

wilkerlucio14:03:06

any special reason for not using hiccup on the html generation?

borkdude14:03:18

Hiccup wasn't part of babashka when I wrote that. Feel free to send a PR

Dig14:03:44

Is there a way to do #!/usr/bin/env --stream -io in the script or something equivalent?

borkdude14:03:30

@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")

Dig14:03:12

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*)))" }

Dig15:03:08

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)))"
}

Dig15:03:10

of cause if you do not stuck on windows you can just do $ colrm for first one and $ tr -s ' -' for second 🙂

borkdude15:03:27

This is some advanced i/o flag usage :)

borkdude15:03:07

You can probably write this as a single bb script though

borkdude15:03:16

without the i/o flags

Dig15:03:51

yes, but then it will not be one liner lol

borkdude15:03:02

squeeze-lines.clj - yeah, you're right, one-liners are fun ;)

Dig15:03:06

did you write squeeze-lines.clj? or is it just a tease?

borkdude15:03:26

just a suggestion that instead of bash fns you can write a script and put it on your path

borkdude15:03:45

you will probably need (line-seq (io/reader *in*)) or (str/split-lines (slurp *in*))

Dig15:03:21

cool that helps

nate18:03:56

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

nate18:03:45

I would be nice to be able to do more than the basic 8 colors

rwstauner20:03:39

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)

nate21:03:46

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.

nate21:03:08

I was considering writing a babashka script that would do the same thing when looking at a log file

nate21:03:28

but I need to be able to highlight with more than the base 8

nate21:03:32

I'll probably pick a good set from the 256 color palette and just give them names

nate21:03:27

I figured out how to print out the codes, it's just a series of characters

nate21:03:48

oh cool, I found a listing of them with names and the 256-code number: http://jonasjacek.github.io/colors/

rwstauner22:03:13

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

nate22:03:10

it's probably in my top 5 plugins from a usage POV

grazfather00:03:44

off topic but have you seen bat? It syntax highlights things to terminal

nate00:03:51

definitely, bat is the coolest

borkdude18:03:11

what was that one called again...

nate18:03:03

thank you!

borkdude19:03:11

Feel free to add the clojure-term-colors to the issue

borkdude19:03:22

And I guess we should add ref

nate19:03:11

sure, I'll add a comment

borkdude19:03:40

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)

nate19:03:38

yeah, it's a very old lib

lukasz19:03:00

btw, my bb + lambda experiment is on hold - Lambda doesn't support pulling images from linked accounts 😢

jeroenvandijk10:03:31

@U0JEFEZH6 Did you check lambda layers? I was experimenting with Sci and nodejs for lambda before and I think layers are shareable cross account

jeroenvandijk10:03:20

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.html

borkdude11:03:15

This is from the GraalVM slack, channel native-image

👍 6
lukasz17:03:15

To clarify - this is not specific to GraalVM, as this is a limitation of Lambda+Docker in general

borkdude17:03:32

Yeah, just wanted to bring it to his attention ;)

borkdude17:03:49

@U04V15CAJ if they're talking about container images, that will be supported in the future, but obviously I can't say exactly when

borkdude17:03:57

this was his reply

lukasz17:03:11

Yeah, there's a thread in AWS support forum, no more information beyond that

lukasz17:03:29

Knowing them and my luck - it will be fixed tomorrow 😉

lukasz19:03:15

and that's a blocker for us

borkdude19:03:48

ah, that's a bummer. what is a "linked account"? and the layer approach?

lukasz19:03:33

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

lukasz19:03:14

Currently for Lambda to pull an image, the ECR image repository has to be in the same account

borkdude19:03:26

@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

wilkerlucio19:03:26

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)

wilkerlucio19:03:47

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

borkdude19:03:48

Let's continue in babashka-sci-dev, I'll invite you there