Skip to content

Instantly share code, notes, and snippets.

@heri16
heri16 / 0-README.md
Last active April 19, 2025 08:54
Secure Number Masking for Postgres (Scrambling DB Primary Keys or sensitive data using NIST FF1 Format Preserving Encryption)

What

This is open-source code that lets you secure or mask numbers (within Postgresql DB) for use as unique IDs that are 6-digits or more.

This is what they look like:

https://example.com/order/053124
@J-Yaghoubi
J-Yaghoubi / sql-cheat-sheet.md
Last active May 14, 2025 11:41
Postgres SQL query cheat sheet
@joelonsql
joelonsql / PostgreSQL-EXTENSIONs.md
Last active July 23, 2025 02:30
1000+ PostgreSQL EXTENSIONs

🗺🐘 1000+ PostgreSQL EXTENSIONs

This is a list of URLs to PostgreSQL EXTENSION repos, listed in alphabetical order of parent repo, with active forks listed under each parent.

⭐️ >= 10 stars
⭐️⭐️ >= 100 stars
⭐️⭐️⭐️ >= 1000 stars
Numbers of stars might not be up-to-date.

@fabiolimace
fabiolimace / fn_tsid_milli.sql
Last active May 23, 2025 21:11
Function for generating Time Sortable ID with millisecond precision on PostgreSQL
/**
* Returns a Time Sortable ID with millisecond precision.
*
* Time component: 42 bits (2^42 = ~69 years)
*
* Random component: 22 bits (2^22 = 4,194,304)
*
* The time component is the count of milliseconds since 2020-01-01T00:00:00Z.
*
* Tags: tsid ulid snowflake id-generator generator time sortable sort order id
@beginor
beginor / snowflake-id.sql
Last active May 24, 2025 06:18
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;