Skip to content

Instantly share code, notes, and snippets.

Avatar
🙈
Taking care of my kid

Matt Wright mattupstate

🙈
Taking care of my kid
View GitHub Profile
@mattupstate
mattupstate / resources.tf
Last active Jul 21, 2020
Just a clever way to set an RDS master password with Terraform and Ansible to prevent the password from being stored in plain text
View resources.tf
resource "aws_db_instance" "core" {
username = "postgres"
password = "changeme"
...
}
resource "null_resource" "master_password" {
triggers {
db_host = "${aws_db_instance.address}"
}
@mattupstate
mattupstate / README.md
Created Nov 13, 2014
An example of how to setup streaming replication for PostgreSQL with Docker.
View README.md

PostgreSQL Streaming Replication With Docker

The *.txt files here hold user and database parameters. Specifically, replication.txt contains the user/role and password to use for replication. Whereas database.txt contains an initial database, user/role and password to create on the master.

Run the master:

$ fig run -d master

Wait for it to start up completely. Start the slave:

@mattupstate
mattupstate / app.py
Created Mar 15, 2012
Flask application configuration using an environment variable and YAML
View app.py
os
from flask_extended import Flask
app = Flask(__name__)
app.config.from_yaml(os.join(app.root_path, 'config.yml'))
@mattupstate
mattupstate / uuid_url64.py
Last active Jul 2, 2020
Generate unique, URL friendly ID's based on UUID with Python
View uuid_url64.py
import re
import uuid
import base64
def uuid_url64():
"""Returns a unique, 16 byte, URL safe ID by combining UUID and Base64
"""
rv = base64.b64encode(uuid.uuid4().bytes).decode('utf-8')
return re.sub(r'[\=\+\/]', lambda m: {'+': '-', '/': '_', '=': ''}[m.group(0)], rv)
@mattupstate
mattupstate / example.py
Created Feb 5, 2015
JSON Patch SQLAlchemy models w/ Flask
View example.py
from dictalchemy import make_class_dictable
from flask import Flask, request, jsonify, json
from flask_sqlalchemy import SQLAlchemy
from jsonpatch import JsonPatch, JsonPatchException
app = Flask(__name__)
app.debug = True
db = SQLAlchemy(app)
make_class_dictable(db.Model)
@mattupstate
mattupstate / gather_stack_outputs.py
Created May 19, 2015
Ansible module to gather a Cloudformation stack outputs into variable scope
View gather_stack_outputs.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
try:
import boto
from boto import cloudformation
HAS_BOTO = True
except ImportError:
HAS_BOTO = False
@mattupstate
mattupstate / helpers.py
Created Jun 25, 2013
Register all Blueprint instances on the specified Flask application found in all modules for the specified package
View helpers.py
# -*- coding: utf-8 -*-
"""
helpers
~~~~~~~
helpers module
"""
import pkgutil
import importlib
@mattupstate
mattupstate / put-s3-bucket-notification-configuration
Last active Jan 14, 2020
Example of how to configure S3 bucket notifications from the command line
View put-s3-bucket-notification-configuration
#!/usr/bin/env python
import argparse
import sys
try:
import boto3
except ImportError:
print('Please install boto3 to use this tool')
sys.exit(1)
@mattupstate
mattupstate / gist:7010498
Created Oct 16, 2013
Flask-Mail Log Handler
View gist:7010498
import logging
from flask_mail import Message
class FlaskMailLogHandler(logging.Handler):
def __init__(self, mail, sender, recipients, subject, *args, **kwargs):
super(FlaskMailLogHandler, self).__init__(*args, **kwargs)
View humio.d.ts
declare module 'humio' {
interface Options {
ssl?: boolean;
host: string;
port: number;
basePath?: string;
dataspaceId?: string;
sessionId?: string;
includeClientMetadata?: boolean;
includeSessionId?: boolean;
You can’t perform that action at this time.