Skip to content

Instantly share code, notes, and snippets.

View triangletodd's full-sized avatar

Todd Edwards triangletodd

View GitHub Profile
@triangletodd
triangletodd / Changelog.yml
Last active August 19, 2016 16:36
Changelog - Class representation of a project's changelog
---
-
version: 5.2.2
version_code: 5000202
changes:
- Fixed an issue where some photo galleries would crash the app
- Photo credits added
- High res photos added to stories
- Other bug fixes
-
@triangletodd
triangletodd / yt
Last active January 5, 2017 20:28
Download and play youtube videos in mplayer with a single command.
#!/usr/bin/env bash
set -e
url="$1"
temp_dir=$(mktemp -d /tmp/yt.XXXXXXXXXXXXX)
validate_url() {
if [ -z $url ]; then
echo 'Usage: yt [url]'
exit 0
@triangletodd
triangletodd / benchmark_bcrypt.rb
Created March 15, 2017 20:12
Benchmarking BCrypt
require 'benchmark'
require 'bcrypt'
(5..15).to_a.each do |i|
bm = Benchmark.measure { BCrypt::Password.create('I have a hairy cat', cost: i) }
puts "cost: #{i} \t #{bm}"
end
#=> cost: 5 0.010000 0.000000 0.010000 ( 0.001988)
#=> cost: 6 0.000000 0.000000 0.000000 ( 0.004081)
@triangletodd
triangletodd / bashorg_cowsay.sh
Created March 21, 2012 09:52
Random quote from bash.org in a random Cowsay template
#!/bin/bash
bashorg=$(curl -s http://bash.org/?random1|grep -oE "<p class=\"quote\">.*</p>.*</p>"|grep -oE "<p class=\"qt.*?</p>"|sed -e 's/<\/p>/\n/g' -e 's/<p class=\"qt\">//g' -e 's/<p class=\"qt\">//g'|perl -ne 'use HTML::Entities;print decode_entities($_),"\n"'|head -1)
files=($(cowsay -l|sed 's#Cow files in /usr/share/cowsay/cows:##'))
num_files=${#files[@]}
cowsay -f "${files[$((RANDOM%num_files))]}" ${bashorg}
unset bashorg files num_files
@triangletodd
triangletodd / 20000_leagues
Last active June 21, 2017 03:25
ASCII Art
__...__
.--""``` ```""--.
':--..___ ___..--:'
\ ``` /
.-` ___.....___ '-.
.:-""`` ~ ~ ``""-:.
/`-..___ ~ ~ ~___..-'\
/ ~ '`""-----""` \
; ;
; '::. ' .:' _. ;
@triangletodd
triangletodd / github_org_backup
Last active November 2, 2017 14:22
Backup your private Github organization.
#!/usr/bin/env bash
set -e
trap cleanup EXIT
cleanup() {
cd "$(dirs -l -0)" && dirs -c
}
setup() {
@triangletodd
triangletodd / Makefile
Created November 21, 2017 23:44
Make OPTS example
SHELL := /usr/bin/env bash
RSYNC_OPTS := -av --exclude-from 'rsync-exclude.list'
RSYNC = rsync $(RSYNC_OPTS)
install :
$(RSYNC) $(PWD)/ $(HOME)/
dryinstall : RSYNC_OPTS += --dry-run
dryinstall : install
@triangletodd
triangletodd / check_apt_updates.sh
Last active June 22, 2018 17:51
Nagios compatible check for pending Ubuntu updates.
#!/bin/sh
#
# Standard Nagios plugin return codes.
STATUS_OK=0
STATUS_WARNING=1
STATUS_CRITICAL=2
STATUS_UNKNOWN=3
# Query pending updates.
updates=$(/usr/lib/update-notifier/apt-check 2>&1)
@triangletodd
triangletodd / check-vertica-certificate.py
Created July 26, 2018 17:02
A Nagios compatible script to check your Vertica SSL certificate expiration.
#!/usr/bin/env python
import argparse
import socket
import ssl
import struct
import subprocess
import sys
from datetime import *
@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