Skip to content

Instantly share code, notes, and snippets.


Mat Schaffer matschaffer

View GitHub Profile
matschaffer /
Last active Dec 3, 2021
New Laptop Install list

Do first

  • Dropbox
  • 1Password


  • Slack
  • Flycut
  • Zoom
  • Google drive
matschaffer /
Last active Nov 1, 2021
A bash helper for switching a local clone and a github fork from master to main.
#!/usr/bin/env bash
set -euo pipefail
echo ":: Renaming local master to main"
git branch -m master main || true
git fetch origin
git remote set-head origin -a
if git remote show upstream >/dev/null 2>&1; then
matschaffer / .env
Created Oct 20, 2021
View .env
matschaffer / gist:4912279e49dce41ab9b2
Last active Jul 6, 2021
Bash-friendly ec2 prices
View gist:4912279e49dce41ab9b2
#!/usr/bin/env bash
(echo 'function callback(data) { console.log(JSON.stringify(data)); }'; curl -s "$URL") |\
node |\
jq -r '.config.regions[] |
select(.region == "us-east-1") |
.instanceTypes[] |
matschaffer /
Created Mar 19, 2021
Shows all role and user policies - Helpful for deprecation of AWSElasticBeanstalkService
for R in $(aws iam list-roles --query 'Roles[].RoleName[]' --output text); do
echo "$R"
aws iam list-attached-role-policies --role-name "$R"
for U in $(aws iam list-users --query 'Users[].UserName[]' --output text); do
echo "$U"
aws iam list-attached-user-policies --user-name "$U"
View audibility.js
function ESPlayer(server, indexPattern, playCallback, initialLoad = 40, delay = 10, blockDuration = 10, size = 10) {
this.server = server;
this.indexPattern = indexPattern;
this.playCallback = playCallback;
this.initialLoad = initialLoad;
this.delay = delay;
this.blockDuration = blockDuration;
this.size = size;
this.blocks = [];
matschaffer / gist:942981
Created Apr 26, 2011 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
View gist:942981
$ git branch -r --merged |
sed '/>|master/d;/origin/!d;s:origin/::' |
xargs git push origin --delete
# I think this will work, but I don't know how to get git branch to show me that -> line
View to_prawn.rb
module MaRuKu::Out::Prawn
def to_prawn(pdf)
@pdf = pdf
@pdf.font_size = 11
def array_to_prawn(children)
children.each do |c|
send("to_prawn_#{c.node_type}", c)
matschaffer / mdtopdf.rb
Created Sep 27, 2010
A rough translation of markdown to pdf
View mdtopdf.rb
require 'rubygems'
require 'jekyll'
require 'maruku'
require 'pathname'
# Need pre for inline format support
gem 'prawn', '=0.11.1.pre'
require 'prawn'
require 'to_prawn'
class Converter
View time_series_fit.rb
require 'gsl'
require 'time'
module Diskalerter
class ThresholdEstimator
attr_reader :timestamps, :signal, :threshold, :now
# timestamps - a list of timestamps in epoch milliseconds
# signal - a list of values for the provided timestamps
# threshold - the "exhaustion" threshold (e.g., 100 for a percentage signal)