Skip to content

Instantly share code, notes, and snippets.

View immanuelpotter's full-sized avatar

Immanuel Potter immanuelpotter

View GitHub Profile
@immanuelpotter
immanuelpotter / cleanup.sh
Created December 6, 2023 09:33
Remove dangling resources that can affect terraform after nuking an AWS account.
#!/bin/bash
set -e
workspace="$1"
environment="$2"
state_bucket="${3:-terraform-state-bucket}"
usage(){
echo "Usage: $0 [workspace_name] [environment_name] (state_bucket_optional)"
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"lambda:CreateFunctionUrlConfig",
"lambda:UpdateFunctionUrlConfig"
],
"Resource": "arn:aws:lambda:*:*:function:*",
@immanuelpotter
immanuelpotter / .npmignore
Last active April 30, 2021 08:23
packer-cleanup-serverless
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
@immanuelpotter
immanuelpotter / copy-to-icloud.sh
Last active December 24, 2020 17:19
copy-to-icloud.sh
#!/bin/bash
usage() {
echo "$0 [SRC] [DST]"
echo "Example iCloud path: /Users/$(whoami)/Library/Mobile Documents/com~apple~CloudDocs/"
exit 99
}
[[ -z "$1" || -z "$2" ]] && usage
@immanuelpotter
immanuelpotter / export-findings.sh
Last active December 16, 2020 15:50
aws-securityhub-export-findings
#!/bin/bash
# Reads a list of profile names from a file in the local directory. Example provided.
set -e
# If a profiles.txt file doesn't exist in the current dir, fail.
[[ -f profiles.txt ]] && echo "profiles.txt found, continuing..." || echo "Please provide a profiles.txt with profile names separated by new lines."
@immanuelpotter
immanuelpotter / totp_now.py
Created September 15, 2020 09:26
Get MFA code for a TOTP String, right now
#!/usr/bin/env python
# https://github.com/pyotp/pyotp
import pyotp
import argparse
parser = argparse.ArgumentParser(description='Get the TOTP code, for an MFA string, right now.')
parser.add_argument('mfa_string', metavar='mfa_string', type=str, help='The MFA string to get the current totp code for.')
args = parser.parse_args()
@immanuelpotter
immanuelpotter / .zshrc
Last active July 26, 2023 10:14
.zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/$(whoami)/.oh-my-zsh"
HISTFILE=~/.zsh_history
# Keep history, forever
HISTSIZE=999999999
SAVEHIST=$HISTSIZE
# Set name of the theme to load --- if set to "random", it will
@immanuelpotter
immanuelpotter / azure_sb_read_message.py
Created May 28, 2020 16:11
Sending & receiving messages from Azure ServiceBus.
#!/usr/bin/env python
from azure.servicebus import QueueClient, Message
import sys, os
def main():
if 'SERVICEBUS_CONN_STRING' in os.environ:
connection_string = os.getenv("SERVICEBUS_CONN_STRING")
else:
print("Please provide connection string as envvar: SERVICEBUS_CONN_STRING")
@immanuelpotter
immanuelpotter / token-test.py
Last active April 24, 2020 13:43
Testing out PAT tokens can hit required endpoints they need to get to in Azure DevOps.
#!/usr/bin/env python
import requests
import sys
import pprint
import base64
def encode_string(token):
to_encode_string = "Basic:" + token
encoded_str = base64.b64encode(to_encode_string.encode()).decode('utf-8')
@immanuelpotter
immanuelpotter / tpc-h-amazonlinux.sh
Last active February 11, 2020 21:01
Scripting dataset generation using TPC-H toolset in amazon linux, for a record of how it was done
#!/bin/bash
# Ensure an S3 full access role is attached.
# Install TPC-H benchmarking tools on an rpm-based Linux machine, and generate two datasets: 10GB and 40GB of tabular data respectively.
# Create a bucket for storage of the generated data and upload to S3.
# Install tools
sudo yum install -y make git gcc
git clone https://github.com/gregrahn/tpch-kit