Skip to content

Instantly share code, notes, and snippets.

View mdp's full-sized avatar

Mark Percival mdp

View GitHub Profile
### Keybase proof
I hereby claim:
* I am mdp on github.
* I am mdp (https://keybase.io/mdp) on keybase.
* I have a public key whose fingerprint is 3977 96B0 0D37 D95B 3FDC F12F 32FC E8AB 7513 4EF9
To claim this, I am signing this object:
@mdp
mdp / env-to-ssm.sh
Created January 8, 2018 21:33
.env to SSM
#!/bin/bash
# Usage: ./env-to-ssm.sh prefix envfile
# Ex: ./env-to-ssm.sh prod.app .env
AWS_SSM_PREFIX=$1
ENV_FILE=$2
cat aws/.env | grep -v ^# | grep -v -e '^$' | while read line
@mdp
mdp / openvpn.sh
Created November 21, 2017 21:41
OpenVPN setup on docker
#!/bin/bash
arg=$1
host=$2
OVPN_DATA="ovpn-data"
set -x
if [ "$arg" == "setup" ]; then
@mdp
mdp / Occupancy.py
Last active September 26, 2017 21:02
The occupancy sensor at work have REALLY short timeouts.
try:
import RPi.GPIO as GPIO
except RuntimeError:
print("Error importing RPi.GPIO! This is probably because you need superuser privileges. You can achieve this by using 'sudo' to run your script")
import time
import random
import pytz
from datetime import datetime
@mdp
mdp / keybase.md
Created September 18, 2017 23:48
Keybase

Keybase proof

I hereby claim:

  • I am mdp on github.
  • I am mdp (https://keybase.io/mdp) on keybase.
  • I have a public key whose fingerprint is 0FB5 F926 DBAA CEF8 52E9 027F 0A16 D724 A034 42CF

To claim this, I am signing this object:

@mdp
mdp / README.md
Last active March 24, 2021 15:32
Clone/Sync all gists

Clone all your gists

Stolen from mbostok and improved upon

node cloneAllGists.js username token [outputDir]

@mdp
mdp / README.md
Last active May 22, 2021 07:53
Magically watermark your PDF's in bulk

Requirements

_Assumes you are on OSX (sorry, I didn't have time to test it on linux)

Usage

./watermark.sh mydoc.pdf < recipients.txt

@mdp
mdp / README.md
Created February 1, 2017 16:46
Docker files for VPS

My Docker bash scripts for VPS

@mdp
mdp / redirects.md
Last active October 25, 2015 18:41
The NYTimes redirect list

Below is a list of redirects my browser goes through when I visit a NYTimes link on Twitter. Surely we don't have to hop through 'Trib.al' 4 different times? On a mobile connection you get to watch your url bar hop around for 5 seconds before you get to the article.

  1. https://t.co/bA9yHfjB1A
  2. http://nyti.ms/1O0Uw3i
  3. http://trib.al/PIc9tC5
  4. http://nyti.ms/1W97b2Y?smid=tw-upshotnyt&smtyp=cur
  5. http://trib.al/w7kWBH5
  6. http://nyti.ms/1S0PDpl?smid=tw-upshotnyt&smtyp=cur
  7. http://trib.al/Y0hJNH1
  8. http://nyti.ms/1kzuvLV?smid=tw-upshotnyt&smtyp=cur
@mdp
mdp / csp_middleware.js
Created October 13, 2015 17:23
Node.js CSP
let sources = {
'default-src': ['\'self\''],
'script-src': ['\'self\'','https://*.myexternalcdn.com'],
'frame-src': ['https://someexternalframesource.com'],
'img-src': ['\'self\'', 'https:', 'data:'],
'style-src': ['\'self\'', 'https:'],
'font-src': ['\'self\'', 'https:'],
'connect-src': ['\'self\''],
}