Skip to content

Instantly share code, notes, and snippets.

View whamtet's full-sized avatar

Matthew Molloy whamtet

View GitHub Profile
(defn- mk* [m [a b & rest]]
(cond
(keyword? a) (recur (assoc m a b) rest)
a (recur (assoc m (keyword a) (symbol a)) (list* b rest))
:else m))
(defmacro mk [& syms]
(mk* {} syms))
/media/mmcblk0p1/apks
http://repo.jing.rocks/alpine/v3.20/main
http://repo.jing.rocks/alpine/v3.20/community
# mount -o remount,rw /media/mmcblk0p1
(def hidden-matcher #"(#)?([^\.]+)\.?(.+)?")
(defmacro hiddens [& args]
`(list
~@(for [[k-str v] (partition 2 args)]
(let [[_ id? k class] (re-find hidden-matcher k-str)]
[:input (cond-> {:type "hidden" :name k}
id? (assoc :id k)
class (assoc :class class)
(not= nil v) (assoc :value v))]))))
(defn sh
[dir & args]
(let [proc (.exec (Runtime/getRuntime)
^"[Ljava.lang.String;" (into-array args)
(make-array String 0)
(io/as-file dir))]
(with-open [stdout (.getInputStream proc)
stderr (.getErrorStream proc)]
(future (io/copy stdout *out*))
(future (io/copy stderr *err*))
(defn modal-scroll [width & contents]
[:div#modal {:class "fixed left-0 top-0 w-full h-full
z-10"
:style {:background-color "rgba(0,0,0,0.4)"}
:_ "on click if target.id === 'modal' add .hidden"}
[:div {:class (str "mx-auto border rounded-lg bg-white overflow-y-auto overflow-x-clip " width)
:style {:max-height "94vh"
:margin-top "3vh"
:margin-bottom "3vh"}}
contents]])
(def cors-headers
{"Access-Control-Allow-Origin" "*"
"Access-Control-Allow-Methods" "POST, GET, OPTIONS, DELETE"
"Access-Control-Allow-Headers" "*"
"Access-Control-Expose-Headers" "*"})
(defn wrap-cors [handler]
(fn [req]
(if (-> req :request-method (= :options))
{:status 200
(defmacro format-js [s]
`(-> ~s
~@(for [[to-replace replacement] (re-seq #"\{([^\}]+)}" s)]
`(string/replace-first ~to-replace ~(read-string replacement)))))
(ns scripts.simplify-svg
(:require
[clojure.string :as string])
(:import
java.text.DecimalFormat))
(defn- map-rest [f [x & rest]]
(conj
(map f rest)
x))
(ns email-edit.core
(:import
java.util.Base64))
(def encoder (Base64/getMimeEncoder))
(def decoder (Base64/getMimeDecoder))
(defn decode [^String s]
(String. (.decode decoder s)))
(defn encode [^String s]
#!/usr/bin/env bb -i
;; Usage:
;; Install babashka at https://github.com/babashka/babashka
;; put this script on PATH and make it executable
;; copy logs to the clipboard
;; to filter SimpleAsyncTaskExecutor-3 run
;; pbpaste | slct.clj 3
(require '[clojure.string :as string])