Skip to content

Instantly share code, notes, and snippets.

View matthewberryman's full-sized avatar
💭
work work work

Matthew Berryman matthewberryman

💭
work work work
View GitHub Profile
@matthewberryman
matthewberryman / serverless_policy.json
Created March 22, 2018 06:44
IAM policy for using serverless in codebuild
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1483564261000",
"Effect": "Allow",
"Action": [
"iam:GetRole",
"iam:CreateRole",
"iam:DeleteRole",
@matthewberryman
matthewberryman / clearconfig.js
Created March 21, 2018 22:02
clear all AWS config rules for a region
let AWS = require('aws-sdk');
let configservice = new AWS.ConfigService({region: process.argv[2]});
const describeParams = {};
configservice.describeConfigRules(describeParams, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else {
for (let ruleIndex in data.ConfigRules) {
let params = {
@matthewberryman
matthewberryman / water_taps.sql
Created February 14, 2018 04:03
water tap extraction from West Africa HOT openstreetmap data
SELECT * from osm.planet
WHERE type = 'node'
AND tags['man_made'] IN ('water_tap')
AND lon BETWEEN -15.0863 AND -7.3651
AND lat BETWEEN 4.3531 AND 12.6762;
CREATE EXTERNAL TABLE planet (
id BIGINT,
type STRING,
tags MAP<STRING,STRING>,
lat DECIMAL(9,7),
lon DECIMAL(10,7),
nds ARRAY<STRUCT<ref: BIGINT>>,
members ARRAY<STRUCT<type: STRING, ref: BIGINT, role: STRING>>,
changeset BIGINT,
timestamp TIMESTAMP,
@matthewberryman
matthewberryman / git_fix_authordate.sh
Created December 13, 2017 02:07
Brings git AuthorDate in line with CommitDate for all git commits
#!/usr/bin/env bash
git filter-branch --env-filter '
export GIT_AUTHOR_DATE=`git show -s --format=%ci $GIT_COMMIT`
' --tag-name-filter cat -- --branches --tags
@matthewberryman
matthewberryman / greengrass.service
Last active November 25, 2019 11:42
greengrass systemd
[Unit]
Description=greengrass daemon
After=network.target
[Service]
ExecStart=/greengrass/ggc/core/greengrassd start
Type=simple
RestartSec=2
Restart=always
User=root
@matthewberryman
matthewberryman / requirements.txt
Created October 20, 2017 00:53
requirements.txt for librosa on RPi3 with llvm-3.8
audioread==2.1.5
cryptography==1.7.1
decorator==4.0.11
idna==2.2
joblib==0.11
keyring==10.1
keyrings.alt==1.3
librosa==0.5.1
llvmlite==0.15.0
numba==0.30.1
@matthewberryman
matthewberryman / cache-control.js
Created October 7, 2017 05:34
lambda to add cache-control header to cloudfront
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
headers['cache-control'] = [
{key: 'Cache-Control',
value: 'max-age=3600'
}];
callback(null, response);
@matthewberryman
matthewberryman / setup_nice_environment_on_mac.sh
Created September 4, 2017 23:30
setup_nice_environment_on_mac.sh
#!/usr/bin/env bash
brew upgrade
brew cleanup
brew install zsh git
cd ~
git clone https://github.com/matthewberryman/oh-my-zsh .oh-my-zsh && ln -s .oh-my-zsh/templates/zshrc.mac .
git clone https://github.com/creationix/nvm .nvm
echo "/usr/local/bin/zsh" | sudo tee -a /etc/shells > /dev/null
sudo chsh -s /usr/local/bin/zsh $USER
# Then close terminal and re-open and run
@matthewberryman
matthewberryman / cors-s3-upload.xml
Created June 21, 2017 20:53
CORS config for s3 uploads
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>