Skip to content

Instantly share code, notes, and snippets.

:octocat:
🐘 🐇 🐍

Gavin M. Roy gmr

:octocat:
🐘 🐇 🐍
Block or report user

Report or block gmr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View redirect-list.sql
CREATE OR REPLACE VIEW redirect_list AS
WITH RECURSIVE recursive_url_relationships (job_id, source, source_url, target, target_url, redirect) AS
(SELECT a.job_id,
a.source,
b.value AS source_url,
a.target,
c.value AS target_url,
a.redirect
FROM url_relationships AS a
JOIN urls AS b ON b.id = a.source
View pglifecycle-table.json
{
"$schema": "http://json-schema.org/schema#",
"$id": "https://pglifecycle.readthedocs.io/en/stable/schemata/table.html",
"title": "Table",
"description": "Defines a table",
"type": "object",
"properties": {
"name": {
"title": "Name",
"description": "The table name",
@gmr
gmr / 1-example.py
Last active Jun 4, 2019
Example usage of pgdumplib to read data from a pg_dump file
View 1-example.py
import pgdumplib
dump = pgdumplib.load('build/data/dump.compressed')
print('# Header: {}'.format(dump.toc.header))
print('# Database: {}'.format(dump.toc.dbname))
print('# Archive Timestamp: {}'.format(dump.toc.timestamp))
print('# Server Version: {}'.format(dump.toc.server_version))
print('# Dump Version: {}'.format(dump.toc.dump_version))
View download.py
import gzip
import requests
r = requests.get('http://data.dot.state.mn.us/iris_xml/incident.xml.gz')
with open('incident.xml', 'w') as handle:
handle.write(gzip.decompress(r.content).decode('utf-8'))
@gmr
gmr / s3-strip-object-tags.py
Created Aug 29, 2018
Small Python CLI application for removing any object tags from all objects in a bucket
View s3-strip-object-tags.py
#!/usr/bin/env python3
import argparse
import logging
import sys
import boto3
LOGGER = logging.getLogger(__name__)
@gmr
gmr / table_sizes.sql
Last active Feb 6, 2018
A PostgreSQL view that combines the relation size, the size of its indexes, the size of its toast table, and the size of the toast table indexes, combines them to give you a total table size.
View table_sizes.sql
CREATE OR REPLACE VIEW public.table_sizes AS
WITH tables AS (
SELECT a.oid, b.nspname, a.relname, a.reltoastrelid, pg_relation_size(a.oid) AS size
FROM pg_class AS a
JOIN pg_namespace AS b ON b.oid = a.relnamespace
WHERE a.relkind = 'r'
AND b.nspname NOT IN ('pg_catalog', 'information_schema')),
indexes AS (
SELECT i.oid, n.nspname, i.relname AS idxname, c.oid AS reloid, c.relname AS relname,
pg_relation_size(i.oid) AS size
View gist:3c28c9e3a71f5ef9fd83f1867fa6f11f
Time: 3198.725 ms (00:03.199)
Time: 6887.960 ms (00:06.888)
Time: 10622.234 ms (00:10.622)
Time: 13110.130 ms (00:13.110)
Time: 21388.449 ms (00:21.388)
Time: 24127.707 ms (00:24.128)
Time: 28515.858 ms (00:28.516)
Time: 32666.766 ms (00:32.667)
@gmr
gmr / rabbitmq-autocluster_k8s_persistent.bash
Created Jan 10, 2018 — forked from pmint93/rabbitmq-autocluster_k8s_persistent.bash
Deploy rabbitmq-autocluster on k8s with persistent storage (EBS)
View rabbitmq-autocluster_k8s_persistent.bash
#!/bin/bash
set -eo pipefail
export KUBE_NAMESPACE=test
export REPLICA_COUNT=3
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1beta1
kind: StatefulSet
View gist:bbc2ed6bdf79c6b6f82aa13bdd9f35de
2017/11/29 14:20:09.628249 [INFO] envconsul v0.7.2 (a508c43)
2017/11/29 14:20:09.629523 [INFO] (runner) creating new runner (once: false)
2017/11/29 14:20:09.630590 [DEBUG] (runner) final config: {"Consul":{"Address":"127.0.0.1:8500","Auth":{"Enabled":false,"Username":"","Password":""},"Retry":{"Attempts":12,"Backoff":1000000000,"MaxBackoff":120000000000,"Enabled":true},"SSL":{"CaCert":"","CaPath":"","Cert":"","Enabled":false,"Key":"","ServerName":"","Verify":true},"Token":"","Transport":{"DialKeepAlive":30000000000,"DialTimeout":30000000000,"DisableKeepAlives":false,"IdleConnTimeout":90000000000,"MaxIdleConns":100,"MaxIdleConnsPerHost":2,"TLSHandshakeTimeout":10000000000}},"Exec":{"Command":"/usr/local/bin/test-script.sh","Enabled":true,"Env":{"Blacklist":[],"Custom":["CUSTOM_ENV_VAR=FOUND","PATH=$PATH:/etc/myapp/bin"],"Pristine":false,"Whitelist":[]},"KillSignal":15,"KillTimeout":5000000000,"ReloadSignal":null,"Splay":5000000000,"Timeout":0},"KillSignal":2,"LogLevel":"debug","MaxStale":60000000000,"PidFile"
View example.vcl
director autodirector_ random {
{
.backend = F_us_east_1_assets_aweberstage_com;
.weight = 100;
}{
.backend = F_us_west_1_assets_aweberstage_com;
.weight = 100;
}
}
You can’t perform that action at this time.