Skip to content

Instantly share code, notes, and snippets.

admin1234
#!/bin/bash
#
# Compiles a Python package into a zip deployable on AWS Lambda
#
# - Builds Python dependencies into the package, using a Docker image to correctly build native extensions
# - Strip shared object files for smaller size ca. 20% reduction
# - Remove .py and use .pyc's = faster lambda and ca. 20% reduction
# - Remove tests, info (minor reduction, but why not)
# - Remove packages that will be available in AWS lambda env anyway (boto et al) ca. 50mb (uncompressed) reduction
# - Able to be used with the terraform-aws-lambda module
@rdkls
rdkls / aws-ssm-ec2-proxy-command.sh
Last active October 20, 2022 01:07
AWS SSM SSH ProxyCommand
#!/usr/bin/env bash
#
# Description
# Bootstrap SSH Session to an SSM-managed instance
# by temporarily adding a public SSH key available on the local machine (ssh-agent or in ~/.ssh)
#
#
# Installation
#
# First run your eye over this script to check for malicious code
HTTP -> HTTPS
socat -v TCP4-LISTEN:443,reuseaddr,fork OPENSSL-CONNECT:20.190.142.66:443,verify=0
#!/usr/bin/env python
# Generate config file for chrome extension "aws-extend-switch-roles"
# https://github.com/tilfin/aws-extend-switch-roles
import boto3
import argparse
import hashlib
from pprint import pprint
parser = argparse.ArgumentParser()
(cd ~/; git clone --recursive https://github.com/jessfraz/.vim.git .vim; ln -sf $HOME/.vim/vimrc $HOME/.vimrc; cd $HOME/.vim; git submodule update --init)
#!/usr/bin/env python
import zipfile
from itertools import product
filename = 'certs-20190403.zip'
pwd_len = 6
from string import digits, ascii_uppercase, ascii_lowercase
@rdkls
rdkls / generate-ssl-cert.sh
Created October 18, 2018 22:38
Generate SSL Cert
#!/bin/bash
FILENAME=wnea
STATE=VIC
LOCALITY=Melbourne
ORG=Vandelay
OU=WNEA
CN=wnea.sdpamp.internal
openssl genrsa -out $FILENAME.key
openssl req -new -key $FILENAME.key -x509 -days 3653 -out $FILENAME.crt -subj "/C=AU/ST=$STATE/L=$LOCALITY/O=$ORG/OU=$OU/CN=$CN"
#!/usr/bin/env python
# Store an Ansible vault credential in specified Tower instance
# Code: https://github.com/ansible/tower-cli
# Doc: https://tower-cli.readthedocs.io/en/latest/
import argparse
import tower_cli
from tower_cli import get_resource
from tower_cli.conf import settings
from pprint import pprint
@rdkls
rdkls / .vimrc
Created September 10, 2018 05:31
.vimrc settings for python-mode long lines
let g:pymode_options_max_line_length = 120
let g:pymode_lint_options_pep8 = {'max_line_length': g:pymode_options_max_line_length}
let g:pymode_options_colorcolumn = 1