Skip to content

Instantly share code, notes, and snippets.

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 / runner
Last active July 24, 2022 02:03
Show a self-install nbb script by using a wrapper around nbb
View runner
#!/usr/bin/env bash
# make directory to hold node_modules
read -ra hash <<< "$(pwd | shasum)" # get hash of current path
mkdir -p "$modules_dir"
# install node_modules
View skeletyl_parts_cost
Skeletyl self source cost
5x each PCB from JLCPCB: 33.46 + 20.13 = 53.59
Flex strips x 30 = 47.48
Diode x 100 = 17.70
Neopixel LED x 70 = 20.65
330 Ohm resistor x 20 = 2.66
View html.clj
(ns helix.util.html)
'[ :as xml]
'[clojure.walk :as walk])
(import '[ Element])
(defn html->dom
View iteration_async_example.cljc
;; 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]
View template.cljs
(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]
View useCutoff.js
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)) {
View global-scope.clj
(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)
View helix_three_core.cljs
(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]
View helix_context_memo.cljs
(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))
View helix_example.cljs
(ns helix-example
[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]}]