Fork me on GitHub
#announcements
<
2023-12-21
>
roboli00:12:44

Hi all! I've been working on small library called "balloon". I did some integrations a while ago, for zapier and for flowxo. It happens that you need to flat objects often. Back then I created a python script for that, then I found a library for nodejs but I couldn't find anything for clojure (or maybe I didn't look hard enough? or maybe bc you can make this stuff yourself). I decided to give it a go, you know, for the learning experience and, what's more fun than staying a Friday night coding instead of hanging out with friends right? Anyway, today I released version "0.1.0" and you can find it here https://github.com/roboli/balloon And you can do stuff like this:

(b/deflate {:my-map {:one "one"
                    :two "two"
                    :any {:other "other"}}
            :my-array [{:a "a"} "b" "c"]})

;;=>
;; {:my-map.one "one",
;;  :my-map.two "two",
;;  :my-map.any.other "other",
;;  :my-array.0.a "a",
;;  :my-array.1 "b",
;;  :my-array.2 "c"}
And it also has a CLI. Hope you find it useful!

🎈 12
πŸ‘ 4
πŸŽ‰ 2
seancorfield00:12:30

Might be a nice enhancement to support a delimiter of "/" and handle qualified keywords:

user=> (b/inflate {:user/id 1 :user/name "Sean" :user/addressid 2 :address/id 2 :address/street "123 Main St"} :delimiter "/")
{:id 2, :name "Sean", :addressid 2, :street "123 Main St"}
I was hoping for {:user {:id ...} :address {:street ..}}

πŸ“ 1
Harold00:12:16

Cool idea and library, re-wrote this one function while I was reading... hth πŸ™‚

(defn- keys->deflated-key
  [delimiter]
  (fn [ks]
    (->> (for [k ks] (if (number? k) (str k) (name k)))
         (string/join delimiter)
         (keyword))))

πŸ‘€ 1
Harold00:12:39

> what's more fun than staying a Friday night coding instead of hanging out with friends balance πŸ™‡

1
dpsutton01:12:14

i was reading something like this for javascript recently. json notation has the benefit of exploding to valid json so you can turn sub parts of it back into json

emilaasa07:12:27

gron is great - works really well with grep / rg

onetom07:12:45

i was just about to mention gron too. when i tried to do something like gron, but for "edn", i was thinking of using vectors as keys, so i can do the inverse operation via something like (reduce (fn [m [k v]] (assoc-in m k v) {[:a] 1 [:a 0] 2 [:b] 3})

onetom08:12:27

eg, this works:

(->> [[:a] []
        [:a 0] 2
        [:b] 3
        [:c] {}
        [:c :d] 4]
       (partition-all 2)
       (reduce (partial apply assoc-in) nil))
=> {:a [2], :b 3, :c {:d 4}}
it assumes an ordered input, which explicitly expresses whether a nesting level is a map or vector, so that nesting level is ready to receive subsequent inputs. this way there is no magic needed during reconstruction.

roboli10:12:44

Interesting about gron, I didn't know it. It's just matter of doing some pretty print on lein-balloon output and should be ready for grep :thinking_face:

cjohansen08:12:20

Announcing the first official release of https://github.com/cjohansen/powerpack - a batteries included static website framework. It's based on the excellent https://github.com/magnars/stasis toolkit, and comes with: β€’ Lots of development convenience: live reload of content, CSS, and code, strong error handling, and more β€’ Streamlined data flow: put static content in markdown and EDN files, have them automatically ingested into an in-memory Datomic database, and build pages from that Datomic database. β€’ i18n tooling β€’ Image transformation (crop, resize, duotone, etc) β€’ Production ready exporting tools β€’ Asset optimization pipeline Even though this is the first official release, the product is very stable - it's based on five years of work with static web sites, and has been polished while building a 5000 page static web page over the past few months. There is a fairly extensive step by step guide in a separate repo: https://github.com/cjohansen/powerblog

πŸŽ‰ 24
nice 11
πŸ‘ 9
⭐ 1
tvaughan09:12:30

People might be interested in https://sumar.io. It’s written in Python but due to problems with its dependencies, namely its authentication library, a rewrite in Clojure is probable.

magnars09:12:40

That step by step walkthrough is πŸ˜™πŸ‘Œ excellent, @U9MKYDN4Q

πŸ™ 1
elken10:12:38

Sod's law this came out just as a redid my blog 😞 Time to re-migrate again! Curious why datomic over xt here; is the strict schema needed or is it just a preference thing?

cjohansen10:12:21

I love Datomic and its schemas, and I have zero experience with xt.

βœ… 1
magnars10:12:36

I also note that the datomic schemas are used to import structured data more easily when adding metadata to markdown files.

elken17:12:45

Okay this is really good work πŸ˜„ Gonna take me a little bit to grok the datomic bits, but this is really cool work πŸ™ Might be worth a #stasis πŸ™‚

❀️ 1
cjohansen18:12:27

Thanks! I'm happy to answer any questions.

georgy17:12:08

Awesome, just what I was looking for! special thanks for the walkthrough guide @U9MKYDN4Q

πŸ™ 1
borkdude20:12:04

Babashka https://github.com/babashka/fs: file system utility library for Clojure v0.5.20 (2023-12-21) β€’ https://github.com/babashka/fs/issues/119: fs/delete-tree: add :force flag to delete read-only directories/files. Set the flag to true in fs/with-temp-dir (https://github.com/jlesquembre) β€’ https://github.com/babashka/fs/issues/102: add gzip and gunzip functions β€’ https://github.com/babashka/fs/issues/113: fs/glob: enable :hidden (when not already set) when pattern starts with dot (https://github.com/eval). β€’ https://github.com/babashka/fs/issues/117: fix fs/match and fs/glob not finding files in root-folder (https://github.com/eval).

πŸŽ‰ 15