Fork me on GitHub
#babashka
<
2022-07-15
>
pinkfrog03:07:37

For https://github.com/borkdude/deps.clj, if I use it in a normal clj (not bb) project. When I run clojure -Sdeps will it invoke a subprocess or running inside the current process? Also, why the package name is borkdude.deps and not babashka.deps?

pinkfrog03:07:27

Sounds like the lib is not meant to be used as a library, but instead as a standalone process.

borkdude06:07:53

This project is exactly what it says what it is: the clj bash script rewritten in Clojure. The bash script invokes a Java process to calculate the classpath. But it also caches the classpath, so the second time it won't.

borkdude06:07:14

It's “borkdude” because everything including babashka started under borkdude. Some repos were moved and some weren't.

borkdude06:07:05

This project started as a babashka script but later on it turned out to be useful within bb itself

Søren Sjørup08:07:45

To get scittle.nrepl to work with ClojureJVM I had to add nrepl/bencode {:mvn/version "1.1.0"} to my deps.edn . Am I doing something wrong?

borkdude09:07:49

I think you're correct. I only tested this by running the server in bb, which also works but there nrepl/bencode is included

borkdude11:07:48

💯 1
🎉 2
Darrick Wiebe16:07:31

Nice. Just 2 days ago I borrowed your blog back end to start my own. Much better this way than being on a fork! BTW, I just noticed that in the generated .xml files, you've hard coded your own name as author! 🙂

no.horse git:(master) grep -r Michiel
./public/planetclojure.xml:    <name>Michiel Borkent</name>
./public/atom.xml:    <name>Michiel Borkent</name>

👍 1
borkdude16:07:13

@U01D37REZHP We should make this configurable. PRs welcome!

👍 1
teodorlu12:07:07

Quick quickblog question. How are you injecting

watch-script "<script type=\"text/javascript\" src=\"\"></script>"
(https://github.com/borkdude/quickblog/blob/1f1346d77a319976dfe6fa6de0ff62f2f5805c8b/src/quickblog/api.clj#L235) into the rendered HTML? I'm loosing track of where watch-script is being used. Does the https://github.com/borkdude/quickblog/blob/1f1346d77a319976dfe6fa6de0ff62f2f5805c8b/src/quickblog/api.clj#L169 render differently depending on whether it's being used to produce live-reloading local output or final HTML render?

borkdude12:07:16

@U3X7174KS It's injected here during the function watch

teodorlu12:07:10

Aaaah, so the HTML template can optionally receive the watch script. Nice, thanks!

teodorlu14:07:05

Writing an EDN filter with bb is super easy:

echo '{:args [1 2]}' | bb '(assoc *input* :sum (reduce + (:args *input*)))'
{:args [1 2], :sum 3}
Is the best way to write a JSON filter with bb with jet?
echo '{"args": [1, 2]}' | jet --from json | bb '(assoc *input* :sum (reduce + (:args *input*)))' | jet --to json
{"args":[1,2],"sum":0}

teodorlu14:07:17

I was kind of curious if there was some kind of --json flag for babashka to use JSON for IO instead of EDN - https://book.babashka.org/#_input_and_output_flags

borkdude14:07:25

you could combine jet and bb for this :)

borkdude14:07:43

or just write a script and place it on your path

borkdude14:07:00

but jet can also execute functions

👀 1
borkdude14:07:16

$ echo '{"args": [1, 2]}' | jet --from json --keywordize --to json -T '(as-> $ (assoc $ :sum (reduce + (:args $))))'
{
  "args" : [ 1, 2 ],
  "sum" : 3
}

👀 1
teodorlu14:07:57

ohh, nice. Jet is executing functions with sci, I assume?

borkdude14:07:02

A cleaner solution:

$ echo '{"args": [1, 2]}' | jet -i json -o json -k -f '#(assoc % :sum (reduce + (:args %)))'
Yes, also SCI

👍 1
Jeffrey Bay16:07:15

babashka.fs/glob does not find files which are symlinks

Jeffrey Bay16:07:14

the symlink is a named file in the unix abstraction, it is weird to me that if the glob name filter matches, that glob wouldn't include the symlink path in its results, and leave the user to decide what to do with the link.

borkdude16:07:18

might be a bug, can you file a repro in the fs repo?

Jeffrey Bay16:07:20

I tried using :follow-links true as well, but from inspecting the source and the behavior, that is about following a link to continuing recursing below a linked directory

Jeffrey Bay16:07:06

hmm - i'm not sure how to repro

Jeffrey Bay16:07:32

it's clearly happening in my non-trivial case, but when i try to create a trivial case, it works fine

borkdude16:07:04

maybe when the symbolic link links to a dir outside of the dir?

Jeffrey Bay16:07:27

i tried that - that works too

borkdude16:07:54

you could try to check out the fs lib locally and add some logging to it, etc

Jeffrey Bay16:07:59

it's a deeper tree, but that's the only difference

Jeffrey Bay16:07:11

(that i can see)

Jeffrey Bay16:07:15

ls shows the file with the same pattern glob does - it isn't even a recursive pattern, it looks like this:

Jeffrey Bay16:07:29

ls */foo/bar/baz*.clj

Jeffrey Bay16:07:38

(linking config files instead of having them in situ, and the glob pattern isn't finding the ones that are linked. it's baffling given that the repro is working fine)

Jeffrey Bay17:07:13

well, instrumenting the fs library helped, thanks for the suggestion. it was actually one layer up, the conversion from a unixpath result to a http://clojure.java.io/file (through an extra call to .getCanonicalPath, natch) was replacing the path with the symlink target path. unexpected, but not babashka.fs's fault 😆 this is why you always ask for a repro

borkdude17:07:35

so, all good?

Jeffrey Bay19:07:45

thanks for the suggestions on debugging

teodorlu18:07:39

Want to transform Markdown, Org-mode, Asciitext, HTML or even EPUB wth Clojure? It turns out that Babashka and clojure.walk is an excellent choice for writing Pandoc filters. Here's a writeup: https://play.teod.eu/document-transform-pandoc-clojure/

🆒 5
borkdude19:07:18

Cool stuff :) Also post to #news-and-articles? I think we should also revive: https://github.com/babashka/babashka/blob/master/doc/news.md But surely you can already add it here too: https://github.com/babashka/babashka#articles-podcasts-and-videos

👍 1
borkdude19:07:40

You could simplify the bash wrapper by doing the JSON reading in bb itself, using cheshire

borkdude19:07:35

Added the links to those pages now

👍 1
borkdude19:07:16

I forgot to update the news.md page in the babashka repo, but I'm picking back up now. https://github.com/babashka/babashka/blob/master/doc/news.md If anyone wants to help backfill news items from previous months, check out the #babashka hashtag on Twitter: I usually share all new projects and tidbits there (among other noise I make about my own work in progress stuff, sorry) PRs welcome

borkdude19:07:53

Now backfilled January 2022: https://github.com/babashka/babashka/blob/master/doc/news.md#2022-01 Will post other months in thread to this message.

🔥 3
1