This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-24
Channels
- # adventofcode (1)
- # announcements (22)
- # babashka (30)
- # beginners (69)
- # calva (53)
- # cider (17)
- # cljfx (1)
- # clojure (2)
- # clojure-australia (1)
- # clojure-europe (1)
- # clojurescript (36)
- # code-reviews (10)
- # conjure (3)
- # cursive (2)
- # datomic (4)
- # fulcro (13)
- # graalvm (261)
- # luminus (2)
- # malli (1)
- # nrepl (13)
- # off-topic (19)
- # rdf (3)
- # reveal (1)
- # ring (3)
- # sci (66)
- # shadow-cljs (14)
- # spacemacs (1)
- # specmonstah (1)
- # test-check (1)
- # vim (2)
- # xtdb (14)
bah, I need to process some html (specifically to pull data out of a table.) I know there is a jsoup pod... but is there anything lighter weight?
Regex for the win... (def rows (drop 1 (clojure.string/split table-contents #"<tr class=\"\w+\">")))
#!/usr/bin/env bb
(require '[babashka.pods :as pods])
(pods/load-pod 'retrogradeorbit/bootleg "0.1.9")
(require '[pod.retrogradeorbit.bootleg.utils :as utils])
(-> "<html><p>Hello</p></html>"
(utils/convert-to :hiccup))
;; => [:html [:p "Hello"]]
Thanks, I now realize I need to do even more parsing... I have to pull data out of a simple form. Life is too short to parse HTML with regex and indexOf and subs() - I will try the pod.
I am going to include test.check as a preparation for including clojure.spec in babashka. https://github.com/babashka/babashka/pull/717 clojure.spec will be included when it's clear what happens to alpha and version 2, but I've already made a start with this as a feature flag, which is disabled by default.
Released babashka 0.2.8 with additional built-in libraries: - core.match (much requested) - clojure.test.check (prep for including spec once it comes out of alpha) - hiccup (who doesn't use it?) https://github.com/babashka/babashka/blob/master/CHANGELOG.md#v028
./test.clj
/home1/[redacted]/.babashka/pods/repository/org.babashka/postgresql/0.0.1/pod-babashka-postgresql: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home1/[redacted]/.babashka/pods/repository/org.babashka/postgresql/0.0.1/pod-babashka-postgresql)
Is there a way to get a static binary for this or should I try a different route?@jayzawrotny Are you running this in an alpine docker container?
There is even a library around shelling out to psql for bb: https://github.com/DarinDouglass/clj-psql
Great! I did see that library mentioned in the docs but was curious about alternatives. The psql bin does exist on this server so shelling out should be doable, but local compile then uploading might be more performant I’m guessing? Any docs on compiling it locally? Should I setup a docker container to match the host environment?
And there is another way: there is a feature flag in babashka itself which includes the postgres driver. So you could have a static babashka with postgres support and you could then upload this to your shared env.
@jayzawrotny yeah, so you could compile the pod statically, or you could compile babashka statically with pg support enabled
then you would have it built into bb, you can require next.jdbc directly without the pod
@jayzawrotny So here are the build docs: - static: https://github.com/babashka/babashka/blob/master/doc/build.md#static - postgres: https://github.com/babashka/babashka/blob/master/doc/build.md#postgresql