Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Molloy whamtet

  • Bangkok
View GitHub Profile
View v8.args.gn
is_debug = false # To get a release build
target_cpu = "arm64"
v8_target_cpu = "arm64"
is_clang = false # To build with GCC instead of clan
treat_warnings_as_errors = false
is_component_build=true
use_custom_libcxx=false
View profiles.clj
;; deploy to clojars
{:auth {:repository-auth {#"clojars" {:username "whamtet" :password "app-pw"}}}
;; then go lein deploy clojars
View flatten_all.clj
(defn flatten-all [m] (->> m (tree-seq coll? seq) (remove coll?)))
View format-plurals.clj
(defn- pluralize [todo last-num done]
(if (empty? todo)
done
(let [[f & r] todo]
(recur
r
(if (number? f) f last-num)
(conj done
(if (coll? f)
((if (= 1 last-num) first second) f)
@whamtet
whamtet / htmx-files.js
Created Jan 28, 2021
Keep selected files
View htmx-files.js
var files;
htmx.defineExtension('file', {
onEvent: function(type, evt) {
if (type === 'htmx:beforeSwap') {
files = htmx.findAll(evt.target, 'input[type="file"]');
}
if (type === 'htmx:afterSwap') {
for (file of files) {
const target = document.getElementsByClassName(file.className)[0];
View alias.sh
sudo ifconfig lo0 alias 127.0.0.2
View primes.clj
(defn next-prime
([] (concat [2 3] (next-prime [2 3])))
([primes]
(loop [candidate (-> primes peek (+ 2))]
(if (->> primes
(take-while #(<= % (Math/sqrt candidate)))
(some #(zero? (mod candidate %))))
(recur (+ candidate 2))
(lazy-seq (cons candidate (next-prime (conj primes candidate))))))))
View ifconfig.cljs
#!/usr/local/bin/planck
(require '[planck.core :refer [*in* slurp]])
(require '[planck.shell :refer [sh]])
(->> "ifconfig"
sh
:out
(re-find #"inet (192\S+)")
second
(sh "pbcopy" :in))
View repl.cs
using clojure.lang;
IFn load = clojure.clr.api.Clojure.var("clojure.core", "load-string");
load.invoke("(clojure.core.server/start-server {:port 5555 :name \"repl\" :accept 'clojure.core.server/repl})" +
"(println \"serving!\")");
// telnet localhost 5555
View open.cljs
#!/opt/homebrew/bin/planck
(require '[planck.core :refer [*in* slurp]])
(require '[planck.shell :refer [sh]])
(defn round-nth [s i]
(nth s (mod i (count s))))
(let [to-open
(as-> *in* $
(slurp $)