Skip to content

Instantly share code, notes, and snippets.

@shaunlebron
shaunlebron / safe-navigation-clojure.md
Last active November 5, 2025 21:31
Safe Navigation in Clojure

Safe Navigation in Clojure

safe-> is a safe navigation macro for Clojure. It extends some-> with additional guards:

  1. doesn’t call nil values
  2. doesn’t call missing methods (ClojureScript only)

#!/bin/bash
# Cheatsheet for remembering Bash rules for Parameter Substitution:
# https://tldp.org/LDP/abs/html/parameter-substitution.html#PSUB2
# Fallback for unset vars
# Bash #——> like JavaScript
${a+b} #——> a && b
@shaunlebron
shaunlebron / timed-functions.clj
Created March 16, 2025 03:06
setTimeout and setInterval in clojure (java)
(ns user
(:import (java.util.concurrent Executors TimeUnit)))
(defn set-timeout [^Callable f ^long ms]
(doto (Executors/newScheduledThreadPool 1)
(.schedule f ms TimeUnit/MILLISECONDS)))
(defn set-interval [^Callable f ^long ms]
(doto (Executors/newScheduledThreadPool 1)
(.scheduleAtFixedRate f 0 ms TimeUnit/MILLISECONDS)))
@shaunlebron
shaunlebron / kalshi-signing.java
Last active March 6, 2025 03:21
Kalshi signing in Java
import java.nio.charset.StandardCharsets;
import java.security.PrivateKey;
import java.security.Security;
import java.security.Signature;
import java.util.Base64;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser;
@shaunlebron
shaunlebron / polymarket.sign.clj
Last active June 8, 2025 23:23
Polymarket order signing in Clojure
(ns example.polymarket.sign
(:require
[cheshire.core :as json]
[clojure.string :as str])
(:import
(org.web3j.crypto Sign Credentials) ;; org.web3j/crypto "4.12.2"
(org.web3j.utils Numeric)
(java.util Base64)
(javax.crypto Mac)
(javax.crypto.spec SecretKeySpec)))
@shaunlebron
shaunlebron / polymarket-data-api-docs.md
Last active January 4, 2025 20:03
Polymarket Data API Docs
@shaunlebron
shaunlebron / css-typography.md
Last active April 13, 2024 17:07
CSS typography

CSS Typography

We can do typographic things in CSS that we couldn’t before.

Hanging Indent

text-indent: 2em hanging; /* Safari and Firefox only */
@shaunlebron
shaunlebron / flexbox-rosetta.md
Last active April 13, 2024 17:32
Flexbox Rosetta Stone

Flexbox vs Inline alignment

flex-flow: row wrap shows how inline text alignment is a special case of flexbox:

TEXT-ALIGN:         left  | center | right | justify       | __           | __
→ JUSTIFY-CONTENT:  start | middle | end   | space-between | space-around | space-evenly

VERTICAL-ALIGN:     top   | middle | bottom | __
→ ALIGN-SELF: start | center | end | stretch