Fork me on GitHub
#babashka
<
2022-01-26
>
crinklywrappr02:01:33

Can somebody offer some suggestions for how to easily host a babashka/scittle server?

borkdude08:01:08

Good question. I guess you could always use a VPS on DigitalOcean and what not. Alternatively you could use Amazon or Google and make a lambda. Another alternative: shared hosting on Bluehost or similar, but then I think you'd have to set up your site with CGI. You can read about bb + CGI here: • https://eccentric-j.com/blog/clojure-like-its-php.htmlhttps://blog.michielborkent.nl/using-babashka-with-php.html

👍 1
borkdude11:01:19

I recently also saw this: https://fly.io/ Might be worth looking into

👍 1
dabrazhe10:01:07

I thought bb supported clojure.tools but getting an error

(require '[clojure.tools.namespace.repl :refer [refresh]]) ; java.lang.Exception: Could not find namespace: clojure.tools.namespace.repl.

1
borkdude11:01:38

It's not a built-in dep but there is a fork which works well with babashka. https://github.com/babashka/tools.namespace You probably need to upgrade babashka for it to work, not sure.

1
dabrazhe10:01:05

babashka v0.6.4

heyarne12:01:47

Is it expected that one cannot import java.text.SimpleDateFormat ? If yes, why is that? I'm on babashka 0.7.3

borkdude12:01:30

@arne-clojurians in babashka we include only java.time

heyarne12:01:50

Hmmm I see

1
borkdude12:01:13

Are you bumping into a problem with a library?

heyarne12:01:10

No, with a script I'm writing myself. I'm trying to parse a german date ("22.12.2022") into an Instant so I can exchange it via EDN

heyarne12:01:26

I.e. pipe it from one babashka script into another

borkdude12:01:30

ok, use the java.time API for this

heyarne12:01:30

java.time.format.FormatStyle can not be resolved either?

borkdude12:01:04

$ bb -e '(java.time.LocalDate/parse "2022.01.26", (java.time.format.DateTimeFormatter/ofPattern "yyyy.MM.dd"))'
#object[java.time.LocalDate 0x187bb91e "2022-01-26"]

borkdude12:01:57

Don't know what FormatStyle is, never used it, but we could add it ;)

heyarne12:01:20

It allows for some pre-defined formatters

heyarne12:01:36

But your snippet will do just fine 🙂 Thanks a lot! 🙏

👍 1
heyarne13:01:57

Ok, what I tried to do didn't quite work. I tried to pass output between two babashka scripts, with the first one using bb -O . Some of the values I'm trying to pass are dates, so I thought I could leverage the #inst tag for that. However, when parsing the dates as Instants, they get serialized like this: #object[java.time.Instant 0x782f8391 "2022-01-02T23:00:00Z"] Is there any way to make it use the #inst tag?

borkdude13:01:22

There are several options. Serialize using a different tag and then use that tag when reading EDN. Or convert the date into java.util.Date or so

borkdude13:01:44

I found some information on this here: https://nextjournal.com/schmudde/java-time

borkdude13:01:30

This seems to work:

$ bb -e '(-> (java.time.LocalDate/parse "2022-01-26", java.time.format.DateTimeFormatter/ISO_LOCAL_DATE) (.atStartOfDay (java.time.ZoneId/of "EST5EDT")) (.toInstant) (java.util.Date/from) )' | bb -e '*input*'
#inst "2022-01-26T05:00:00.000-00:00"

👍 1
heyarne13:01:30

Thank you, that's great 🙂

lilactown19:01:20

I'm thinking of making a CLI tool. I could build it in clojure and compile it using graalvm. another thought I had was writing it in babashka. the end goal is to have a tool that someone can do brew install lilactown/brew/thing. is that something that babashka supports?

borkdude19:01:00

@lilactown Absolutely! Take a look at https://github.com/babashka/neil - it's a babashka script that can be installed using brew and scoop (Windows) and even nix

lilactown19:01:05

the tool itself is simple: read in some JSON/EDN from stdin, do some operations, print it

lilactown19:01:12

ah nice, an example. ty!

borkdude19:01:41

The brew formula itself is hosted here: https://github.com/babashka/homebrew-brew

emccue20:01:09

jq but for edn?

borkdude20:01:32

https://github.com/borkdude/jet <- there's also this one

🙌 2
❤️ 1