Skip to content

Instantly share code, notes, and snippets.

View phwelo's full-sized avatar
🌈

Daniel Agans phwelo

🌈
View GitHub Profile
### Keybase proof
I hereby claim:
* I am phwelo on github.
* I am danielagans (https://keybase.io/danielagans) on keybase.
* I have a public key ASDaF1ApciS6XJOX4e9-o8LXVl-YYW3-pOUWu4xSB1Ezqgo
To claim this, I am signing this object:
@phwelo
phwelo / public_instances.py
Created August 11, 2022 14:43
Public Instances - List any EC2 instances that have a public address associated
#!/usr/bin/env python3
import boto3
import json
client = boto3.client('ec2')
ec2_result = client.describe_instances()
results = []
for result in ec2_result["Reservations"]:
@phwelo
phwelo / inline_policies.py
Created August 11, 2022 14:42
List any inline IAM policies
#!/usr/bin/env python3
import boto3
client = boto3.client('iam')
# three different calls to get inline-policy on all IAM items:
# list_groups - get_group_policy
# list_roles - get_role_policy
# list_users - get_user_policy
@phwelo
phwelo / imdsv2_all_instances.py
Created August 11, 2022 14:41
IMDSv2 for everything - Set metadata to IMDSv2 for all of your ec2 instances
#!/usr/bin/env python3
import boto3
client = boto3.client('ec2')
def set_imdsv2_required(instance_id):
client.modify_instance_metadata_options(
InstanceId=instance_id,
HttpTokens='required',
@phwelo
phwelo / higlight.py
Created August 11, 2022 14:39
Highlight - Simple grep tool that highlights instead of displaying only results
#!/usr/bin/env python3
from colorama import init, Fore, Back, Style
import sys
import argparse
init(autoreset=True)
what_color = Fore.BLACK + Back.WHITE
parser = argparse.ArgumentParser(exit_on_error=False)
@phwelo
phwelo / space_heater.py
Created January 12, 2022 22:36
Low is too high, so I'll try and turn it on and off at a frequency that leaves me comfortable...
#!/usr/bin/env python3
import argparse, atexit, os, subprocess, time
from datetime import datetime
tmpfile = "/tmp/heaterstate"
# it's going to be nicer to have this switch off when the script is killed
def exit_handler():
set_switch(args.ip, "off")
#!/usr/bin/env python3
import requests
from bs4 import BeautifulSoup
import json
import sys
import transposer
import argparse
# transpose(source_chord, direction, to_key)
@phwelo
phwelo / rando.py
Created October 25, 2021 19:53
Random Curseforge Modpack Chooser, Static Minecraft Version 17.1, static pages count of 10
#!/usr/bin/env python3
import requests
import json
import random
import webbrowser
import sys
# This is a query for 1.17.1 modpacks
base_searchpage = "https://www.modpackindex.com/api/v1/minecraft/version/71/modpacks?limit=100&page="
@phwelo
phwelo / cidr.py
Created October 20, 2021 18:44
Simple tool to prevent me needing to remember bit to range conversions. accepts single param of cidr in 10.0.0.0/32 format
#!/usr/bin/env python3
import sys
import ipaddress
CYAN = '\033[96m'
END = '\033[0m'
BOLD = '\033[1m'
if len(sys.argv) < 2:
@phwelo
phwelo / config.json
Last active September 10, 2022 17:11
Per-Display Workspace Toggler
[
{"name": "eDP-1", "workspaces": [1, 5]},
{"name": "DP-1", "workspaces": [3, 4]},
{"name": "HDMI-A-1", "workspaces": [2, 6, 7]}
]