Skip to content

Instantly share code, notes, and snippets.

Dr Paul Brewer DrPaulBrewer

Block or report user

Report or block DrPaulBrewer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
DrPaulBrewer /
Last active Mar 20, 2019
git-hook for on-push nginx configuration, testing, and alerting
# originally /root/
APK='your-mailgun-key' # replace with mailgun key
FROM='Nginx Alert <>'
TO='you@email' # replace with recipients
# SUBJECT, TEXT is exported from caller
curl -s --user $APK \ \
-F from="$FROM" \
-F to="$TO" \
DrPaulBrewer /
Last active Jun 23, 2019
Randomized Model of Markets populated by Gode and Sunder (1993) ZI robots + Todd Kaplan's Snipers with Sniper Failure -- for section 3 of Brewer and Ratan (2018)
#!/usr/bin/env python3
# File:
# Copyright 2018 Paul Brewer, Economic and Financial Technology Consulting LLC
# This code approximates allocation efficiency, source of efficiency losses, and
# Gini Coefficient for profits accumulated over many periods in a market populated
# by a mix of Gode and Sunder (1993) ZI robots and Todd Kaplan's Sniper robots.
# In this code, we only model the "failsafe" case where the snipers fail to find or
# act on exceptional prices or low bid-ask spread and so execute the end-of-period failsafe
# strategy of accepting any existing profitable bid/ask. Taking an average
# over random shuffling of Snipers imperfectly approximates the interactions over multiple
DrPaulBrewer / GINISS
Last active Oct 30, 2018
GINISS Gini Coefficient Function for Google Sheets. Open Tools->Script Editor in Sheets and Copy/Paste.
* GINISS and THEILT Copyright 2018- Paul Brewer, Economic and Financial Technology Consulting LLC <>
* This file may be used or copied under the terms of the MIT License as explained below or at
* The MIT License
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
DrPaulBrewer / UploaderForGoogleDrive.js
Last active Aug 19, 2019
Upload Browser Blobs to Files in Google Drive API v3
View UploaderForGoogleDrive.js
// upload.js, from
// Contributors Steve Bazyl, Mike Procopio, Jeffrey Posnick, Renaud Sauvain
// License: Apache 2.0
// Implements Resumable Upload for Google Drive as described by
// Modified by Paul Brewer, Economic and Financial Technology Consulting LLC
// Nov. 1 2017
// 1. use Google Drive API V3 instead of V2
DrPaulBrewer / createStorageKey.js
Created Oct 4, 2017
create random AES-256 key in hex -- compatible with Google Cloud Storage
View createStorageKey.js
// Copyright 2017 Paul Brewer, Economic and Financial Technology Consulting LLC <>
// License: The MIT License. See:
// Google has an example using base64; hex is a little safer to copy/paste and recognize as incorect
// see
DrPaulBrewer /
Last active Oct 25, 2017
Set up openjdk 8 and scala build tool sbt on bare ubuntu/debian machine
#!/bin/bash -e
apt-get --yes update
apt-get --yes install openjdk-8-jdk emacs-nox curl wget apt-transport-https
# modified from "Installing sbt on Linux" at
echo "deb /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
apt-key adv --keyserver hkp:// --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
DrPaulBrewer / zcash-miner-Dockerfile
Last active Jul 8, 2017
Dockerfile and run script to mine zcash with EWBF and Dwarfpool. Pre-requisite: download and unzip EWBF into ./zec/miner
View zcash-miner-Dockerfile
# Working as of Dec 2016
FROM ubuntu:14.04
RUN apt-get update && apt-get --yes upgrade && apt-get --yes install iputils-ping less emacs24-nox git curl wget build-essential screen python-pip software-properties-common
RUN echo deb xenial multiverse >>/etc/apt/sources.list && \
echo deb-src xenial multiverse >>/etc/apt/sources.list && \
echo deb xenial-updates multiverse >>/etc/apt/sources.list && \
echo deb-src xenial-updates multiverse >>/etc/apt/sources.list
RUN apt-get update && apt-get --yes --no-install-recommends install nvidia-cuda-dev nvidia-cuda-doc
RUN apt-get --no-install-recommends --yes install nvidia-367; exit 0
DrPaulBrewer /
Last active Mar 9, 2016
# Do NOT use this as-is
# you probably need to change a few lines (disk, subnet, script)
# The google compute engine web UI may provide you
# with an equivalent command line for a specific configuration built in the web UI
gcloud compute instances create "my-spark-notebook" \
--description "docker spark jupyter-notebook analysis platform" \
--zone "us-east1-c" \
--machine-type "n1-highcpu-32" \
--subnet "default-754f8fec2c9e9fe2" \
DrPaulBrewer /
Created Jan 8, 2016
environment vars to JSON
#!/usr/bin/env python
import json
import os
print json.dumps(dict(os.environ))
DrPaulBrewer /
Created Jun 26, 2015
count expressions in python code, not including comment lines
#!/usr/bin/env python
# Copyright 2015 Paul Brewer
# This file is open source software
# License: The MIT License
import re
import sys
if len(sys.argv)!=3:
print 'Usage: '
You can’t perform that action at this time.