Skip to content

Instantly share code, notes, and snippets.

View jimbuck's full-sized avatar

Jim Buck jimbuck

View GitHub Profile
@jimbuck
jimbuck / setup-next-ts.bat
Last active August 30, 2019 03:45
Next.js Setup for TypeScript
npm init -y
npm i -P react react-dom next bootstrap react-bootstrap @zeit/next-css @zeit-next-less
npm i -D typescript @types/react @types/react-dom @types/node
npx npm-add-script -k dev -v next -f
npx npm-add-script -k build -v "next build" -f
npx npm-add-script -k start -v "next start" -f
mkdir pages
mkdir components
@jimbuck
jimbuck / debug.css
Created August 25, 2021 13:05
Show debug data on a site.
.show-debug *[data-debug]::after {
content: attr(data-debug);
color: #f00;
position: absolute;
opacity: 0.1;
}
.show-debug *[data-debug]:hover::after {
opacity: 1;
}
@jimbuck
jimbuck / buffered.ts
Created November 30, 2021 21:51
Creates a buffered function using RXJS.
import { Subject, fromEvent } from 'rxjs';
import { buffer, map, filter } from 'rxjs/operators';
function buffered<T>(handler: ((values: T[]) => Promise<void>)) {
const valueQueue = new Subject<T>();
const bufferTrigger = new Subject<void>();
let busy = false;
let destroyed = false;
const sub = valueQueue.pipe(