Skip to content

Instantly share code, notes, and snippets.

@kg6zjl
kg6zjl / git_aliases_functions
Last active May 24, 2024 18:21
All of my favorite git related aliases and functions
function git_master_branch() {
if [[ $(git branch -a | grep 'origin/main') = *origin/main* ]]; then
master_branch="main"
else
master_branch="master"
fi
}
function git_branch() {
branch="$(git branch 2> /dev/null | sed -e '/^[^*]/d' | tr -d '* ')"
#!/usr/bin/env python3
from diffusers import StableDiffusionPipeline
import torch
import random
import string
import time
def save_image(image, name, count):
image.save(f"C:/stable-diffusion/images/{name}-{count}.png")

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@kg6zjl
kg6zjl / .bash_profile
Created February 23, 2019 14:13
Create env vars from single section of ~/.aws/credentials, and set as default.
function activate() { #choose aws creds to push to env vars (example: activate sre-dev)
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_SESSION_TOKEN AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID AWS_SECURITY_TOKEN
eval $(python3 $HOME/git/dotfiles/files/python-ini.py $HOME/.aws/credentials $1)
}
@kg6zjl
kg6zjl / spare_the_air.py
Last active September 22, 2020 23:46
Pulls the rss feed from Bay Area Air Quality Management District (BAAQMD) to monitor "Spare the Air" / "No Burn Days"
#!/usr/bin/python3
import requests
import xmltodict
rss_feed = "http://www.baaqmd.gov/Feeds/AlertRSS.aspx"
def fetch_feed(url):
r = requests.get(url)
return r.text.strip()
@kg6zjl
kg6zjl / rancher_ssh.sh
Last active January 11, 2019 19:20
SSH into Rancher Kubernetes Node
#!/usr/bin/env bash
#usage: rancher_ssh.sh node:id
#example: rancher_ssh.sh c-5581v:m-ghv14
#requirements: jq, curl
TOKEN="bearer token"
RANCHER_URL="set or use env var including api version, example: `https://rancher.dev/v3`"
function rssh() {
@kg6zjl
kg6zjl / add-keys.sh
Created December 13, 2018 23:32
Bash/Expect to add password protected ssh keys to agent, using creds from credstash
#!/usr/bin/env bash
function ssh-keys () {
if ssh-add -l | grep -q "$1"; then
echo "$1 key is ready"
else
/usr/bin/expect -c "
spawn /usr/bin/ssh-add $1;
expect 'Enter passphrase';
send $2\r;
# encoding=utf8
from __future__ import print_function
import requests
from bs4 import BeautifulSoup
url = "https://status.aws.amazon.com/"
allGreen = True
r = requests.get(url)
@kg6zjl
kg6zjl / split_text_file.txt
Last active June 22, 2016 19:59
Split a text file in half by line
f=$"download.sh"; s=$(wc -l $f | awk '{print $1}'); \
h=$(echo "scale=0;" $(($s/2+1)) | bc -q); \
split -l $h $f "output_"; for file in output_*; \
do mv "$file" "$file.sh"; done; \
for f in output_*.sh; do bash $f & done;