snippets.

small pieces of code i keep coming back to.

eza alias
bash
alias ls="eza --color=always --long --git --icons=always --no-time --no-user"
find the process
bash
lsof -i tcp:3000
generate 16 character random hash
bash
openssl rand -hex 16
generate rsa key
bash
ssh-keygen -t rsa
omit in union
typescript
// Source - https://stackoverflow.com/a/57103940
type DistributiveOmit<T, K extends keyof any> = T extends any
  ? Omit<T, K>
  : never;
remove all files from git tracking
bash
git rm -r --cached .
remove input focus
css
focus-visible:outline-none
sleep
typescript
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
group by
typescript
function groupBy<T>(arr: T[], key: (item: T) => string): Record<string, T[]> {
  return arr.reduce((acc, item) => {
    const group = key(item);
    (acc[group] ??= []).push(item);
    return acc;
  }, {} as Record<string, T[]>);
}