Skip to content

Instantly share code, notes, and snippets.

@jviall
jviall / useAsyncDebounce.ts
Last active August 4, 2020 16:18
type-ified version of react-table's useAsyncDebounce hook
export function useAsyncDebounce<T extends (args: any[]) => any>(defaultFn: T, defaultWait: number): T {
const debounceRef = React.useRef<{
promise?: Promise<T>,
resolve?: (value: T | PromiseLike<T>) => void,
reject?: (reason?: any) => void,
timeout?: NodeJS.Timeout
}>({})
// the given args could be props, which change, so we want to always use latest definitions.
const getDefaultFn = useGetLatest(defaultFn)
@jviall
jviall / index.md
Last active January 23, 2023 20:17
Scope -- TypeScript Advanced Techniques -- TS Playground Pres

Advanced TypeScript Techniques

Team Disco

  • Dylan Roberts
  • James Viall

Topic: Generics

Types that take parameters

Typing the useState React hook

## First let's download YADM using Homebrew
brew install yadm
## did it work? You can check out the docs at https://yadm.io
which yadm
## YADM, as well as many other dotfile managament tools, uses the same commands as Git such as checkout, add, and commit
## We can use `yadm clone` to get a dotfiles repo going. So let's create a new repo called "dotfiles" and then clone it
open https://github.com/new?name=dotfiles
yadm clone jviall/dotfiles
@jviall
jviall / aws-sso-alias.zsh
Created February 25, 2026 21:13
A helper Bash/Zsh function/alias to quickly switch between existing AWS Profiles, and log in to them.
# what is my active AWS Profile?
alias awswho='aws sts get-caller-identity'
# Start a fresh session with my active AWS Profile
alias awslogin='aws sso login'
# Switch my active AWS Profile: e.g. `awsp res-dev`
function awsp() {
if [ -z "$1" ]; then
echo "Usage: awsp <profile-name>"
echo "Available profiles:"
aws configure list-profiles
@jviall
jviall / README.md
Last active June 9, 2026 06:40
rekordbox-edit: e2e audio fixture generation

rekordbox-edit e2e audio fixtures — generation and authoring guide

This gist holds the off-repo material used to produce the audio fixtures and master.db files for the rekordbox-edit end-to-end suite. The audio files themselves live in the repo under tests/e2e/fixtures/audio/.

Filename convention

NN-<codec>-<rate>-<depth-or-bitrate>[-encmode].<ext>