Skip to content

Instantly share code, notes, and snippets.

@tswaters
tswaters / postgres-policy.sql
Last active February 7, 2020 05:08
postgres policy
SET SESSION app.id TO DEFAULT;
SET ROLE postgres;
SET search_path = 'public';
DROP TABLE IF EXISTS expenses CASCADE;
DROP TABLE IF EXISTS projects CASCADE;
DROP TABLE IF EXISTS users CASCADE;
CREATE TABLE users (
user_name text PRIMARY KEY NOT NULL,
@tswaters
tswaters / game-of-life.mjs
Created December 13, 2020 00:05
Terminal game of life
import readline from 'readline'
const w = process.stdout.columns
const h = process.stdout.rows
const init = () => Array.from({ length: w * h }).map(() => Math.round(Math.random()))
let state = init()
const deindex = (i) => [i % w, Math.floor(i / w)]
@tswaters
tswaters / index.html
Created December 4, 2021 03:27
HOW TO: center text
<!DOCTYPE html>
<html>
<head>
<title>How to center text</title>
<meta charset="utf-8" />
</head>
<body>
<table style="width: 100%; height: 100%; position:absolute;">
<tr>
<td valign="middle" align="center">
@tswaters
tswaters / ddl.sql
Created August 31, 2022 21:33
crud operations using json_to_recordset
CREATE TABLE _table (
pk SERIAL PRIMARY KEY,
field1 TEXT,
field2 TEXT,
date_deleted TIMESTAMPTZ
);