Fork me on GitHub
#babashka
<
2022-11-15
>
zach08:11:24

Hi! Would y’all know if there’s any libraries for parsing .ics/caldav files that are compatible with babashka? I would like to slurp a public calendar and get a list of events to map over.

borkdude08:11:28

If you can't find any for clojure/bb, you could also try https://www.npmjs.com/package/node-ical with #nbb

zach09:11:53

oh awesome, and thank you for the quick reply! The closest I found so far is the java library caldav4j (https://github.com/caldav4j/caldav4j) Am going to see if it’s possible to include it using a bb.edn

lispyclouds09:11:52

looks like its in java, so wouldnt run in bb without rebuilding bb locally

zach09:11:39

ah, good to know! thank you.

borkdude16:11:22

Infix math in bb:

(babashka.deps/add-deps '{:deps {rm-hull/infix {:mvn/version "0.4.0"}}})

(require
 '[infix.core :refer [base-env]]
 '[jasentaa.parser :as p :refer [parse-all]]
 '[infix.grammar :refer [expression]])

((parse-all expression "1 + 2 * 3") base-env) ;;=> 7

👍 2
parrot 1
kipz22:11:21

I'm hoping to listen on a unix domain socket from bb - anyone got any experience with this?

kipz22:11:50

That's reading, right? I want to listen/create the socket....

borkdude22:11:16

You can create a TCP listener, but not sure about domain sockets. This requires a certain Java version

kipz22:11:35

Yeah, Java 16 I think.

borkdude22:11:16

This might be a good reason to upgrade bb to JDK 17 (since JDK 11 will be deprecated in GraalVM 23 as well)

👀 1
1
borkdude22:11:27

so after that it will become possible to do this. Issue welcome

clojure-spin 1
borkdude22:11:46

We still have to add that specific class, so if you want to make an example in the issue that would be helpful

kipz22:11:01

oh, cool. Didn't realise that re: GraalVM23 and JDK 11. You're after an example of how I might want to create/listen on a unix socket from bb land?

borkdude22:11:07

yes, just a regular clojure example that works in jdk16

👌 1
nivekuil20:03:08

the relevant classes still need to be added to babashka here right? will make an issue

kipz20:03:15

We will have support for this in http-kit in the next release - so this should get a bit easier 🙂

borkdude21:03:05

@U797MAJ8M please make an issue about the relevant classes, we're now on JDK19

bananadance 2
borkdude21:03:28

I see you made an issue. Can you please provide an example expression that we can use as a test?

borkdude21:03:31

In the issue

nivekuil21:03:45

oh that's great. @U04V15CAJ I can write a test but do you want to use the new http-kit feature as the test instead? would be more comprehensive https://github.com/http-kit/http-kit#unix-domain-sockets-udss

borkdude21:03:17

Just the interop part

borkdude21:03:09

I mean it would be good to make some isolated examples for that

hairfire22:11:44

In the following code, can anyone explain the difference in output?

(def s "a")
(def r "\"12 \\\"Hello\\\" 34\"")

(defn replace-match [s match r]
  (clojure.string/replace s match r))

(println "good:" (replace-match s s r)) => good: "12 \"Hello\" 34"
(println "bad :" (replace-match s (re-pattern s) r)) => bad : "12 "Hello" 34"

Bob B23:11:31

the docs for clojure.string/replace say

The replacement is literal (i.e. none of its characters are treated
specially) for all cases above except pattern / string.
... and then goes into more detail about being able to use $n for capture groups and so on. the 'good' case is string/string, and the 'bad' case is pattern/string, which is treated differently as described above

hairfire16:11:43

Thank you for the feedback! Sorry to have wasted your time because I didn't read the docs more carefully. It mentions using the function re-quote-replacement to eliminate the problem I encountered.

nivekuil20:03:08

the relevant classes still need to be added to babashka here right? will make an issue