Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stephenh
stephenh / .yarnrc.yml
Created October 23, 2023 15:40
supported architectures
# This setting ensures we always install the Linux binaries when running `yarn install`. This is needed for running
# swc natively in Docker from a Mac host.
supportedArchitectures:
cpu:
- current
- x64
- arm64
libc:
- current
- glibc
<body class="b-using-keyboard">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root" style="position: relative; z-index: 0;">
<div class="css-32lf3s">
<img src="/wordmark.svg" alt="Homebound" class="css-u1jr60" />
<div class="css-1k9buc6">Purchase Order</div>
<div class="css-1yduzul">
<div class="css-11ykhmt">Prime Contractor ("Homebound")</div>
<div class="css-11ykhmt">Trade Partner</div>
</div>
@stephenh
stephenh / .gitconfig
Created July 14, 2022 21:58
Multiple git configs
# In your home directory ~.gitconfig
[user]
name = <your name>
email = <personal-email>@gmail.com
# If all Homebound-related code is in your ~/homebound directory
[includeIf "gitdir:~/homebound/"]
path = .gitconfig-homebound
@stephenh
stephenh / linkedomEnv.js
Created April 3, 2021 22:04
linkedomEnv.js
const { EnvironmentContext, JestEnvironment } = require("@jest/environment");
const { LegacyFakeTimers, ModernFakeTimers } = require("@jest/fake-timers");
const { Config, Global } = require("@jest/types");
const { ModuleMocker } = require("jest-mock");
const JestUtil = require("jest-util");
const { parseHTML } = require("linkedom");
const VM = require("vm");
const { Script } = VM;
/**
@stephenh
stephenh / makeSimpleAutoObservable.ts
Last active August 19, 2021 13:30
makeSimpleAutoObservable.ts
import { $mobx, isObservable, makeObservable } from "mobx";
const annotationsSymbol = Symbol("annotationsSymbol");
const objectPrototype = Object.prototype;
/**
* A purposefully-limited version of `makeAutoObservable` that supports subclasses.
*
* There is valid complexity in supporting `makeAutoObservable` across disparate/edge-casey
* class hierarchies, and so mobx doesn't support it out of the box. See:
@stephenh
stephenh / exact.ts
Created July 9, 2020 20:33
ExactType
type Args = {
id?: string | undefined | null;
firstName?: string | undefined | null;
parentId?: string | undefined | null;
different?: string | undefined | null;
};
type Opts = {
id?: string | undefined | null;
firstName?: string | undefined | null;
@stephenh
stephenh / foo.ts
Created June 4, 2020 13:09
Blessed proxy
class Target {
ref = new Ref();
foo() {
return this.bar();
}
bar() {
return this.ref;
}
}
class Ref {
interface AstNode<T> {
value: T;
}
const n1: AstNode<number> = { value: 1 };
const n2: AstNode<string> = { value: "asdf" };
// https://github.com/microsoft/TypeScript/pull/26063 says that if T is a tuple
// type, the mapped type will map each specific type in the tuple.
type Values<T> = { [P in keyof T]: T[P] extends AstNode<infer V> ? V : never };
import path from "path";
import { Polly, PollyConfig } from "@pollyjs/core";
// @ts-ignore polly's typings aren't great but we don't really need them for this small init code
import { setupPolly } from "setup-polly-jest";
import { MODES } from "@pollyjs/utils";
import { env } from "@src/env";
Polly.register(require("@pollyjs/adapter-node-http"));
Polly.register(require("@pollyjs/persister-fs"));
@stephenh
stephenh / foo.ts
Last active May 18, 2019 15:14
doWhileMounted
class Foo {
a = 1;
b(): void {}
c(): boolean {
return true;
}
}
// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c
type FilterFlags<Base, Condition> = {