Skip to content

Instantly share code, notes, and snippets.

View anztrax's full-sized avatar
🎯
Focusing

andrew ananta gondo anztrax

🎯
Focusing
View GitHub Profile
@anztrax
anztrax / ReadonlyAndExclude.ts
Created December 1, 2025 02:47
Simple implementation of Readonly + Exclude in Typescript
type MyReadonly2<T, K extends keyof T = keyof T> = {
readonly [P in K] :T[P]
} & {
[P in keyof T as P extends K ? never : P] : T[P]
}
@anztrax
anztrax / If.ts
Created November 30, 2025 00:46
simple implementation of If in Typescript
/* _____________ Your Code Here _____________ */
type If<C extends boolean, T, F> = C extends true ? T: F
/* _____________ Test Cases _____________ */
import type { Equal, Expect } from '@type-challenges/utils'
type cases = [
Expect<Equal<If<true, 'a', 'b'>, 'a'>>,
Expect<Equal<If<false, 'a', 2>, 2>>,
@anztrax
anztrax / Awaited.ts
Created November 30, 2025 00:40
Simple implementation of Awaited in Typescript
type MyAwaited<T> = T extends PromiseLike<infer A> ? MyAwaited<A> : T;
/* _____________ Test Cases _____________ */
import type { Equal, Expect } from '@type-challenges/utils'
type X = Promise<string>
type Y = Promise<{ field: number }>
type Z = Promise<Promise<string | number>>
type Z1 = Promise<Promise<Promise<string | boolean>>>
type T = { then: (onfulfilled: (arg: number) => any) => any }
@anztrax
anztrax / exclude.ts
Created November 30, 2025 00:32
Simple Implementation of Exclude in Typescript
type MyExclude<T, U> = T extends U ? never: T;
@anztrax
anztrax / ArrayLength.ts
Created November 30, 2025 00:25
Simple Implementation Got Length of Array in Typescript
type Length<T extends readonly unknown[]> = T['length']
@anztrax
anztrax / First.ts
Created November 30, 2025 00:20
Simple implementation of First Array in Typesscript
type First<T extends any[]> = T extends [infer P, ...unknown[]] ? P : never;
@anztrax
anztrax / TupleToObject.ts
Created November 30, 2025 00:13
Simple Implemention Tuple to Object
// this version using any
type TupleToObject<T extends readonly (keyof any)[]> = {
[A in T[number]]: A
}
@anztrax
anztrax / readonly.ts
Created November 30, 2025 00:05
Simple implementation of Readonly in Typescript
type MyReadonly<T> = {
readonly [A in keyof T]: T[A]
}
@anztrax
anztrax / pick.ts
Created November 29, 2025 23:56
Simple Pick implementation in Typescript
type MyPick<T, K extends keyof T> = {
[key in K]: T[key]
}
@anztrax
anztrax / gist:b6ae83cc358bfe2a4a5376a316a04eef
Created May 25, 2025 15:52
Reset password for open-webui ( forgot password )
docker exec -it open-webui rm /app/backend/data/webui.db