Based on https://bl.ocks.org/officeofjane/2c3ed88c4be050d92765de912d71b7c4
(gist: https://gist.github.com/officeofjane/2c3ed88c4be050d92765de912d71b7c4 )
MIT licensed.
Use node process.node.js
to split into separate layout files.
import {useSyncExternalStore} from 'use-sync-external-store/shim'; | |
const DOT = '.'; | |
export default function createStore(defaultStore = {}) { | |
let allStore = defaultStore; | |
const listeners = new Set(); | |
function subscribe(listener) { | |
listeners.add(listener); |
#!/bin/bash | |
# Execution-relative (all shells). Get dir path of the script executed | |
# by the user. | |
__0="$(CDPATH= cd -- $(dirname -- $0) && pwd -P)" | |
echo "$__0"/bar | |
# Code-relative (bash/zsh only). Get dir path of *this file*, |
#!/bin/bash | |
# Like docker compose build [SERVICE]. | |
# | |
# USAGE: ddev-build [SERVICE] | |
# | |
function ddev-build { | |
~/.ddev/bin/docker-compose -f .ddev/.ddev-docker-compose-full.yaml build $1 --no-cache --progress=plain | |
} |
<body> | |
<svg viewBox="0 0 200 200" height="200"> | |
<circle cx="100" cy="100" r="90" pathLength="1" transform="rotate(-90 100 100)" class="percentage" stroke-dashoffset="0.9"></circle> | |
</svg> | |
<p> | |
Set percentage: | |
<button type="button">0</button> | |
<button type="button">15</button> | |
<button type="button">50</button> |
Based on https://bl.ocks.org/officeofjane/2c3ed88c4be050d92765de912d71b7c4
(gist: https://gist.github.com/officeofjane/2c3ed88c4be050d92765de912d71b7c4 )
MIT licensed.
Use node process.node.js
to split into separate layout files.
type RGB = [number, number, number]; | |
export function parseRgb(color: RGB | string): RGB { | |
if (Array.isArray(color)) { | |
return color; | |
} | |
let c = color; | |
let m; | |
if ( |
#!/bin/bash | |
# Script is needed because my default firewall rules are messed up and after | |
# every restart, docker containers can't make connections to the host, notably | |
# preventing debuggers like xdebug from attaching. | |
# If networking fails in your containers but works in others, rm and re-create the | |
# docker network that container is bound to. | |
set -euo pipefail |
import { useEffect, useRef } from 'react'; | |
export default function usePrevious<T, U>(value: T, init: U): T | U { | |
const ref = useRef<T | U>(init); | |
useEffect(() => { | |
ref.current = value; | |
}); | |
return ref.current; | |
} |
function isRichValue(value) { | |
return Boolean(value && Array.isArray(value.richText)); | |
} | |
function richToString(rich) { | |
return rich.richText.map(({ text }) => text).join(''); | |
} | |
function richToHtml(rich) { | |
let str = rich.richText.map(({ font = {}, text }) => { |
#!/bin/bash | |
# Like docker compose logs -f but it waits for containers to come back up | |
# if they stop or haven't been started. | |
# | |
# USAGE: dclogs [SERVICE] | |
# | |
function dclogs { | |
# If in ddev project, use ddev's full config file | |
if [ -d ".ddev" ]; then |