Skip to content

Instantly share code, notes, and snippets.

View jviall's full-sized avatar

james jviall

View GitHub Profile
@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
## 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 / 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

@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)