Fork me on GitHub

I was looking into SCI code and found Why are other types extended if there is already an Object there with the same extension? Code below would work the same.

#?(:clj (extend-protocol types/Eval
          (eval [expr _ _]
          nil (eval [_ _ _] nil))
Or is there something I don't see?


Maybe a performance reason

Cora (she/her)20:08:20

is there a trivial way in babashka to read all *in* to bytes? (meaning read until eof)



$ echo 'yolo' | bb -e '(-> (.readAllBytes System/in) (String. "utf-8"))'

Cora (she/her)20:08:36

ahhhh System/in

Cora (she/her)20:08:23

ahhhh readAllBytes was added in java 9

Cora (she/her)20:08:25

that explains it

Cora (she/her)20:08:37

I was looking at java 8's docs

Cora (she/her)21:08:40

#!/usr/bin/env bb

(require '[ :as io])
(import '[ Inflater InflaterInputStream])

(with-open [input (InflaterInputStream. System/in (Inflater. true))]
  (io/copy input System/out))
for inflating as part of a pipeline in the shell. in this case I'm working with SAML SSO and the request data is string->bytes->deflate->base64encode->urlencode and this handles the inflate portion of reversing that

👍 1
Cora (she/her)22:08:48

is babashka/cli going to be included in babashka eventually?


it already is

Cora (she/her)22:08:27

I created this a while back

Cora (she/her)22:08:13

I imagine some kind of combination of babashka/cli with this sort of thing would be interesting. being able to install these as shell scripts on your path and execute something in a library

Cora (she/her)22:08:05

basically you can do cljx babashka/fs which ls and it will pull down the latest babashka/fs and run the which function with an argument of "ls"

Cora (she/her)22:08:34

I could see something like this being useful with, say, a database migration tool like ragtime, being able to run a function to create a new migration or to run existing migrations

Cora (she/her)22:08:54

perhaps even have something in the package that describes valid args and commands and such and this could extract that to generate output

Cora (she/her)22:08:31

it's similar to clojure tools, in a way