Skip to content

Instantly share code, notes, and snippets.

View unacceptable's full-sized avatar
👑
Strange women lying in ponds distributing swords is no basis for a system of ...

Robert J. unacceptable

👑
Strange women lying in ponds distributing swords is no basis for a system of ...
View GitHub Profile
#!/usr/bin/env bash
set -e
git diff | git apply --whitespace=fix
git diff --cached | git apply --cached --whitespace=fix
def pi(n_terms: int) -> float:
'''
Approximate pi using the Leibniz formula
'''
series = [
(-1)**k / (2*k + 1) for k in range(n_terms)
]
pi_approx = 4*(
sum(series)
#!/usr/bin/env python3
'''
Generate a graph of the real returns of the S&P 500
'''
import logging
import yfinance as yf
import pandas as pd
import requests
# macos
ssh-keygen -t rsa -b 4096 -E SHA512 -m PEM -f ~/my.jwt.RS512.pem
# pip install pyjwt
python <<PYTHON
import os
import logging
import jwt
#!/usr/bin/env python
'''
Calculate AWS Fargate pricing
'''
import argparse
import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s'
#!/usr/bin/env python
'''
Convert an image to ASCII art
'''
import argparse
from PIL import Image
# pylint: disable=redefined-outer-name
def main(args):
'''
#!/usr/bin/env python
'''
.. ::
.:.:=;.
.: ;;;. .
...=:;:..:?:.:.
.;;=;=====;;*=.
..::;;;========;?=.
.;;;;;;=======;==;.
.:;;;;;;==**==?SSZ;
#!/usr/bin/env bash
set -e
watch_dns(){
HOST=$1
DNS_SERVER=${2:-"8.8.8.8"}
OLD_IP="$(dig +short "$HOST")"
echo "$(date) Starting to watch $HOST for changes from \"$OLD_IP\" as tracked by ${DNS_SERVER}"
#!/usr/bin/env python
'''
This script will check for instances with tags "start", "shutdown" or "restart"
and will start, stop or restart them based on the time specified in the tag value
relative to the past execution.
'''
import json
import logging
import time
while read -r AWS_PROFILE; do
for CLUSTER in $(aws eks list-clusters --profile "$AWS_PROFILE" --query clusters --output text); do
aws eks update-kubeconfig --name "$CLUSTER" --profile "$AWS_PROFILE"
done
done < <(
grep "^\[.*\]$" ~/.aws/credentials | sed 's/\[//;s/\]//;s/profile //'
)