Skip to content

Instantly share code, notes, and snippets.

🙈
Taking care of my kid

Matt Wright mattupstate

🙈
Taking care of my kid
Block or report user

Report or block mattupstate

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
@mattupstate
mattupstate / resources.tf
Last active Sep 29, 2019
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 / 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 / as_blueprint.py
Last active Aug 27, 2019
An `as_blueprint` method for Flask MethodView classes
View as_blueprint.py
from flask import Flask, Blueprint
from flask.views import MethodView
class ApiResource(MethodView):
endpoint = None
url_prefix = None
url_rules = {}
@classmethod
@mattupstate
mattupstate / uuid_url64.py
Last active Jul 9, 2019
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 / Scale to Fit.jsx
Created Aug 22, 2012
Photoshop script to scale an image to fill a specified rectangle and preserve aspect ratio. Save this in <Photoshop Install Folder>/Presets/Scripts and restart Photoshop.
View Scale to Fit.jsx
#target photoshop
main ();
function cloneRectangle(rect) {
return { x:rect.x, y:rect.y, width:rect.width, height:rect.height };
}
function rectangle(x, y, width, height) {
return { x:x, y:y, width:width, height:height };
@mattupstate
mattupstate / put-s3-bucket-notification-configuration
Last active Nov 29, 2018
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 / 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 / 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 / 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 / consul-ssh-configurator.py
Last active Jul 2, 2018
A script to generate an SSH config from Consul's HTTP API
View consul-ssh-configurator.py
#!/usr/bin/env python3
"""
Renders a partial SSH configuration file from Nodes and Services
located in a specified Consul catalog and then merges other partial
config files into the main ~/.ssh/config file. The Consul based SSH
config follows a convention for the SSH host::
Host <consul-cluster-name>-<service-name>-<node-address>
User <ssh-user>
Hostname <consul-node-address>
You can’t perform that action at this time.