Advent 2019 part 19, Advent of Random Hacks

This post is part of Advent of Parens 2019, my attempt to publish one blog post a day during the 24 days of the advent.

Something I’m pretty good at is coming up with random hacks. The thing where you’re like “hey how about we plug this thing into that thing” and everyone says “why would you do that that’s a terrible idea” and I’m like (mario voice) “let’s a go”.

And sometimes the result is not entirely useless. Like this little onelinerI came up with yesterday, using Babashka to “convert” a project.clj into a deps.edn.

cat project.clj | sed -e 's/#=//g' -e 's/~@//g' -e 's/~//g' | bb '(let [{:keys [dependencies source-paths resource-paths]} (apply hash-map (drop 3 *in*))] {:paths (into source-paths resource-paths) :deps (into {} (for [[d v] dependencies] [d {:mvn/version v}]))} ) ' | jet --pretty > deps.edn

You could do this properly, write a hundred lines or more to deal with profiles, aliases, etc, or you can cook this up in ten minutes, and do the rest by hand.

Reminds me of that time I wrote a chat server that fits in a tweet, (the old 140 character ones), on the bus on the way back from a conference. Code golf was a lot easier when I still did Ruby :D

Hi, my name is Arne (aka @plexus) and I consult companies and teams about application architecture, development process, tooling and testing. I collaborate with other talented people under the banner Gaiwan. If you like to have a chat about how we could help you with your project then please get in touch!

Comment on ClojureVerse