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 / 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 / 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
@1stvamp
1stvamp / joke.sh
Last active October 16, 2019 16:17
cowsay joke
#!/bin/bash
args=( '-e OO -T U' '-e ">o"' )
lines=( 'knock knock' "who\'s there?" 'moo' 'moo who?' "aww don\'t cry, it\'ll be alright" )
args_i=0
for line in "${lines[@]}"
do
eval cowsay "${args[$args_i]}" "$line"
#!/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:*"
@1stvamp
1stvamp / vpn-status.sh
Last active October 10, 2019 11:40
Script to checked the connected status output from the gotunl client for the pritunl vpn daemon
#!/usr/bin/env bash
while ! [[ $(gotunl -l) == *Connected* ]]
do
echo -n .
sleep 1
done
echo -e '\e[32mVPN connected!\e[0m'
@1stvamp
1stvamp / Gemfile
Last active September 11, 2019 14:05
main entrypoint.js to use with a GitHub Action to run action written in ruby
# .github/actions/my-action/Gemfile
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'json'
@1stvamp
1stvamp / user.js
Created September 4, 2019 10:53
Open GitHub issue description links in a new tab when rendering on app.zenhub.com
var mutationObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
Array.prototype.forEach.call(document.querySelectorAll('.zhc-markdown a'), function(el, i) {
el.setAttribute('target', '_blank')
})
})
})
mutationObserver.observe(document.documentElement, {
childList: true,