Skip to content

Instantly share code, notes, and snippets.

View phwelo's full-sized avatar
🌈

Daniel Agans phwelo

🌈
View GitHub Profile
@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]}
]
@phwelo
phwelo / gist:c9692bfd8595fe97097538108d98ac50
Created September 30, 2020 23:15
Quick kube switcher
#!/usr/bin/env python3
# HEADS UP: Requires that kubeconfig files be named `config.description`!!!
from iterfzf import iterfzf
import glob
import os
import shutil
searchpath = "/.kube/config.*"
#!/usr/bin/env python3
import socket
import pymysql
username = "A USERNAME"
password = "A REALLY GOOD PASSWORD"
hostname = "SOME HOSTNAME OR IP"
def is_port_open(host, port):
@phwelo
phwelo / parse.py
Last active March 18, 2020 01:30
parse caronavirus data
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import urllib.request, urllib.error, urllib.parse
source_url = 'https://docs.google.com/spreadsheets/u/0/d/e/2PACX-1vR30F8lYP3jG7YOq8es0PBpJIE5yvRVZffOyaqC0GgMBN6yt0Q-NI8pxS7hd1F9dYXnowSC6zpZmW9D/pubhtml/sheet?gid=0'
def get_table_rows(url):
response = urllib.request.urlopen(url)
@phwelo
phwelo / thisthing
Created December 26, 2019 01:31
asdff
#!/usr/bin/env python3
import os
import markdown
from subprocess import Popen, DEVNULL
from rofi import Rofi
r = Rofi()
# Path to data docs
data_dir = 'terraform-provider-aws/website/docs/d'
@phwelo
phwelo / sshd_config
Created December 13, 2019 05:26
default aws sshd
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
@phwelo
phwelo / pr.py
Created October 18, 2019 03:50
Automatically browse to create PR for master/current branch
#!/usr/bin/env python3
import subprocess
BROWSER = "vivaldi-snapshot"
def git_remote_to_url(branch):
remotev = subprocess.check_output(["git", "remote", "-v"]).decode("utf-8")
remote = remotev.split('\t')[1].split(' (fetch)')[0]
url = convert_uri(remote)
@phwelo
phwelo / weathericon.py
Created August 23, 2019 16:45
Pulls geolocation then weatherdata and returns icon and temperature
#!/usr/bin/env python3
import requests
import json
import pyowm
geolocation_api_uri = "http://ip-api.com/json/?fields=49344"
def get_coord():
r = requests.get(geolocation_api_uri)
@phwelo
phwelo / ECS_DD_AGENT.yml
Last active August 22, 2019 20:00
ECS Datadog Agent Yaml Config (For dev)
#########################
## Basic Configuration ##
#########################
site: datadoghq.com
skip_ssl_validation: false
# force_tls_12: false
tags:
- environment:dev
- dd_agent:true