Skip to content

Instantly share code, notes, and snippets.

View bolubee101's full-sized avatar

Akinwande Akinboluwarin bolubee101

View GitHub Profile
@bolubee101
bolubee101 / migration.sql
Last active February 26, 2025 08:12
PostgreSQL Schema and Data Migration Script Using the dblink extension
DO $$
DECLARE
tbl RECORD;
col RECORD;
seq RECORD;
udt RECORD;
schema RECORD;
sql TEXT;
default_expr TEXT;
column_definitions TEXT;
@AkinAguda
AkinAguda / range.ts
Last active January 26, 2024 22:53
A `Range` type in typescript that ensures that a value is within a certain range of positive values (not inclusive of the last)
// Convert string to number
type ToNumber<S> = S extends `${infer N extends number}` ? N : never;
// Creates an array with a particular length
type ArrayWithLength<
T extends number,
A extends number[] = number[],
> = A["length"] extends T ? A : ArrayWithLength<T, [...A, A["length"]]>;
// Generates a union type with all the numbers from zero -> n
@davidekete
davidekete / updateEnv.js
Last active November 15, 2023 11:32
A script that watches your .env file and updates your .env.example file
const fs = require('fs');
const chokidar = require('chokidar');
const envFilePath = './.env';
const exampleFilePath = './.env.example';
/**
* Reads the contents of the .env file and returns an array of variable names.
* @returns A set of variable names from the .env file.
*/