Fork me on GitHub
#babashka
<
2022-02-18
>
borkdude10:02:45

pod-babashka-go-sqlite3 0.1.0 is out: https://github.com/babashka/pod-babashka-go-sqlite3 it's been a year since the previous release. use sqlite3 directly from babashka without installing sqlite, the pod is self-contained and written in ... golang!

borkdude15:02:39

A PR to make cli-matic compatible with babashka: https://github.com/l3nz/cli-matic/pull/145

2
jaide15:02:16

Was hacking on building an immutable journal with some automation against the Notion API. The last part I needed was the ability to have an embeddable button trigger a GitHub action. I was hoping a vanilla HTML form would be enough but after testing it clearly needed the auth token and json data. That's when babashka running as a cgi script was a really good fit! Just had to create a single clj script file to process the post data and used the curl wrapper to use the proper API and it worked!

babashka 2
borkdude15:02:55

That's awesome!

borkdude15:02:07

I've also explored an alternative CGI thing with bb recently, but then leveraging PHP which already ran on my VPS: https://blog.michielborkent.nl/using-babashka-with-php.html

borkdude15:02:30

Also I think such a thing could run on AWS Lambda or Google Cloud very well now too, maybe even more so with #nbb

jaide15:02:08

Ooh very nice! This might be even better given that it's easier to find php hosts than ones that let you change cgi handlers, I bet the debugging story is a bit better too. What does your passthru function look like? Lambda or Google cloud would work but I suspect would have a bit more upfront setup. In the cgi or php path we already had a suitable web server so the path of least resistance was to upload our scripts and we were good to go

borkdude15:02:00

Here's a reaction from someone who actually started rewriting his PHP website to Clojure with babashka as an in-between step. https://github.com/borkdude/blog/discussions/21

borkdude15:02:18

I'm by no means a PHP expert, quite the opposite, so I just hacked together until this worked. There might be better ways

borkdude15:02:17

Writing an nbb lambda is actually very little code. https://blog.michielborkent.nl/aws-lambda-nbb.html

jaide15:02:22

Ahhh I see! I just had to scroll to the right more to see the env vars passed to the bb script. At one point PHP was my go to but that was over a decade ago now that I think about it.

jaide15:02:03

I figured it's not much code but I meant the aws console account setup, payment info and the steps to get to that point

jaide15:02:03

Oh damn nbb might be the perfect solution for a project I had in mind. Keep trying to fix lumo’s build system to get that updated but this might be a lot better too

borkdude15:02:48

Welcome to join #nbb and ask anything ;)

eltonlaw19:02:58

Is sci accessible from bb? I’m writing a test util with clojure.test to conditionally print stdout on fail and I’ve been able to save the printlns running in the different deftests to a string writer but I noticed that the way the report works differently, it’s writing to sci/out https://github.com/babashka/babashka/blob/e64db1028cfcbdfccbda572444e942f2a77b2dd7/src/babashka/impl/clojure/test.clj#L278-L283 is there any way to get to this internal sci/out?

$ bb
Babashka v0.7.3 REPL.
...
=> (require '[sci.core :as sci])
java.lang.Exception: Could not find namespace: sci.core.
=> (require '[babashka.impl.clojure.test])
java.lang.Exception: Could not find namespace: babashka.impl.clojure.test.

borkdude19:02:07

sci/out is the same as *out* within bb, similar to JVM Clojure.

borkdude20:02:47

Thanks for the report.

borkdude20:02:04

Yeah, I see what the issue is. sci/out here should probably be *out* here: https://github.com/babashka/babashka/blob/e64db1028cfcbdfccbda572444e942f2a77b2dd7/src/babashka/impl/clojure/test.clj#L282 since in this macro body we are using normal clojure prn etc, which print to *out* .

borkdude20:02:51

I'll push a fix to a branch and you can download this version in #babashka-circleci-builds in 10 minutes or so

borkdude20:02:19

Hmm, too soon, it's a bit harder than I thought. I'll report back when this is fixed

borkdude20:02:23

@UBBCH4TSA I pushed to the branch fix-test-out - a new binary should appear within 10 minutes in #babashka-circleci-builds

borkdude20:02:35

I now get the same output with as with JVM Clojure for your test program

borkdude21:02:05

@UBBCH4TSA can you give that a go?

eltonlaw21:02:01

sweet thank you, it works 🙇

borkdude21:02:29

Thanks for you donation!

borkdude21:02:05

Merged to master including a test. When that build finishes you can install it with:

bash <(curl ) --version 0.7.6-SNAPSHOT --dir .
until the next release.