Skip to content

Instantly share code, notes, and snippets.

@jordiup
jordiup / zod-postgres-connection.ts
Created August 29, 2024 14:45
Zod Postgres Connection Schema
import { z } from 'zod';
const connectionSchema = z.object({
user: z.string(),
password: z.string(),
host: z.string(),
database: z.string(),
port: z.number().int().positive().default(5432),
ssl: z.boolean().default(true),
pooling: z.boolean().default(true),
SELECT
EXTRACT(MONTH FROM s."shiftStart")::int AS month,
/* ---------- average hourly rate ---------- */
ROUND(AVG(
CASE
WHEN s."positionParentCategory" = 'Consultant' THEN
CASE
WHEN s."isDayRate" THEN s.cost / NULLIF(s.hours, 0)
WHEN s."isHourlyRate" THEN s.rate
@jordiup
jordiup / medicare-number-validation.ts
Last active January 12, 2026 23:18
Medicare Number Validation - Typescript
/**
* Australian Medicare Number Validation
*
* Validates an 11-digit Medicare card number using the official checksum algorithm.
*
* Structure (11 digits total):
* - Identifier: 8 digits (first digit must be 2-6, indicates state/territory)
* - Checksum: 1 digit (weighted sum mod 10)
* - Issue Number: 1 digit (card reissue count)
* - IRN: 1 digit (Individual Reference Number)