Skip to content

Instantly share code, notes, and snippets.

View lilactown's full-sized avatar
🌊
Do not follow in the footsteps of the sages. Seek what they sought.

Will Acton lilactown

🌊
Do not follow in the footsteps of the sages. Seek what they sought.
View GitHub Profile
@lilactown
lilactown / html.clj
Last active January 20, 2024 05:35
(ns helix.util.html)
(require
'[clojure.data.xml :as xml]
'[clojure.walk :as walk])
(import '[clojure.data.xml Element])
(defn html->dom
@lilactown
lilactown / promises.re
Last active August 20, 2022 07:56
Notes on using JavaScript Promises in ReasonML/BuckleScript
/**
* Making promises
*/
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok"));
/* Simpler promise creation for static values */
Js.Promise.resolve("easy");
Js.Promise.reject(Invalid_argument("too easy"));
@lilactown
lilactown / runner
Last active July 24, 2022 02:03
Show a self-install nbb script by using a wrapper around nbb
#!/usr/bin/env bash
current_dir=$(pwd)
# make directory to hold node_modules
read -ra hash <<< "$(pwd | shasum)" # get hash of current path
modules_dir="$HOME/.nbb/_modules/${hash[0]}"
mkdir -p "$modules_dir"
# install node_modules
Skeletyl self source cost
5x each PCB from JLCPCB: 33.46 + 20.13 = 53.59
Digikey
Flex strips x 30 = 47.48
Diode x 100 = 17.70
Neopixel LED x 70 = 20.65
330 Ohm resistor x 20 = 2.66
;; An example usage of an imaginary `iteration-async` API, which uses
;; continuation passing to signal when to continue to the next page,
;; completion, and failure
(defn fetch-pages-async
"Fetches summary pages repeatedly until no pages are left.
Calls `done` callback when complete. Calls `err` if an error occurs."
([done err url]
(fetch-summaries done err url 0))
([done err url page]
(ns lilactown.template
#?(:cljs (:require-macros [lilactown.template])))
(defn- interleave*
"A version of interleave that continues to build the lazy seq even if one of
the coll has no elements left"
([] ())
([c1] (lazy-seq c1))
([c1 c2]
function useCutoff(x, cutoff) {
// track each value of x between renders
let xPrev = useRef(x);
useEffect(() => { xPrev.current = x }, [x]);
// if the cutoff function returns true, render the previously returned value.
// else, synchronously schedule render withnew state value
let [ret, setRet] = useState(x);
if (!cutoff(xPrev.current, x)) {
setRet(x)
(ns eff.global-scope
(:import
(java.lang Continuation ContinuationScope)))
(let [effect-scope (ContinuationScope. "effect")
state (atom 0)
;; track what effect is currently being performed,
;; and what we're going to return
effect-performing (atom nil)
effect-returning (atom nil)
@lilactown
lilactown / cljs-serverless.md
Last active January 27, 2020 05:06
CLJS in AWS Lambda Quick Start
(ns helix-three.core
(:require [goog.object :as gobj]
[helix.core :refer [defnc $]]
[helix.hooks :as hooks]
[cljs-bean.core :as b]
["react-dom" :as rdom]
["react-three-fiber" :as rtf])
(:refer-clojure :exclude [Box]))
(defnc Box [props]