Skip to content

Instantly share code, notes, and snippets.

View cmattoon's full-sized avatar

Curtis Mattoon cmattoon

View GitHub Profile
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS current_statement_in_blocking_process
FROM pg_catalog.pg_locks blocked_locks
JOIN pg_catalog.pg_stat_activity blocked_activity
ON blocked_activity.pid = blocked_locks.pid
JOIN pg_catalog.pg_locks blocking_locks
@cmattoon
cmattoon / get_acm_certificate.yml
Created September 10, 2019 14:38
Get ACM Certificate with Ansible
---
- hosts: localhost
tasks:
- name: Get ACM Certificates
shell: aws acm list-certificates --region=us-east-1
register: acm
- name: Set ACM Certificate
set_fact:
acm_arn: "{{ item.CertificateArn }}"
@cmattoon
cmattoon / Makefile.docker
Last active April 13, 2019 13:29
Makefile Templates
.DEFAULT_GOAL := help
.PHONY:
PROJECT_NAME = foo-bar
PROJECT_NS = cmattoon
GIT_REPO ?= $(PROJECT_NS)/$(PROJECT_NAME)
GIT_URL ?= git@github.com/$(GIT_REPO).git
VCS_REF = $(strip $(shell git describe --tags --dirty --always))
@cmattoon
cmattoon / fabfile.py
Created February 14, 2019 00:48
CVE-2019-5736 - Apply patch with Fabric
#!/usr/bin/env python
import os
from fabric import Connection
# kubectl get nodes | grep ip | cut -d'-' -f2,3,4,5 | cut -d'.' -f1 | sed 's/-/./g' | xargs echo | sed s'/ /",\"/g'
def getConnection(host):
return Connection(host=host,
user='admin',
connect_kwargs={
@cmattoon
cmattoon / Actual1
Last active September 24, 2018 16:08
Boat Wiring - Falstad
$ 1 0.000005 10.20027730826997 50 5 50
v 224 96 224 176 0 1 40 5 0 0 0.5
v 224 224 224 304 0 1 40 5 0 0 0.5
w 448 160 448 176 0
w 448 176 448 192 0
w 448 192 448 208 0
s 480 160 560 160 0 1 false
s 480 176 560 176 0 1 false
s 480 208 560 208 0 1 false
s 480 192 560 192 0 1 false
@cmattoon
cmattoon / route_tables.py
Created September 7, 2018 21:34
Graph AWS Route Tables
#!/usr/bin/env python
"""
./route_tables.py | dot -Tpng > routes.png
"""
import boto3
def get_tag(obj, key, default=''):
for tag in obj['Tags']:
if tag['Key'] == key:
return tag['Value']
@cmattoon
cmattoon / conf--app.conf
Created July 11, 2018 23:53
dir2cm example
[app]
config_value = true
[db]
host = localhost
port = 1234
user = root
pass = toor
"""
Allows one to handle *args and **kwargs together in an intuitive way:
api.create_thing('my-thing', 'property-1', 'property-2')
or
api.create_thing('my-thing', prop2='property-2')
or
api.create_thing(**config)
@cmattoon
cmattoon / fission_router_config.sh
Created February 21, 2018 15:42
Configure Fission Router
#!/bin/bash
# fission.io router config for CoreOS
# v0.1.0
#
# Usage:
# source fission_router_config.sh
# Or:
# eval $(./fission_router_config.sh)
ports=$(kubectl -n fission get svc | grep -e 'controller\|router' | cut -d: -f 2 | cut -d/ -f 1 | xargs echo)
@cmattoon
cmattoon / k8s-svc-annotations.md
Created January 23, 2018 22:04 — forked from mgoodness/k8s-svc-annotations.md
AWS ELB-related annotations for Kubernetes Services (v1.5)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval (in minutes)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-enabled (true|false)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-name
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-prefix
  • service.beta.kubernetes.io/aws-load-balancer-backend-protocol (http|https|ssl|tcp)
  • service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled (true|false)
  • service.beta.kubernetes.io/aws-load-balancer-connection-draining-timeout (in seconds)