Skip to content

Instantly share code, notes, and snippets.

@nkint
nkint / gist:077b6deccdf61351f016dee5b83a2021
Created October 28, 2022 08:34
map fit mapLinear implementations
umbrella:
https://github.com/thi-ng/umbrella/blob/develop/packages/math/src/fit.ts
arduino:
https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/WMath.cpp#L52
p5:
https://github.com/processing/p5.js/blob/main/src/math/calculation.js#L448
openframework:
@nkint
nkint / types.ts
Created November 10, 2022 10:39
Typescript refine string array
// fail silently
type Age = "6" | "12" | "24" | "54" | "72" | "84"
type AgeOld = Extract<Age, "72" | "84" | "62">
// fail kabum
type Age = "6" | "12" | "24" | "54" | "72" | "84"
type ExtractOrFail<T, U extends T> = U
type AgeOld = ExtractOrFail<Age, "72" | "84" | "62">
import { KdTreeSet } from "@thi.ng/geom-accel";
import { samplePoisson } from "@thi.ng/poisson";
import { randMinMax2 } from "@thi.ng/vectors";
import PoissonDiskSampling from "poisson-disk-sampling";
import FastPoissonDiskSampling from "fast-2d-poisson-disk-sampling";
import { DVMesh } from "@thi.ng/geom-voronoi";
import Delaunator from "delaunator";
@nkint
nkint / gist:6dec465fce63de50b510752c89bfcae0
Last active November 26, 2024 10:49
useWhyDidYouUpdate.js
/**
* Debug hook showing which props updated between two renders
* @example
*
* const MyComponent = React.memo(props => {
* useWhyDidYouUpdate('MyComponent', props);
* return <div...;
* });
*
* @link https://usehooks.com/useWhyDidYouUpdate/