Skip to content

Instantly share code, notes, and snippets.

View 1stvamp's full-sized avatar
:shipit:

Wes Mason 1stvamp

:shipit:
View GitHub Profile
@1stvamp
1stvamp / parse_deploy_log.py
Last active January 17, 2025 02:02
Parse Cloud66 server deployment logs for times taken
#!/usr/bin/env python3
from sys import argv, exit
from os.path import dirname
from datetime import datetime
from pprint import pprint
if len(argv) == 1 or argv[1] in ('-h', '--help'):
print('USAGE: parse_deploy_log.py LOG_FILE [NUMBER_OF_TOP_TIMES]')
exit(1)
@1stvamp
1stvamp / update-ssh-config-ts
Last active October 30, 2024 16:30
Update SSH config to include tailscale staging/production/tooling hosts, add "Include /Users/YOURUSER/.ssh/tailscale-hosts" to the top of ~/.ssh/config
#!/bin/bash
set -euo pipefail
HOSTS=$(curl -s -XGET --url "https://api.tailscale.com/api/v2/tailnet/${TAILSCALE_DOMAIN}/devices" -H "Authorization: Bearer ${TAILSCALE_SSH_CONFIG_UPDATER_TOKEN}" | jq -r '.devices.[].name' | grep -E -- "-(staging|production|tooling).${TAILSCALE_MAGICDNS_DOMAIN}$")
cat << EOF > "${HOME}/.ssh/tailscale-hosts"
Host *.${TAILSCALE_MAGICDNS_DOMAIN}
User ${TAILSCALE_SSH_USER}
EOF
@1stvamp
1stvamp / functions.sh
Last active October 25, 2024 11:07
bash functions I use time and time again in scripts
#!/bin/bash
# Wrapper around apt/apt-get install to avoid all interactive prompts
function apt_install {
local DEBIAN_FRONTEND=noninteractive
local DEBIAN_PRIORITY=critical
export DEBIAN_FRONTEND DEBIAN_PRIORITY
sudo /usr/bin/apt-get install --yes --quiet --option Dpkg::Options::=--force-confold --option Dpkg::Options::=--force-confdef "$@"
return $?
@1stvamp
1stvamp / create-standup.rb
Last active March 26, 2024 13:54
Script to fetch a gist with markdown in it and generate a nice standup post for Slack
#!/home/wes/.asdf/installs/ruby/3.0.2/bin/ruby
require 'uri'
require 'net/http'
NOCACHE_SUFFIX = 'nocache=' + Time.now.to_i.to_s
def break_cache(url)
url + (if url.include?('?') then '&' else '?' end) + NOCACHE_SUFFIX
end
@1stvamp
1stvamp / phpweekly_feb7_giveaway.php
Created February 6, 2013 23:52
PHP script to randomly pick winners of PHP Weekly issue #8 giveaway
<?php
$header = null;
$subscribers = array();
$handle = fopen(dirname(__FILE__).'/members_PHP_Weekly_Feb_6_2013.csv', 'r');
// fgetcsv is a bit naff, luckily I was able to massage this CSV into an easily parsable format
while (($line = fgetcsv($handle, 1000, ",")) !== false) {
if ($header === null) {
$header = $line;
} else {
@1stvamp
1stvamp / mac-curl-ca-bundle.sh
Created March 22, 2012 12:50
Script to install cURL CA certificates on OS X without macports
#!/bin/bash
mkdir /tmp/curl-ca-bundle
cd /tmp/curl-ca-bundle
wget http://curl.haxx.se/download/curl-7.22.0.tar.bz2
tar xzf curl-7.22.0.tar.bz2
cd curl-7.22.0/lib/
./mk-ca-bundle.pl
if [ ! -d /usr/share/curl/ ]; then
sudo mkdir -p /usr/share/curl/
else
@1stvamp
1stvamp / jenv
Last active March 17, 2021 16:51
rbenv/jenv shims for use with asdf, specifically for exec support
#!/usr/bin/env bash
set -e
if [ "$#" -gt 0 ] && [ "$1" = "shell" ]
then
shift
_SHIM_VERSION=${1:-$(asdf current ruby | awk '{print $1}')}
asdf sh-shell ruby "${_SHIM_VERSION}"
elif [ "$#" -gt 0 ] && [ "$1" = "version" ]
@1stvamp
1stvamp / starship.toml
Last active September 18, 2020 11:45
My starship config
prompt_order = [
"username",
"hostname",
"kubernetes",
"directory",
"git_branch",
"git_commit",
"git_state",
"git_status",
"hg_branch",
@1stvamp
1stvamp / whisper-back-fill.sh
Last active April 28, 2020 22:48
Recursive whisper data file back-fill script using carbonate::whisper-fill
#!/bin/bash
set -eo pipefail
if [ "$#" -lt 2 ]
then
>&2 echo 'Usage: whisper-back-fill.sh SOURCE_BASE_DIR DESTINATION_BASE_DIR'
>&2 echo 'e.g. given './data/dal05': whisper-back-fill.sh ./data /data/graphite/storage/'
exit 1
fi
#!/usr/bin/expect -f
set timeout -1
set pin [ lindex $argv 0 ]
set token [ lindex $argv 1 ]
spawn gotunl -c 1
expect "Enter the PIN:*"