Skip to content

Instantly share code, notes, and snippets.

View brannondorsey's full-sized avatar
Makin' the net work

Brannon Dorsey brannondorsey

Makin' the net work
View GitHub Profile
brannondorsey /
Last active October 16, 2020 19:30
Automate shutdown when no GPU processes are running and no users are logged in
# A script for shutting down an idle VM with GPUs attached when they are idle and there
# are no users logged in. Add the below crontab via `crontab -e` to run this script every
# 10 minutes and append its output to a log:
# */10 * * * * ~/ >> ~/shutdown_idle_gpu_machine.log 2>&1
# This script should live in your HOME directory. Your user should have sudoer privileges.
brannondorsey / equivalent-binary-tree-search.go
Last active January 25, 2020 17:24
A Tour of Go Exercises
// Exercise: Equivalent Binary Trees (
// There can be many different binary trees with the same sequence of values stored in it.
// For example, here are two binary trees storing the sequence 1, 1, 2, 3, 5, 8, 13.
// A function to check whether two binary trees store the same sequence is quite complex
// in most languages. We'll use Go's concurrency and channels to write a simple solution.
package main
import (
brannondorsey /
Last active September 24, 2021 07:28
Runway Linux Install Script
NC='\033[0m' # no color
# attempts to download the URL specified as argument $1 using wget. If wget isn't
# installed it falls back to curl. If curl isn't installed it prints an error and
# exits.
# usage: download <url> <outfile>
brannondorsey /
Created March 20, 2019 17:39
Kubernetes Notes

Kubernetes Notes

Get Dashboard Token

# get the name of the dashboard token secret.
# e.g. kubernetes-dashboard-token-3anjf
kubectl get secrets -n kube-system
brannondorsey /
Last active February 22, 2023 21:02
Chattervox Install Instructions

Chattervox on MacOS

Install Direwolf

The official Direwolf User Manual uses MacPorts to manage installation and dependencies. I don't particularly like MacPorts, so here are some instructions for installing Direwolf via Homebrew.

# Install Direwolf via Homebrew
brew install tdsmith/ham/direwolf
brannondorsey / sample.js
Created October 4, 2018 19:43
Discrete probability distribution sampling in JavaScript
// MIT License
// (c) 2018 Brannon Dorsey <>
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
brannondorsey /
Last active August 9, 2018 15:14
ML Experiment Structure
  • experiment_1/
    • hyperparameters.json
    • checkpoints/ (saved model weight checkpoints go in here)
    • notes.txt (general notes and comments about this experiment)
  • experiment_2/
  • experiment_3/
  • etc.
brannondorsey /
Last active November 8, 2022 08:48
Mean Squared Error

A comparison of the Mean Squared Error algorithm in C, Python, and JavaScript.


gcc mse.c -O3 -o mse -lm
time ./mse
brannondorsey / node-event-order-test.js
Created June 10, 2018 17:07
Does the Node event loop maintain the order async callbacks are sent to it?
// test if node's event loop is gauranteed to run events in the order they are
// pushed to the event queue. Turns out they DO NOT!!! 10,000 integers appended
// one after the other to append.txt using fs.appendFile() will NOT maintain
// the order of those ints.
const fs = require('fs')
function getAppend(i) {
return () => {
fs.appendFile('append.txt', `${i.toString().padStart(3)}\n`, (err) => {
brannondorsey / payload.js
Created June 5, 2018 03:35
DNS Rebinding Example Code
// JS in payloads/google-home.html
.then((json) => {
console.log('The attack was successful! Here is the JSON it exfiltrated:')
err => {
// there probably isn't even a machine with this IP address...
console.error('No Google Home found at this IP ')