Skip to content

Instantly share code, notes, and snippets.

@rob-gordon
rob-gordon / reset.sh
Created July 30, 2024 15:06
Reset Prisma DB
rm -rf prisma/migrations
echo 'DROP SCHEMA public CASCADE; CREATE SCHEMA public;' | npx prisma db execute --stdin
npx prisma migrate dev --name init
@rob-gordon
rob-gordon / style.css
Created August 26, 2023 11:22
Expanding Nodes Style
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500&display=swap");
$background: white;
$color: #31405b;
$fontFamily: "IBM Plex Sans", sans-serif;
$red: #e63946;
$orange: #f4a261;
$yellow: #f1fa3b;
$green: #2a9d8f;
$blue: #606ef6;
@rob-gordon
rob-gordon / CreateLoop.test.ts
Created April 11, 2023 22:37
feedback interactions based on loop
import { describe, test, expect } from "vitest";
import { CreateLoop } from "./CreateLoop";
/**
* TODO:
* - add a before all hook
* - add a after all hook
* - add a before state set hook
* - add a after state set hook
* - abiity to preprocess arguments
@rob-gordon
rob-gordon / state-machine-template-literal.tsx
Created January 25, 2023 14:34
Create a context-less xstate machine from a template literal
import {
AnyEventObject,
BaseActionObject,
StateNodeConfig,
TransitionConfig,
TransitionsConfig,
createMachine,
interpret,
} from "xstate";
@rob-gordon
rob-gordon / test-utils-act.ts
Last active September 1, 2022 16:04
act() Testing Utils
// From https://twitter.com/diegohaz/status/1560525455383461888
// by Diego Haz @diegohaz
// Wait for all queueMicrotask() callbacks
export function flushMicrotasks() {
return act(() => Promise.resolve());
}
// Wait for all requestAnimationFrame() callbacks
export function nextFrame() {
@rob-gordon
rob-gordon / hello-world.js
Created August 20, 2022 13:51
My Public Module Gist
function HelloWorld() {
console.log("Hello World");
}
export default HelloWorld;
@rob-gordon
rob-gordon / index.js
Created August 26, 2021 15:31
get idiom
#!/usr/bin/env node
const request = require("request");
const cheerio = require("cheerio");
const args = process.argv.slice(2);
const search = args[0];
if (!search) throw new Error("Must pass search term");
@rob-gordon
rob-gordon / machine.js
Last active December 1, 2020 13:21
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@rob-gordon
rob-gordon / await.ts
Created November 11, 2020 20:28
Unwrap promises and thenables recursively
// From https://stackoverflow.com/questions/48011353/how-to-unwrap-type-of-a-promise/57364353#57364353
type Await<T> = T extends PromiseLike<infer U> ? Await<U> : T
@rob-gordon
rob-gordon / fluid text with clamp
Last active July 13, 2020 21:31
function for fluid text with clamp
/*
Before
html {
font-size: 16px;
}
@media screen and (min-width: 320px) {
html {
font-size: calc(16px + 6 * ((100vw - 320px) / 680));
}
}