Skip to content

Instantly share code, notes, and snippets.

View johnbendi's full-sized avatar

John Chijioke johnbendi

View GitHub Profile
@johnbendi
johnbendi / recover-lost-agent.py
Created October 10, 2022 04:51 — forked from niedbalski/recover-lost-agent.py
recover a lost Juju agent
#!/usr/bin/env python
"""
This is a tool for recovering a lost juju unit
Usage:
{0} controller-ip unit-from unit-to basedir
"""
import subprocess
import shlex
(defmacro when-let*
"simply implementation:
(if-let [[sym expr & more-bindings] (seq bindings)]
`(when-let [~sym ~expr]
(when-let* ~more-bindings ~@body))
`(do ~@body))
the form:
(when-let* [a 3 b 4] (+ a b))
@johnbendi
johnbendi / thread.clj
Created October 15, 2012 16:44 — forked from richhickey/thread.clj
new thread macros draft
(defmacro test->
"Takes an expression and a set of test/form pairs. Threads expr (via ->)
through each form for which the corresponding test is true."
[expr
& clauses]
(assert (even? (count clauses)))
(let [g (gensym)
pstep (fn [[test step]] `(if ~test (-> ~g ~step) ~g))]
`(let [~g ~expr
~@(interleave (repeat g) (map pstep (partition 2 clauses)))]