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
DrPaulBrewer / nginx-alert.sh
Last active Mar 20, 2019
git-hook for on-push nginx configuration, testing, and alerting
View nginx-alert.sh
#!/bin/bash
# originally /root/nginx-alert.sh
APK='your-mailgun-key' # replace with mailgun key
FROM='Nginx Alert <mailgun@mg.econ1.net>'
TO='you@email' # replace with recipients
# SUBJECT, TEXT is exported from caller
curl -s --user $APK \
https://api.mailgun.net/v3/mg.econ1.net/messages \
-F from="$FROM" \
-F to="$TO" \
@DrPaulBrewer
DrPaulBrewer / RandomizedSniperFailureModel.py
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)
View RandomizedSniperFailureModel.py
#!/usr/bin/env python3
# File: RandomizedSniperFailureModel.py
# 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
DrPaulBrewer / GINISS
Last active Oct 30, 2018
GINISS Gini Coefficient Function for Google Sheets. Open Tools->Script Editor in Sheets and Copy/Paste.
View GINISS
/*
* GINISS and THEILT Copyright 2018- Paul Brewer, Economic and Financial Technology Consulting LLC <drpaulbrewer@eaftc.com>
* This file may be used or copied under the terms of the MIT License as explained below or at https://opensource.org/licenses/MIT
* 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
DrPaulBrewer / UploaderForGoogleDrive.js
Last active Aug 19, 2019
Upload Browser Blobs to Files in Google Drive API v3
View UploaderForGoogleDrive.js
// upload.js, from https://github.com/googledrive/cors-upload-sample
// Contributors Steve Bazyl, Mike Procopio, Jeffrey Posnick, Renaud Sauvain
// License: Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0
//
// Implements Resumable Upload for Google Drive as described by
// https://developers.google.com/drive/v3/web/resumable-upload
//
// Modified by Paul Brewer, Economic and Financial Technology Consulting LLC
// Nov. 1 2017
// 1. use Google Drive API V3 instead of V2
@DrPaulBrewer
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 <drpaulbrewer@eaftc.com>
// License: The MIT License. See: https://opensource.org/licenses/MIT
// Google has an example using base64; hex is a little safer to copy/paste and recognize as incorect
// see https://cloud.google.com/storage/docs/using-encryption-keys
@DrPaulBrewer
DrPaulBrewer / setup-scala-sbt.sh
Last active Oct 25, 2017
Set up openjdk 8 and scala build tool sbt on bare ubuntu/debian machine
View setup-scala-sbt.sh
#!/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 http://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
@DrPaulBrewer
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
MAINTAINER drpaulbrewer@eaftc.com
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 http://us.archive.ubuntu.com/ubuntu/ xenial multiverse >>/etc/apt/sources.list && \
echo deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse >>/etc/apt/sources.list && \
echo deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse >>/etc/apt/sources.list && \
echo deb-src http://us.archive.ubuntu.com/ubuntu/ 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
DrPaulBrewer / gcloud-discounted-VM-with-disk-and-startup-script.sh
Last active Mar 9, 2016
gcloud-discounted-VM-with-disk-and-startup-script.sh
View gcloud-discounted-VM-with-disk-and-startup-script.sh
!/bin/bash
# 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
DrPaulBrewer / env2json.py
Created Jan 8, 2016
environment vars to JSON
View env2json.py
#!/usr/bin/env python
import json
import os
print json.dumps(dict(os.environ))
@DrPaulBrewer
DrPaulBrewer / code_count.py
Created Jun 26, 2015
count expressions in python code, not including comment lines
View code_count.py
#!/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.