Skip to content

Instantly share code, notes, and snippets.

View whamtet's full-sized avatar

Matthew Molloy whamtet

  • Tokyo
View GitHub Profile
(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" "*"})
(defn wrap-cors [handler]
(fn [req]
(if (-> req :request-method (= :options))
{:status 200
:headers cors-headers
(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])
import java.awt.*;
import java.time.LocalDateTime;
public class MouseMover {
public static final int PAUSE = 20000;
public static void main(String... args) throws Exception {
int limit = args.length == 0 ? 24 : Integer.parseInt(args[0]);
System.out.println("Time limit: " + limit);
@whamtet
whamtet / clipboard.clj
Created November 2, 2022 08:12 — forked from exupero/clipboard.clj
Clojure code to interact with the system clipboard
(ns test.core
(:import [java.awt.datatransfer DataFlavor StringSelection Transferable]))
(defn clipboard []
(.getSystemClipboard (java.awt.Toolkit/getDefaultToolkit)))
(defn slurp-clipboard []
(.getTransferData (.getContents (clipboard) nil) (DataFlavor/allHtmlFlavor)))
(def html-flavors
-- run as cat sqlite.sql | sqlite3
CREATE TABLE ichiba (
disp_date INTEGER,
genre3_id INTEGER,
gms REAL,
order_cnt INTEGER
);
.mode tabs
setInterval(() => document.body.querySelector('.video-button').click(), 1000);