Skip to main content

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.

Can't leave out variadic args in Java interop with Clojure

When calling interop functions into Java land with Clojure you have pass an empty array. While it's OK in Java/Groovy/... to:

RatpackPac4j.requireAuth(SAML2Client)

... you have to pass an empty array in Clojure:

(RatpackPac4j/requireAuth SAML2Client (into-array Authorizer []))

Split a sequence by function in Clojure

Split a collection on the sequence of elements, that match it.

(defn split-by
  ([f]
    (comp (partition-by f) (take-nth 2)))
  ([f coll]
    (sequence (split-by f) coll)))
; (split-by zero? [1 0 2 0 3]) => ([1] [2] [3])

Clojure REST-REPL

While tools like httpie give you a nice way to query web APIs, they only give you the means to query data easily and print the results nicely. Once you need to modify the results or need to drill down on them, you are on your own.

Therefor I wrote my own tool - REST REPL. It starts a Clojure REPL with some state handling (imagine cd from the shell), preloaded libraries, that make your live easier (clj-http, specter, clojure.data.xml, cheshire) and make it pretty print (with colors) the results using puget.

Since this is a (close to) regular Clojure REPL, you can handle the data as you are used too and you can place reoccurring code into functions.