Skip to content

Instantly share code, notes, and snippets.

@mixja
mixja / nlb_securitygroup.py
Last active March 13, 2018 07:32
Network Load Balancer Security Group Provisioner
import sys, os
parent_dir = os.path.abspath(os.path.dirname(__file__))
vendor_dir = os.path.join(parent_dir, 'vendor')
sys.path.append(vendor_dir)
import logging, datetime, json
import boto3
import backoff
from botocore.exceptions import ClientError
from cfn_lambda_handler import Handler
@mixja
mixja / cloudformation_service_role.yml
Last active March 31, 2018 08:31
Creating an S3 Stack using Lambda
# This is a CloudFormation definition of the IAM role required for the CloudFormation Service
# This must include permissions to create/update/delete any resources defined in the stack
CloudFormationServiceRole:
Type: AWS::IAM::Role
Properties:
RoleName: cfn-s3-deployer
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Action:
@mixja
mixja / demo.py
Created January 11, 2018 06:15
Interacting with Jinja Templates
# Requires Jinja2 and Ansible 2.4+ installed
# Assumes you have custom filters
from jinja2 import Template,FileSystemLoader,Environment
# filter_loader includes all Ansible plugins
from ansible.plugins.loader import filter_loader
# Import locally defined filters
filter_loader.add_directory('filter_plugins')
@mixja
mixja / security.json
Last active June 28, 2020 08:20
AWS IAM Policy for MFA
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAllUsersToListAccounts",
"Effect": "Allow",
"Action": [
"iam:ListAccountAliases",
"iam:GetAccountPasswordPolicy",
"iam:ListUsers",
@mixja
mixja / git_zip.py
Created December 21, 2016 03:50
Clone a revision of a Git Repo and create a ZIP file
from dulwich.client import get_transport_and_path
from dulwich.repo import Repo
import shutil
git_url = "https://github.com/dpaws/microtrader.git"
git_revision = "54dcd9f5b557af87ec1132f62b9c6bbdfc01a2f5"
local = Repo.init(b"local", mkdir=True)
client, path = get_transport_and_path(git_url)
remote_refs = client.fetch(path, local, determine_wants=local.object_store.determine_wants_all)
volumes:
registry_data:
external: true
services:
registry:
image: registry:2
ports:
- "5000:5000"
volumes:
@mixja
mixja / Dockerfile
Last active September 17, 2019 11:06
Docker Health Check using Make
FROM nginx
HEALTHCHECK --interval=3s --retries=20 CMD curl -fs http://localhost:${HTTP_PORT:-8000}
@mixja
mixja / pySim-run-gsm.py
Created September 3, 2015 11:24
Reads SIM card and generates EAP-SIM triplets
#!/usr/bin/env python
#
# Utility to run the 2G gsm algorithm on the SIM card
# used to generate authentication triplets for EAP-SIM
#
# Copyright (C) 2009 Sylvain Munaut <[email protected]>
# Copyright (C) 2010 Harald Welte <[email protected]>
# Copyright (C) 2013 Alexander Chemeris <[email protected]>
# Copyright (C) 2013 Darell Tan <[email protected]>
@mixja
mixja / DPDK 2.1.0 I218 Patch
Last active February 16, 2017 16:15
Patch for adding Intel I218 NIC support to DPDK v2.1.0
From f06bb9837eec75fdaa16de0b8b21240724df450d Mon Sep 17 00:00:00 2001
From: Justin Menga <[email protected]>
Date: Tue, 25 Aug 2015 00:56:56 +1200
Subject: [PATCH] Patch for i218 support
---
drivers/net/e1000/base/e1000_api.c | 22 ++++++++++++++++++++++
drivers/net/e1000/base/e1000_api.h | 1 +
drivers/net/e1000/base/e1000_osdep.h | 22 ++++++++++++++++++----
drivers/net/e1000/em_ethdev.c | 7 +++++++