Skip to content

Instantly share code, notes, and snippets.

Avatar
🧡

Mat Schaffer matschaffer

🧡
View GitHub Profile
@matschaffer
matschaffer / switch_to_main.sh
Last active Oct 21, 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
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
# Point main to upstream if we use upstream
@matschaffer
matschaffer / .env
Created Oct 20, 2021
docker-compose.yml
View .env
env-hyphens=ok
env.dots=ok
@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
@matschaffer
matschaffer / README.md
Last active Oct 27, 2021
New Laptop Install list
View README.md
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 = [];
}
View reindex_year.yaml
actions:
1:
action: reindex
description: Reindex 2017 indices to single index
options:
wait_interval: 9
max_wait: -1
request_body:
source:
index: REINDEX_SELECTION
@matschaffer
matschaffer / get_solution_stack_name.sh
Last active Feb 7, 2019
A script for pulling an elasticbeanstalk solution name for a given runtime version
View get_solution_stack_name.sh
#!/usr/bin/env bash
set -euo pipefail
MINOR_VERSION=$(awk -F. '{print $1 "." $2}' $(dirname $0)/../.ruby-version)
NAME_FILTER="{\"Type\":\"PlatformName\",\"Operator\":\"begins_with\",\"Values\":[\"Puma with Ruby ${MINOR_VERSION}\"]}"
VERSION_FILTER='{"Type":"PlatformVersion","Operator":"=","Values":["latest"]}'
PLATFORM_ARN=$(
aws elasticbeanstalk list-platform-versions \
View bottles.rb
class Bottles
def word_part(n)
case n
when 0
"no more bottles"
when 1
"1 bottle"
else
"#{n} bottles"
end
@matschaffer
matschaffer / api_demo.py
Created Aug 7, 2018
A python example uploading and submitting a safecast drive
View api_demo.py
import sys
import requests
import os
endpoint = os.environ.get("SAFECAST_API", "https://api.safecast.org")
api_key = os.environ.get("SAFECAST_API_KEY")
if len(sys.argv) != 2:
print("Usage: {} <LOGFILE>".format(sys.argv[0]), file=sys.stderr)
@matschaffer
matschaffer / Makefile
Created Apr 13, 2018
Terraform makefile
View Makefile
SHELL = /bin/bash
terraform_opts ?=
terraform_plan_opts ?=
.PHONY: help
help::
@echo
@echo Infrastructure management using Terraform.
@echo