start new:
tmux
start new with session name:
tmux new -s myname
| import logging | |
| import sqlalchemy | |
| import sys | |
| from sqlalchemy.engine.base import Engine | |
| import sqlalchemy.event | |
| class ExplainPlan(object): | |
| """ | |
| Context manager that outputs the postgres explain plan for every | |
| query executed within to stdout or a file, if provided with "logfile" |
| SELECT 'SET ADD TABLE (SET id = 1, origin = 1, FULL QUALIFIED NAME = ''' || nspname || '.' || relname || ''', comment=''' || nspname || '.' || relname || ' TABLE'');' FROM pg_class JOIN pg_namespace ON relnamespace = pg_namespace.oid WHERE relkind = 'r' AND relhaspkey AND nspname NOT IN ('information_schema', 'pg_catalog') ORDER BY pg_total_relation_size(pg_class.oid) DESC; | |
| SELECT 'SET ADD SEQUENCE (SET id = 1, origin = 1, FULL QUALIFIED NAME = ''' || n.nspname || '.' || c.relname || ''', comment=''' || n.nspname || '.' || c.relname || ' SEQUENCE'');' FROM pg_class c, pg_namespace n WHERE c.relnamespace = n.OID AND c.relkind = 'S'; |
| WITH btree_index_atts AS ( | |
| SELECT nspname, relname, reltuples, relpages, indrelid, relam, | |
| regexp_split_to_table(indkey::text, ' ')::smallint AS attnum, | |
| indexrelid as index_oid | |
| FROM pg_index | |
| JOIN pg_class ON pg_class.oid=pg_index.indexrelid | |
| JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace | |
| JOIN pg_am ON pg_class.relam = pg_am.oid | |
| WHERE pg_am.amname = 'btree' | |
| ), |
| #!/usr/bin/env ruby | |
| require 'json' | |
| require 'fileutils' | |
| include FileUtils | |
| # Parses the argument array _args_, according to the pattern _s_, to | |
| # retrieve the single character command line options from it. If _s_ is | |
| # 'xy:' an option '-x' without an option argument is searched, and an | |
| # option '-y foo' with an option argument ('foo'). |
WAL-E needs to be installed on all machines, masters and slaves.
Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:
archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
As configured in my dotfiles.
start new:
tmux
start new with session name:
An implementation of Conway's Game of Life in 140 characters of Ruby.
Created by Simon Ernst (@sier).
| #!/usr/bin/env python | |
| """Split large file into multiple pieces for upload to S3. | |
| S3 only supports 5Gb files for uploading directly, so for larger CloudBioLinux | |
| box images we need to use boto's multipart file support. | |
| This parallelizes the task over available cores using multiprocessing. | |
| Usage: | |
| s3_multipart_upload.py <file_to_transfer> <bucket_name> [<s3_key_name>] |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| Version 2, December 2004 | |
| Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
| Everyone is permitted to copy and distribute verbatim or modified | |
| copies of this license document, and changing it is allowed as long | |
| as the name is changed. | |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |