Skip to content

Instantly share code, notes, and snippets.

Avatar
🧡

Mat Schaffer matschaffer

🧡
View GitHub Profile
@matschaffer
matschaffer / README.md
Last active Dec 3, 2021
New Laptop Install list
View README.md

Do first

  • Dropbox
  • 1Password

Managed

  • Slack
  • Flycut
  • Zoom
  • Google drive
@matschaffer
matschaffer / switch_to_main.sh
Last active Nov 1, 2021
A bash helper for switching a local clone and a github fork from master to main.
View switch_to_main.sh
#!/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
matschaffer / .env
Created Oct 20, 2021
docker-compose.yml
View .env
env-hyphens=ok
env.dots=ok
@matschaffer
matschaffer / gist:4912279e49dce41ab9b2
Last active Jul 6, 2021
Bash-friendly ec2 prices
View gist:4912279e49dce41ab9b2
#!/usr/bin/env bash
URL="http://a0.awsstatic.com/pricing/1/ec2/ri-v2/linux-unix-shared.min.js"
(echo 'function callback(data) { console.log(JSON.stringify(data)); }'; curl -s "$URL") |\
node |\
jq -r '.config.regions[] |
select(.region == "us-east-1") |
.instanceTypes[] |
[
@matschaffer
matschaffer / check-attached-policies.sh
Created Mar 19, 2021
Shows all role and user policies - Helpful for deprecation of AWSElasticBeanstalkService
View check-attached-policies.sh
for R in $(aws iam list-roles --query 'Roles[].RoleName[]' --output text); do
echo "$R"
aws iam list-attached-role-policies --role-name "$R"
done
for U in $(aws iam list-users --query 'Users[].UserName[]' --output text); do
echo "$U"
aws iam list-attached-user-policies --user-name "$U"
done
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
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
array_to_prawn(@children)
end
def array_to_prawn(children)
children.each do |c|
send("to_prawn_#{c.node_type}", c)
@matschaffer
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)