This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-01
Channels
- # announcements (14)
- # architecture (28)
- # aws (34)
- # babashka (18)
- # beginners (114)
- # biff (5)
- # calva (128)
- # clerk (155)
- # clj-kondo (60)
- # clojure (82)
- # clojure-dev (25)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (17)
- # clojure-spec (13)
- # clojure-uk (3)
- # community-development (4)
- # core-logic (4)
- # cursive (5)
- # datomic (21)
- # deps-new (13)
- # emacs (5)
- # funcool (5)
- # graphql (3)
- # hyperfiddle (1)
- # introduce-yourself (1)
- # jobs (2)
- # kaocha (1)
- # london-clojurians (1)
- # lsp (13)
- # malli (16)
- # off-topic (6)
- # other-languages (1)
- # pathom (18)
- # re-frame (23)
- # releases (1)
- # remote-jobs (2)
- # tools-build (1)
- # tools-deps (12)
- # vscode (1)
- # xtdb (27)
What's the difference between running bb
and bb repl
(in a Linux terminal)? The screen looks the same to me.
its the same: https://github.com/babashka/babashka/blob/master/src/babashka/main.clj#L212
bb has several subcommands; if no subcommands are provided, the subcommand implicitly used is repl
I'm using borkdude/jet
to convert json to edn, having too minor issues:
⢠--keywordize
turns json strings like: "@class"
to clj keywords like :@class
⢠commas, I don't need them, how do I remove 'em?
Right, right... I am having my first senior moment or something š I quite forgot, I asked you about commas long ago, you told me to use zprint instead if they bother me so much
@U0G75ARHC I think you can also write a tiny babashka script to rip out the commas from maps using rewrite-clj
it's alright, it ain't biggy. I'm basically using it to convert responses when poking into APIs from Emacs. I would run a query; it comes back with json; there's a hook fn, it grabs the content and feeds it into call-process-region
.
I love it. I can then quickly dissect the data, see the count, filter, map, etc. Damn, I wish more people knew how much better EDN is compared to json. It's more concise and much more readable; you can quickly align things, sort, group and filter.
I used to get annoyed when someone sends me a link to a json snippet "grrr.. why do I have to stare at this monstrosity?"... now, I'd just run my transform function (that uses jet), and immediately see what's up
Out of curiosity I tried stripping commas with rewrite-clj:
user=> (str (let [loc (z/of-string "{:a 1, :b 2}")] (loop [loc loc] (let [next (z/next* loc)] (if (z/end? loc) (z/root loc) (if (= :comma (z/tag loc)) (recur (z/remove* loc)) (recur next)))))))
"{:a 1 :b 2}"
cc @UE21H2HHD

Maaan, sometimes I'm scared to talk to you. You think faster in Clojure, than I can type in English.
Here's the script:
[email protected] ~/dev/babashka (master*) $ echo '{:a 1 :b 2}' | jet
{:a 1, :b 2}
[email protected] ~/dev/babashka (master*) $ echo '{:a 1 :b 2}' | jet | /tmp/strip_commas.bb
{:a 1 :b 2}
[email protected] ~/dev/babashka (master*) $ cat /tmp/strip_commas.bb
#!/usr/bin/env bb
(require '[rewrite-clj.zip :as z])
(-> (let [loc (z/of-string (slurp *in*))]
(loop [loc loc]
(let [next (z/next* loc)]
(if (z/end? loc) (z/root loc)
(if (= :comma (z/tag loc))
(recur (z/remove* loc))
(recur next))))))
str
(print))
(flush)
