Skip to content

Instantly share code, notes, and snippets.

View restore.sql
UPDATE pg_database SET datallowconn = TRUE WHERE datname = 'template0';
\c template0
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = 'template0';
\c template1
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template0';
View convert-to-ipad
ffmpeg -i {filename} -acodec aac -ac 2 -strict experimental -ab 160k -s {ssize} -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b 1200k -f mp4 -threads 0 {filename}.ipad.mp4
@juike
juike / gist:9770209
Created Mar 25, 2014
Postgresql table inherits view
View gist:9770209
WITH RECURSIVE tables_tree (table_oid, path) AS (
SELECT I.inhparent AS table_oid, '{}'::oid[] AS path
FROM pg_inherits I
LEFT JOIN pg_inherits I2 ON I.inhparent = I2.inhrelid
WHERE I2.inhparent IS NULL
UNION
SELECT I.inhrelid, TT.path || I.inhparent
FROM pg_inherits I