Skip to content

Instantly share code, notes, and snippets.

View russau's full-sized avatar

Russ Sayers russau

View GitHub Profile
@sm-azure
sm-azure / application.py
Created October 3, 2016 04:15
Elastic beanstalk Python logging
from flask import Flask, abort, request, jsonify, g, url_for, Response, json
from flask_sqlalchemy import SQLAlchemy
from model.billingmodel import db
from model.billingmodel import User, ManagedAccount, VPNTunnel
from flask_login import LoginManager, login_required, logout_user, login_user, current_user
import logging
from logging.handlers import RotatingFileHandler
import base64
logger = logging.getLogger(__name__)
@maxivak
maxivak / _readme.md
Last active June 8, 2022 06:19
Vagrant with Ubuntu 16.04 in VirtualBox

Setup Ubuntu 16.04 to be used with Vagrant and Virtualbox

Prepare Vagrant box with Ubuntu 16.04

We will use official box "ubuntu/xenial64" and modify it to work with Vagrant.

  • Vagrantfile
@pgjones
pgjones / test_flask_cookie.py
Created February 12, 2017 16:00
Example of how to use the Flask `test_request_context` with a cookie set
@robcowie
robcowie / django-uwsgi.ini
Last active March 10, 2023 20:29
Supervisord config examples
[program:uwsgi]
user=robdev
command=uwsgi --ini /path/to/config.uwsgi
autostart=false
@crmccreary
crmccreary / AESCipher.py
Created May 20, 2013 02:17
Encryption using pycrypto, AES, and PKCS5 padding
from Crypto.Cipher import AES
from Crypto import Random
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
class AESCipher:
def __init__( self, key ):
"""
@magnetikonline
magnetikonline / README.md
Last active May 1, 2023 04:43
Python AWS CloudTrail parser class.

Python AWS CloudTrail parser

Python parser class for CloudTrail event archives, previously dumped to an S3 bucket. Class provides an iterator which will:

  • Scan a given directory for archive files matching the required pattern.
  • Decompress each archive in memory.
  • Parse JSON payload and return each event in turn.

Parser contained in cloudtrailparser.py, with timezone.py used as a simple datetime.tzinfo concrete class implement to provide UTC timezone.

@kurokikaze
kurokikaze / gist:350fe1713591641b3b42
Created October 3, 2014 11:40
install chrome from powershell
(new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', 'c:/temp/chrome.exe');. c:/temp/chrome.exe /silent /install;rm c:/temp -rec
@josephkern
josephkern / example_image_utils.py
Last active July 29, 2023 10:44 — forked from turicas/example_image_utils.py
Layer on top of Python Imaging Library (PIL) to write text in images easily
#!/usr/bin/env python
# coding: utf-8
# You need PIL <http://www.pythonware.com/products/pil/> to run this script
# Download unifont.ttf from <http://unifoundry.com/unifont.html> (or use
# any TTF you have)
# Copyright 2011 Álvaro Justen [alvarojusten at gmail dot com]
# License: GPL <http://www.gnu.org/copyleft/gpl.html>
from image_utils import ImageText
@rondomondo
rondomondo / check_jwt_sig.py
Last active February 21, 2024 14:55
Two methods/examples of how to decode and verify the signature of AWS cognito JWT web tokens externally. This uses RSA key pair and alternatively PKCS1_v1_5. See https://gist.github.com/rondomondo/efff911f2c41c295e23415e94e12b8d3 for example of signing and verification by downloading an ISSUERS PKI SSL certificate from the signers website, and h…
#!/usr/bin/env python
import os
import time
import json
import base64
import requests
import argparse
from base64 import urlsafe_b64decode, b64decode
from Crypto.Hash import SHA256, SHA512
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying