Skip to content

Instantly share code, notes, and snippets.

@tcyrus
tcyrus / snowflake-id.sql
Last active May 25, 2021 09:20 — forked from beginor/snowflake-id.sql
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE IF NOT EXISTS public.snowflake_id_seq
MINVALUE 0 MAXVALUE 1023
CYCLE;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
-- 41 bits for time in milliseconds
-- (41 years of IDs from epoch)
-- 13 bits for the logical shard ID
-- 10 bits for the global auto-incrementing sequence (modulus 1024).
-- This means we can generate 1024 IDs, per shard, per millisecond
@tcyrus
tcyrus / main.js
Last active December 13, 2018 22:16 — forked from risacher/main.js
glue to make blessed (low-level API) work in browserify with xterm.js
const blessed = require("blessed");
window.onload = function () {
const term = new Terminal({
cols: 80,
rows: 24
});
term.open(document.body);
term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n');