Skip to content

Instantly share code, notes, and snippets.

View MattHealy's full-sized avatar

Matt Healy MattHealy

View GitHub Profile
@MattHealy
MattHealy / supervisord
Last active September 28, 2015 03:42
An Init script for supervisord running on AWS EC2 Linux AMI
#!/bin/bash
#
# supervisord This scripts turns supervisord on
#
# Author: Mike McGrath <mmcgrath@redhat.com> (based off yumupdatesd)
# Jason Koppe <jkoppe@indeed.com> adjusted to read sysconfig,
# use supervisord tools to start/stop, conditionally wait
# for child processes to shutdown, and startup later
# Mikhail Mingalev <mingalevme@gmail.com> Merged
# redhat-init-jkoppe and redhat-sysconfig-jkoppe, and
@MattHealy
MattHealy / backup-s3.cgi
Created November 27, 2015 07:24
Simple Perl script to mirror a website to Amazon S3
#!/usr/bin/perl
($sec,$min,$hour,$mday,$mon,$year,$nothing,$nothing,$nothing)=localtime(time);
if ($mon<12) {
$mon++;
}
if ($pmon<12) {
$pmon++;
}
@MattHealy
MattHealy / virtual.conf
Created April 24, 2016 03:26
Nginx conf file - example for hosting flask app
server {
listen 80;
server_name my-app.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_connect_timeout 300s;
# Set some HTTP headers so that our app knows where the
# request really came from
proxy_set_header Host $host;
@MattHealy
MattHealy / mariadb_check_restart.sh
Last active April 26, 2016 09:14
Check if MySQL/MariaDB is down, and if so, restart it.
#!/bin/sh
PORT=3306
HP=:$PORT
echo 'Checking to see if MariaDB is up...'
if ( /usr/sbin/lsof -Pni $HP | grep "$PORT (LISTEN)" 2>&1 >/dev/null ); then
echo 'MariaDB is up';
else
echo 'MariaDB is down, restarting...';
/sbin/service mariadb restart
fi
@MattHealy
MattHealy / siecje.py
Created May 2, 2016 07:16 — forked from doobeh/example.html
Checkbox WTForms Example (in Flask)
from flask import Flask, render_template
from flask.ext.wtf import Form, widgets, SelectMultipleField
SECRET_KEY = 'development'
app = Flask(__name__)
app.config.from_object(__name__)
class MultiCheckboxField(SelectMultipleField):
widget = widgets.ListWidget(prefix_label=False)
@MattHealy
MattHealy / install-redis.sh
Created May 11, 2016 11:50 — forked from four43/install-redis.sh
Install Redis
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://gist.githubusercontent.com/four43/e00d01ca084c5972f229/raw/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@MattHealy
MattHealy / landing-page.html
Created May 29, 2016 07:29
Boilerplate for a basic landing page consisting of an image.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My awesome site!</title>
<style type="text/css">
html {
width:100%;
height:100%;
background:url(logo.png) center center no-repeat;
@MattHealy
MattHealy / AESCipher.py
Created May 29, 2016 13:06 — forked from swinton/AESCipher.py
Encrypt & Decrypt using PyCrypto AES 256 From http://stackoverflow.com/a/12525165/119849
#!/usr/bin/env python
import base64
from Crypto import Random
from Crypto.Cipher import AES
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
@MattHealy
MattHealy / README.md
Created August 7, 2016 02:11 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


Index:

@MattHealy
MattHealy / envelope_encryption_kms_boto_pycrypto.md
Created August 7, 2016 11:57 — forked from pmp/envelope_encryption_kms_boto_pycrypto.md
Envelope Encryption using AWS KMS, Python Boto, and PyCrypto.

If you use Amazon AWS for nearly anything, then you are probably familiar with KMS, the Amazon Key Management Service.

KMS is a service which allows API-level access to cryptographic primitives without the expense and complexity of a full-fledged HSM or CloudHSM implementation. There are trade-offs in that the key material does reside on servers rather than tamper-proof devices, but these risks should be acceptable to a wide range of customers based on the care Amazon has put into the product. You should perform your own diligence on whether KMS is appropriate for your environment. If the security profile is not adequate, you should consider a stronger product such as CloudHSM or managing your own HSM solutions.

The goal here is to provide some introductory code on how to perform envelope encrypt a message using the AWS KMS API.

KMS allows you to encrypt messages of up to 4kb in size directly using the encrypt()/decrypt() API. To exceed these limitations, you must use a technique called "envelope encryptio