Skip to content

Instantly share code, notes, and snippets.

View triangletodd's full-sized avatar

Todd Edwards triangletodd

View GitHub Profile
@triangletodd
triangletodd / cloudflare.inc.sh
Created November 5, 2019 06:35
Bash functions for interacting with the Cloudflare v4 API
#!/usr/bin/env bash
export CF_CURL_OPTS=()
export CF_V4_API='https://api.cloudflare.com/client/v4'
_cf_exit() {
# if being called directly, don't exit
if [ ${#FUNCNAME[@]} -eq 0 ]; then
return 1
fi
exit 1
@triangletodd
triangletodd / feature_flipper.rb
Last active December 12, 2020 22:41
Ruby Feature Flipper
#!/usr/bin/env ruby
require 'redis'
require 'flipper'
require 'flipper/adapters/redis'
class Feature
ENABLED = Flipper::Actor.new(true)
DISABLED = Flipper::Actor.new(false)
def initialize
@triangletodd
triangletodd / gcr_cleanup.sh
Last active May 24, 2019 09:40
GCR Image Cleanup - list or delete all but the 5 newest tags for all images in a GCR repository
#!/usr/bin/env bash
# Exit if no arguments are passed
if [ $# -lt 1 ]; then
cat << HELP
gcr_cleanup -- list or delete all but the 5 newest tags for all images
EXAMPLE:
- list all but the 5 newest tags for all images
@triangletodd
triangletodd / k8s_secret.code-snippets.json
Last active May 24, 2019 09:42
VSCode Kubernetes Snippets
{
"k8s_secret": {
"prefix": "k8s_secret",
"scope": "plaintext,yaml",
"body": [
"apiVersion: v1",
"kind: Secret",
"metadata:",
" name: ${1:secret_name}",
"type: Opaque",
@triangletodd
triangletodd / Chassis.stl
Last active December 12, 2020 22:44
Wifi Pineapple Quad
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@triangletodd
triangletodd / sparse_clone.sh
Created February 28, 2019 22:06
Sparse git clone (clone a single subdirectory from a repo)
mkdir config
cd config
git init
git remote add -f origin https://github.com/cockroachdb/cockroach
git config core.sparseCheckout true
echo "cloud/kubernetes" >> .git/info/sparse-checkout
git pull origin master
@triangletodd
triangletodd / create_pdbs.sh
Last active February 27, 2019 23:48
Create a PDB for all deployments in the default Kubernetes namespace with a minAvailable of 50%
#!/usr/bin/env bash
set -e
template() {
cat <<EOF
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: {{NAME}}
namespace: default
@triangletodd
triangletodd / working_verify_slack.go
Created February 7, 2019 23:29
Golang Verify Slack
package middlewares
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"github.com/gin-gonic/gin"
)
@triangletodd
triangletodd / .bash_colors
Created December 13, 2018 19:16
Bash Colors
#!/usr/bin/env bash
#░█ ██ ██
#░█ ░██ ░░
#░█ █████ ██████ ░██ ██████ ██████ ██ ██████ █████
#░█ ██░░░██ ██░░░░██ ░██ ██░░░░██░░██░░█░██░░░░██ ██░░░██
#░█ ░██ ░░ ░██ ░██ ░██░██ ░██ ░██ ░ ░██ ██ ░███████
#░█ ░██ ██░██ ░██ ░██░██ ░██ ░██ ░██ ██ ░██░░░░
#░█ ░░█████ ░░██████ ███░░██████ ░███ ░██ ██████░░██████
#░█ ░░░░░ ░░░░░░ ░░░ ░░░░░░ ░░░ ░░ ░░░░░░ ░░░░░░
@triangletodd
triangletodd / README.md
Last active August 6, 2018 17:33 — forked from adambom/README.md
Backup Kubernetes Cluster State

Run this in order to backup all you k8s cluster data. It will be saved in a folder bkp. To restore the cluster, you can run kubectl apply -f bkp.

Please note: this recovers all resources correctly, including dynamically generated PV's. However, it will not recover ELB endpoints. You will need to update any DNS entries manually, and manually remove the old ELB's.

Please note: This has not been tested with all resource types. Supported resource types include:

  • services
  • replicationcontrollers
  • secrets
  • deployments
  • horizontal pod autoscalers