Skip to content

Instantly share code, notes, and snippets.

@juike
juike / gist:9770209
Created March 25, 2014 20:07
Postgresql table inherits view
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
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 / restore.sql
Created November 21, 2014 06:40
Restoring a 'template1' database in PostgreSQL. (https://wiki.postgresql.org/wiki/Adventures_in_PostgreSQL,_Episode_1)
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';