Skip to content

Instantly share code, notes, and snippets.

@wwiill
wwiill / csv.clj
Created November 13, 2020 12:11
babashka script to process csv
#!/usr/bin/env bb
;; cat test.csv | csv.clj '(fn [m] (get m "column1"))'
(defn lines->maps [lines]
(let [headers (first lines)
body (rest lines)]
(->> body
(map (partial zipmap headers)))))
@wwiill
wwiill / generative-testing.md
Last active October 15, 2020 01:43
Generative testing with test.check
@wwiill
wwiill / unless-error.cljc
Created October 6, 2020 11:04
Unless error macro
(defmacro unless-error->
"Unless expr is a map like {:error xxx}, threads it into the first form (via ->),
and unless that result is a map like {:error xxx}, through the next etc"
[expr & forms]
(let [g (gensym)
steps (map (fn [step] `(if (:error ~g) ~g (~step ~g)))
forms)]
`(let [~g ~expr
~@(interleave (repeat g) (butlast steps))]
~(if (empty? steps)
#!/bin/bash
ENCRYPTED_BIN_FILE=$1
aws kms decrypt --ciphertext-blob fileb://$ENCRYPTED_BIN_FILE --query Plaintext --output text | base64 --decode
#!/bin/bash
KEY_ID=$1
UNENCRYPTED=$2
aws kms encrypt --key-id $KEY_ID --plaintext "$UNENCRYPTED" --query CiphertextBlob --output text | base64 --decode
#!/bin/bash
KEY_ID=$1
UNENCRYPTED=$2
aws kms encrypt --key-id $KEY_ID --plaintext "$UNENCRYPTED" --query CiphertextBlob --output text
#!/bin/bash
BASE_DIR=`pwd`
for REPO in $(find . -type d -d 1 | sed -e s/[\.\/]//g)
do
echo "Pulling $BASE_DIR/$REPO ..."
cd "$BASE_DIR/$REPO"
if [ "`git status | grep modified | wc -l`" -eq "0" ] ; then git pull; else echo "Skipping (has modified files)"; fi
done