babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2020-12-02T09:58:07.017Z

And the video is up as well now: https://youtu.be/pgNp4Lk3gf0

👍 9
2020-12-02T09:58:49.017100Z

you beat me by 1 millis on posting the video... Babashka is soo fast! 🙂

👍 1
😄 3
jumar 2020-12-02T16:08:02.019200Z

Should I expect this to return something useful?

$ bb

user=> (doc io/reader)
nil

jumar 2020-12-02T16:08:14.019300Z

(doc map) works fine

borkdude 2020-12-02T16:16:25.019500Z

you can report vars for which the docstring does not work, this needs fixing. sometimes the issue is that we didn't copy in the docstring of the corresponding clojure var

borkdude 2020-12-02T16:17:45.019700Z

Although in this case I would have expected it to work

borkdude 2020-12-02T16:18:07.019900Z

@jumar I think you are on an old version:

$ bb
Babashka v0.2.4 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (doc io/reader)
-------------------------
<http://clojure.java.io/reader|clojure.java.io/reader>

2020-12-02T16:53:52.023200Z

Is there "how to" documentation somewhere to build Babashka pods? I guess Docker it's best choice at first to avoir to install all Graalvm toolchain on local computer, am I right?

borkdude 2020-12-02T16:56:43.023900Z

@admin055 The pod implementation reference is here: https://github.com/babashka/babashka.pods And here is a list of examples: https://github.com/borkdude/babashka/blob/master/doc/projects.md#pods

2020-12-02T17:08:21.027200Z

Perfect, thx for links and your disponibility. And for Graalvm docker tool chain image, you confirm?

borkdude 2020-12-02T17:23:03.028300Z

I usually download GraalVM to a local dir and set GRAALVM_HOME

👍 1
borkdude 2020-12-02T17:56:37.029Z

@admin055 also see: https://github.com/lread/clj-graal-docs Note that you don't need to compile with GraalVM in order to test a pod. You can develop with the normal JVM

enforser 2020-12-02T19:54:54.030600Z

I’m interested in making a simple web server which accepts POST/GET requests similar to this node script: https://www.tutorialsteacher.com/nodejs/create-nodejs-web-server Is there any ring or compojure support being added to babashka? Most clojure examples I’ve seen use those.

borkdude 2020-12-02T19:56:15.032200Z

@trailcapital babashka currently comes with the http-kit server. but there is no routing library included. for the small sized web-apps people typically make with bb it's probably sufficient to look at the :method and :uri of the incoming request and act accordingly. You can see an image viewer web-app in the example folder of the babashka repo which demonstrates this.

enforser 2020-12-02T19:58:09.033300Z

ah awesome, I was looking through at http_server.clj in examples but this one looks much more straightforward. Thanks! Really been enjoying bb by the way - I work at a scala shop but use babashka for all of my own scripting 🙂

borkdude 2020-12-02T19:59:08.033800Z

awesome :) this is a small demo of echo-ing the request: ~

👍 1
borkdude 2020-12-02T20:03:56.034200Z

~

enforser 2020-12-02T20:04:57.034700Z

ah nice, thats great! thanks again

borkdude 2020-12-02T20:08:35.035700Z

This one is nicer and simpler, to inspect the request:

$ bb -e '(org.httpkit.server/run-server (fn [req] (clojure.pprint/pprint req) {:body "hello"}) {:port 3000}) (curl/post "<http://localhost:3000>") nil'
{:remote-addr "0:0:0:0:0:0:0:1",
 :headers
 {"accept" "*/*",
  "accept-encoding" "deflate, gzip",
  "host" "localhost:3000",
  "user-agent" "curl/7.54.0"},
 :async-channel
 #object[org.httpkit.server.AsyncChannel 0x2630dd1e "/0:0:0:0:0:0:0:1:3000&lt;-&gt;/0:0:0:0:0:0:0:1:52341"],
 :server-port 3000,
 :content-length 0,
 :websocket? false,
 :content-type nil,
 :character-encoding "utf8",
 :uri "/",
 :server-name "localhost",
 :query-string nil,
 :body nil,
 :scheme :http,
 :request-method :post}

💯 1
borkdude 2020-12-02T20:20:20.036800Z

@trailcapital Here is a small function that you could use to generate some HTML (if you wish to): https://github.com/borkdude/babashka/blob/9661d8e3372e766046f22a6587050537b8b6a16f/examples/notes.clj#L21 There will probably be a babashka.hiccup or .html namespace in the future, but not there yet.

nate 2020-12-02T20:38:16.037700Z

built-in hiccup would be cool. I think bootleg can be used as a pod for this in the meantime, yes?

borkdude 2020-12-02T20:39:42.038100Z

true! a nice example of that is Gaiwan's site: https://github.com/lambdaisland/gaiwan_co#tech-stack

enforser 2020-12-02T20:53:52.041Z

I’m doing something similar on my personal site - use clojure to dump a bunch of static files into a directory then serve them from gh-pages. Over the holidays I may have time to try and port the hiccup portions to babashka and switch over to that as my html/static file build tool https://matthewfors.com/decrypt-zcash.html

borkdude 2020-12-02T21:12:01.041400Z

I see you also have a bit of Rust in there. Are you using Rust much?

enforser 2020-12-02T21:14:58.041600Z

Not really, but I’d like to dig into it more. Only using it for that post since the library to perform some required cryptography is only available in rust + to play around with WASM

borkdude 2020-12-02T21:17:18.042200Z

I have this thing you can use with babashka. It's written in Rust: https://github.com/babashka/pod-babashka-filewatcher

tvaughan 2020-12-02T23:20:52.042900Z

https://gitlab.com/tvaughan/docker-native-image

tvaughan 2020-12-02T23:21:54.044Z

I then use this in a project to build its native image. For example, https://gitlab.com/tvaughan/kibit-runner/-/blob/master/native-image.mk