This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn wrap-async | |
([af on-success on-failure] | |
(wrap-async af identity on-success on-failure)) | |
([af before on-success on-failure] | |
(fn -wrap [-next] | |
(fn -async [ctx respond raise] | |
(let [ctx (before ctx)] | |
(letfn [(-on-success [result] (-next (on-success ctx result)) respond raise) | |
(-on-failure [?error] (raise (on-failure ctx ?error)))] | |
(af ctx -on-success -on-failure))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Use this to unpack and import an archive | |
ARCHIVE="$1" | |
USERNAME="$2" | |
PASS="$3" | |
HERE="$PWD" | |
NOW=$(date +'%s.%N') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn iterduction | |
[xf coll] | |
(.iterator ^Iterable (->Eduction xf coll))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ytdl | |
(:require | |
[babashka.fs :as fs] | |
[babashka.process :refer [process]] | |
[cheshire.core :as json] | |
[clojure.core.async :as async] | |
[clojure.edn :as edn] | |
[clojure.java.io :as io] | |
[clojure.tools.cli :refer [parse-opts]] | |
[clojure.string :as str])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; As originally seen and improved on https://gist.github.com/holyjak/578571a134ce90526e6907436e91014a | |
(import '[clojure.lang Box]) | |
(defmacro as | |
[tag sym] | |
(let [tag (if (class? tag) (.getName ^Class tag) (str tag))] | |
`(with-meta ~sym {:tag ~tag}))) | |
(definline box! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -x | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | |
GROUP=$(cat "${DIR}/GROUP") | |
PROJECT=$(cat "${DIR}/PROJECT") | |
SCM=$(cat "${DIR}/SCM") | |
ver=$("$DIR/current-version") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
USERNAME="$1" | |
PASS="$2" | |
for f in *.ovpn | |
do | |
name=`basename -s .ovpn $f`; | |
nmcli connection import type openvpn file $f | |
nmcli connection modify "${name}" +vpn.data connection-type=password-tls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn match | |
[m] | |
(reduce | |
(fn [f f'] | |
(fn [m] (and (f m) (f' m)))) | |
(map (fn [[k v]] #(= v (get % k))) m))) | |
(def bands | |
[{:genere :rock :name "Deep Purple"} | |
{:genere :metal :name "Iron Maiden"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; Based on https://stackoverflow.com/a/38842018/12373587 | |
(defn map-vals | |
[m f] | |
(persistent! | |
(reduce-kv | |
(fn [m k v] | |
(assoc! m k (f v))) | |
(transient {}) | |
m))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro defnormalizer | |
[name m] | |
{:pre (map? m)} | |
(let [arg 'rec | |
body | |
(reduce-kv | |
(fn [m k v] | |
((if (sequential? v) assoc-in assoc) | |
m | |
v |