Open Source Consultant, Software Developer and System Administrator

If you are interrested in hiring a consultant for the effective use of open source software on an enterprise grade, take a look around in the About section to see, what I have to offer.

Blog and snippets

Various snippets or code parts I found useful, so I keep them here for reference.

Search Maven artifacts with Babashka

Since Maven Central changed the search I had to fix my helper script. Time to try out Babashka.

#!/usr/bin/env bb
(defn artifact [{:keys [g a v latestVersion]}]
  (str g ":" a ":" (or v latestVersion)))

(defn query [q]
  (let [query-params {:start 0 :rows 50}]
    (if (str/includes? q ":")
      (let [[g a] (str/split q #":" 2)]
        (assoc query-params
               :q (str "g:" g " AND " "a:" a)
               :core "gav"))
      (assoc query-params :q q))))

(defn request [q]
  (-> (org.httpkit.client/get
        {:content-type "application/json"
         :query-params (query q)})
      (cheshire.core/parse-string true)

(assert (= 1 (count *command-line-args*)))

(let [[q] *command-line-args*]
  (->> (request q)
       (map artifact)
       (run! prn)))