Skip to content

Instantly share code, notes, and snippets.

View waltercool's full-sized avatar

WalterCool waltercool

View GitHub Profile
@waltercool
waltercool / gist:07b66e42f9e66fafaa9945e2a2b88206
Last active February 26, 2019 15:10
Postgresql Backup&Restore
Backup: pg_dump -Fc -f /path/to/backup.dump
Restore: pg_restore -U <USER> -h <HOST> -d <DATABASE> -Fc -Oxc backup.dump
@waltercool
waltercool / enum.py
Created May 17, 2018 15:13 — forked from b1naryth1ef/enum.py
PeeWee Postgres Enum Field
from peewee import *
class BModel(Model):
class Meta:
database = db
@classmethod
def create_table(cls, *args, **kwargs):
for field in cls._meta.get_fields():
if hasattr(field, "pre_field_create"):
@waltercool
waltercool / postgres_queries_and_commands.sql
Created June 9, 2017 16:28 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
  1. Stopping a zombie machine: aws opsworks stop-instance --instance-id <opsworks ID>

  2. Resize root disk on AWS:
    z) partprobe /dev/xvdX
    a) parted /dev/xvdX print
    b) parted /dev/xvdX resizepart Y && resize2fs /dev/xvdXY # resize2fs needed to update the partition table

Update for xfs partitions:

a) growpart /dev/xvda 1