Skip to content

Instantly share code, notes, and snippets.

View jjhiggz's full-sized avatar
🎯
Focusing

Jonathan Higger jjhiggz

🎯
Focusing
View GitHub Profile
@jjhiggz
jjhiggz / superpipe.ts
Last active July 16, 2025 11:54
superpipe
/**
* Perform left-to-right function composition.
* @param value The initial value.
* @param operations the list of operations to apply.
* @signature R.pipe(data, op1, op2, op3)
* @example
* superpipe(
* [1, 2, 3, 4],
* R.map(x => x * 2),
* arr => [arr[0] + arr[1], arr[2] + arr[3]],
@jjhiggz
jjhiggz / sync-promise.ts
Created July 16, 2025 12:09
sync-promise
type SyncPromiseState<T, E = unknown> =
| { status: 'ok'; value: T }
| { status: 'error'; error: E };
class SyncPromise<T, E = unknown> {
private state: SyncPromiseState<T, E>;
private constructor(state: SyncPromiseState<T, E>) {
this.state = state;
}
@jjhiggz
jjhiggz / how-to-use.md
Last active September 28, 2025 02:22
Prisma Effect Generator

Prisma Effect Generator

  1. Put the above prisma-effect-generator.ts in your root of your project.

  2. Install "@prisma/generator-helper" and "@prisma/internals" as dev dependecies.

  3. Add this to your schema.prisma file

generator sqlSchema {
import { z } from "zod";
// Zod schemas with branding
export const DollarsSchema = z.number().nonnegative().brand("dollars");
export const CentsSchema = z.number().int().nonnegative().brand("cents");
export type Dollars = z.infer<typeof DollarsSchema>;
export type Cents = z.infer<typeof CentsSchema>;
type DollarVal = Dollars | null | undefined;