Skip to content

Instantly share code, notes, and snippets.

View whamtet's full-sized avatar

Matthew Molloy whamtet

View GitHub Profile
#!/usr/bin/env bb
(ns srt.core
(:require [clojure.string :as str])
(:import
[java.time LocalTime]
[java.time.format DateTimeFormatter]
[java.time.temporal ChronoUnit]))
(def fmt (DateTimeFormatter/ofPattern "HH:mm:ss,SSS"))
(defn- compare-possible-nums [a b]
(if (and a b (re-find #"^\d+$" a) (re-find #"^\d+$" b))
(- (Long/parseLong a) (Long/parseLong b))
(compare a b)))
(defn- compare-bits [[a & as] [b & bs]]
(let [c (compare-possible-nums a b)]
(if (and a (= 0 c))
(compare-bits as bs)
c)))
(defn- compare-names [a b]
;; in head
(when dev?
(list
[:script {:src "https://cdn.jsdelivr.net/npm/eruda"}]
[:script "eruda.init();
eruda.show();"]))
https://www.tednasmith.com/wp-content/uploads/2021/02/TN-Moria-Gate-2021.jpg
https://www.tednasmith.com/wp-content/uploads/2020/12/TN-The-Fellowship-Approaches-Moria.jpg
https://www.tednasmith.com/wp-content/uploads/2018/08/TN-Durins_Crown_and_the_Mirrormere.jpg
https://www.tednasmith.com/wp-content/uploads/2018/08/TN-Gwaihir_the_Windlord_Bears_Gandalf_From_Isengard.jpg
https://www.tednasmith.com/wp-content/uploads/2018/05/TN-Arrival_at_Caras_Galadhon.jpg
http://tednasmith.poverellomedia.com/wp-content/uploads/2012/07/TN-Leaving_the_Shire.jpg
http://tednasmith.poverellomedia.com/wp-content/uploads/2012/07/TN-Under_the_Spell_of_the_Barrow-wight.jpg
http://tednasmith.poverellomedia.com/wp-content/uploads/2012/07/TN-The_Balrog.jpg
http://tednasmith.poverellomedia.com/wp-content/uploads/2012/07/TN-Green_Hill_Country.jpg
http://tednasmith.poverellomedia.com/wp-content/uploads/2012/07/TN-Rivendell.jpg
sqlite3 mydata.db < script.sql
[:title (i18n "Crystal Dashboard")]
[:meta {:property "og:title" :content "Crystal Dashboard"}]
[:meta {:property "og:type" :content "website"}]
[:meta {:property "og:url" :content "https://app.crystal2025.store/"}]
[:meta {:property "og:image" :content "https://app.crystal2025.store/logo.png"}]
(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://ftp.udx.icscoe.jp/Linux/alpine/v3.21/main
http://ftp.udx.icscoe.jp/Linux/alpine/v3.21/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*))