This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| git diff | git apply --whitespace=fix | |
| git diff --cached | git apply --cached --whitespace=fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' | |
| Calculate AWS Fargate pricing | |
| ''' | |
| import argparse | |
| import logging | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format='%(asctime)s %(levelname)s %(message)s' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' | |
| Convert an image to ASCII art | |
| ''' | |
| import argparse | |
| from PIL import Image | |
| # pylint: disable=redefined-outer-name | |
| def main(args): | |
| ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' | |
| .. :: | |
| .:.:=;. | |
| .: ;;;. . | |
| ...=:;:..:?:.:. | |
| .;;=;=====;;*=. | |
| ..::;;;========;?=. | |
| .;;;;;;=======;==;. | |
| .:;;;;;;==**==?SSZ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 //' | |
| ) |
NewerOlder