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 / 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
@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
;; 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)
(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]
(ns helix-context-memo
(:require [helix.core :refer [defnc $ <>]]
[helix.dom :as d]
[helix.hooks :as hooks]
["react-dom" :as rdom]
["react" :as react]))
(def global-state-context (react/createContext {}))
(def GlobalStateProvider (.-Provider global-state-context))
(ns helix-example
(:require
[helix.core :refer [defnc $ <>]]
[helix.hooks :as hooks]
[helix.dom :as d]
["react-dom" :as rdom]))
(defnc Greeting
"A component which greets a user. The user can double click on their name to edit it."
[{:keys [name on-name-change]}]