Skip to content

Instantly share code, notes, and snippets.

View triangletodd's full-sized avatar

Todd Edwards triangletodd

View GitHub Profile
@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 / currencies.yml
Created January 23, 2017 20:57
Currencies
---
- :code: AED
:description: UAE Dirham
:notes: "United Arab Emirates"
- :code: AFA
:description: Afghani
:notes: "Afghanistan. DEPRECATED, replaced by AFN"
- :code: AFN
:description: Afghani
:notes: "Afghanistan (prices normally quoted as integers)"
@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 / 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 / gce_ip_ranges.log
Last active November 8, 2019 13:12
Google Compute Engine GCE IP Ranges
8.34.208.0/20
8.35.192.0/21
8.35.200.0/23
23.236.48.0/20
23.251.128.0/19
35.184.0.0/14
35.188.0.0/15
35.190.0.0/17
35.190.128.0/18
35.190.192.0/19
@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 / bs_deb_stretch_vbox.sh
Created December 25, 2017 05:54
Debian Stretch Virtualbox VM.
#!/usr/bin/env bash
set -e
PACKAGES="i3 tmux vim stow"
read -d '' APT_SRC <<"EOF" ||:
deb http://mirrors.kernel.org/debian/ stretch main contrib non-free
deb http://security.debian.org/debian-security stretch/updates main
deb http://mirrors.kernel.org/debian/ stretch-updates main contrib non-free
deb http://mirrors.kernel.org/debian stretch-backports main contrib non-free
@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 *