Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tear down quad #12

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified config/iterm2/install
100644 → 100755
Empty file.
10 changes: 9 additions & 1 deletion config/macos/gitconfig.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[gpg]
format = ssh
[user]
signingkey = /Users/spraints/.ssh/id_ed25519.pub
signingkey = /Users/spraints/.ssh/id_rsa.pub
[commit]
gpgsign = true
[url "[email protected]:"]
insteadOf = https://github.com/
#[url "[email protected]:"]
# insteadOf = https://ghe.io/
[maintenance]
repo = /Users/spraints/src/github.com/github/spokesd
2 changes: 2 additions & 0 deletions config/nvim/install
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ start_dir="$(pwd -P)"
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage

# Instead of extracting it, maybe just install fuse?
# https://github.com/AppImage/docs.appimage.org/blob/master/source/user-guide/troubleshooting/fuse.rst#how-to-install-fuse
cd /
sudo "${start_dir}/nvim.appimage" --appimage-extract
rm -f "${start_dir}/nvim.appimage"
Expand Down
17 changes: 11 additions & 6 deletions dotfiles/bin/merge-queue
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
export RBENV_VERSION=system
exec ruby "$0" "$@"
#!ruby
#/ Usage: merge-queue OWNER/REPO
#/ Usage: merge-queue [--oneline] OWNER/REPO
#/ Shows pretty merge queue for the given repository.

require "date"
require "json"
require "net/http"
require "timeout"

def main(nwo:, token:, user: nil)
def main(nwo:, token:, user: nil, oneline: false)
data = query_mq(nwo: nwo, token: token)
if errors = data["errors"]
p errors
Expand All @@ -31,7 +31,9 @@ def main(nwo:, token:, user: nil)

active_group_ids = mq.fetch("mergingEntries").fetch("edges").map { |edge| edge.fetch("node").fetch("id") }

puts "**", "Also check out: https://heaven.githubapp.com/apps/#{File.basename(nwo)}", "**", ""
unless oneline
puts "**", "Also check out: https://heaven.githubapp.com/apps/#{File.basename(nwo)}", "**", ""
end

next_merge_time = mq.fetch("nextEntryEstimatedTimeToMerge")
entries = mq.fetch("entries").fetch("edges")
Expand All @@ -53,9 +55,10 @@ def main(nwo:, token:, user: nil)
pr_url = entry.fetch("pullRequest").fetch("url")
commit_url = entry.dig("headCommit", "url")

printf "%3d. %s @%s [%d] %s\n %s\n",
position, pretty_state(state), enqueued_by, pr_number, pr_title, pr_url
if state != "MERGEABLE"
printf "%3d. %s @%s [%d] %s\n",
position, pretty_state(state), enqueued_by, pr_number, pr_title
unless oneline
printf " %s\n", pr_url
printf " %s\n", commit_url || "(no commit URL)"
end
end
Expand Down Expand Up @@ -182,6 +185,8 @@ while arg = ARGV.shift
opts[:nwo] = arg
when "--user"
opts[:user] = ARGV.shift
when "--oneline"
opts[:oneline] = true
else
usage
end
Expand Down
25 changes: 20 additions & 5 deletions dotfiles/bin/tcp-hogs
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
#!/bin/bash
#/ Usage: tcp-hogs [-n SECONDS] [-i IFACE]
#/ SECONDS defaults to 10.
#/ IFACE defaults to en0.
#/ en0 = wifi on mac laptops.
#/ en8 = usb hub on work laptop.

set -e
set -o nounset

# on quad:
# en0 is the wifi adapter
# en8 is the usb hub
iface=en0

sec=10

while [ $# -gt 0 ]; do
case "$1" in
-n)
sec="$2"
shift; shift;;
-i)
iface="$2"
shift; shift;;
*)
cat "$0" | grep "^#/" | cut -c4-
exit 1;;
esac
done

t=${TMPDIR:-/tmp}
pcap="${t}/tcp-hogs-$$.pcap"

#trap "test -f ${pcap} && rm -f ${pcap}" EXIT
trap "test -f ${pcap} && (set -x; rm -f ${pcap})" EXIT

echo "Capturing packets for ${sec} seconds into ${pcap}..."
tcpdumpargs="-G ${sec} -W 1 -w ${pcap}"
Expand Down
2 changes: 2 additions & 0 deletions dotfiles/config/starship.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
command_timeout = 100

[[battery.display]]
threshold = 30

Expand Down
1 change: 1 addition & 0 deletions dotfiles/tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind -N 'find a window by name' e command-prompt -p 'window name:' 'find-window %%'

bind _ clear-history

Expand Down
105 changes: 105 additions & 0 deletions script/archive-quad
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

set -e
set -o nounset

# "DRYRUN=false script/archive-quad" to actually run the commands.
DRYRUN="${DRYRUN:-true}"

TODAY="$(date +%Y-%m-%d)"
ARCHIVE_DIR="${HOME}/archive-${TODAY}"

echo "Making archives in ${ARCHIVE_DIR}"

backup() {
local dir="$1"; shift
local dest="${ARCHIVE_DIR}/${dir}.tar.bz2"
mkdir -p "$(dirname "$dest")"
if [ -e "${dir}/.archive-quad-excludes" ]; then
set -- "$@" --exclude-from "${dir}/.archive-quad-excludes"
fi
set -- "$@" --exclude "target"
set -- "$@" --exclude "build"
set -- "$@" --exclude "node_modules"
set -- "$@" --exclude ".bundle"
set -- "$@" --exclude "vendor/cache"
btar "$dir" "$dest" "$@"
}

backup_home() {
local dir="$1"; shift
local dest="${ARCHIVE_DIR}/homes/${dir}.tar.bz2"
mkdir -p "$(dirname "$dest")"
btar --sudo "$dir" "$dest" "$@"
}

btar() {
local dir="$1"; shift
local sudo=
if [ "$dir" = "--sudo" ]; then
sudo=sudo
dir="$1"; shift
fi
local dst="$1"; shift

if [ -f "$dst" ]; then
ls -l "$dst"
elif $DRYRUN; then
echo $sudo tar "$@" -cjf "$dst" "$dir"
else
rm -f "$ARCHIVE_DIR/.tmp"
(set -x; $sudo tar "$@" -cjf "$ARCHIVE_DIR/.tmp" "$dir")
mv "$ARCHIVE_DIR/.tmp" "$dst"
ls -l "$dst"
fi
}

cd "${HOME}"

backup Desktop

backup Documents --exclude Documents/VOI
backup Documents/VOI

backup Movies

backup Music/Sonic\ Pi

for d in src/*; do
case "$(basename "$d")" in
github.com|ghe.io|github.ghe.com)
for dd in $d/*/*; do
case "$(basename "$dd")" in
enterprise2|github|github-bare|heaven|puppet|thehub|zoom)
;; #skip
*)
backup "$dd"
;;
esac
done
;;
experiments|gist*)
for dd in $d/*; do
backup "$dd"
done
;;
*)
backup "$d"
;;
esac
done

for d in dev/*; do
if [ "$d" != "dev/machines.bak" ]; then
backup "$d"
fi
done

for d in Xcode/*; do
backup "$d"
done

cd ..
backup_home cassandra
backup_home oliver
backup_home goldenpandas