Ensure your react components have a function name so they show up in devtools
// has no name
const Comp = forwardRef(() => {})
export default Comp
// has a name
const Comp = () => {}
export default forwardRef(Comp)| src/web | |
| ├── auth | |
| │ ├── auth-context.tsx | |
| │ ├── auth-store.ts | |
| │ └── login-form.tsx | |
| ├── channel | |
| │ ├── active-channel-list.tsx | |
| │ ├── channel-browser-page.tsx | |
| │ ├── channel-icon.tsx | |
| │ ├── channel-page.tsx |
| export async function retry<T>( | |
| times: number, | |
| fn: () => Promise<T>, | |
| ): Promise<T> { | |
| let lastError: unknown | |
| while (times > 0) { | |
| try { | |
| return await fn() | |
| } catch (error) { | |
| lastError = error |
| export class Maybe<Value> { | |
| constructor(private readonly value: Value | undefined | null) {} | |
| static of<T>(value: T): Maybe<T> { | |
| return new Maybe(value) | |
| } | |
| static empty<T>(): Maybe<T> { | |
| return new Maybe<T>(undefined) | |
| } |
| #!/bin/bash | |
| pkill -HUP -f "cinnamon --replace" | |
| killall -HUP cinnamon | |
| export DISPLAY=":0" | |
| cinnamon & | |
| # https://unix.stackexchange.com/questions/30370/how-to-get-the-pid-of-the-last-executed-command-in-shell-script | |
| disown $! |
| get: async (context) => { | |
| const user = await createSessionHelpers(context).getUser() | |
| if (!user) { | |
| return redirect("/login") | |
| } | |
| const id = context.params?.bucketId | |
| if (!id) { | |
| return notFound() | |
| } |
| useEffect(() => { | |
| const timeout = setTimeout(() => { | |
| doSomething() | |
| }, 5000) | |
| return () => clearTimeout(timeout) | |
| }, []) |
Ensure your react components have a function name so they show up in devtools
// has no name
const Comp = forwardRef(() => {})
export default Comp
// has a name
const Comp = () => {}
export default forwardRef(Comp)| import { useEffect, useRef, useState } from "react" | |
| export function useDebouncedValue<T>( | |
| sourceValue: T, | |
| ms: number | undefined | |
| ): T { | |
| const [value, setValue] = useState(sourceValue) | |
| useEffect(() => { | |
| if (ms == null) return |
| type RangeArgs = | |
| | [end: number] | |
| | [start: number, end: number] | |
| | [start: number, end: number, step: number] | |
| function* range(...args: RangeArgs): Generator<number> { | |
| let start: number | |
| let end: number | |
| let step = 1 |
| import { Draft, produce } from "immer" | |
| type ValueOf<T> = T[keyof T] | |
| type ActionType< | |
| ActionMap extends Record<string, (state: any, arg: any) => void> | |
| > = ValueOf< | |
| { | |
| [K in keyof ActionMap]: ActionMap[K] extends ( | |
| state: any, |