Skip to content

Instantly share code, notes, and snippets.

Matthew Bernhardt matt-bernhardt

Block or report user

Report or block matt-bernhardt

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
View attendance.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matt-bernhardt
matt-bernhardt / mitlib-content-model.php
Created Jan 28, 2019
Snippet to establish a WordPress custom post type in vanilla PHP
View mitlib-content-model.php
<?php
/**
* Plugin Name: MITlib Content Model
*
* @package mitlib-content-model
* @version 0.0.1
*/
/**
* Register content types
@matt-bernhardt
matt-bernhardt / README.md
Last active Feb 15, 2018
Columbus Attendance Changes In Context
View README.md

This is an attempt to build a visualization of organic attendance growth by the Columbus Crew over various time periods during their 21-year history.

For more information about this plot, please reach out to me on Twitter at @BernhardtSoccer.

@matt-bernhardt
matt-bernhardt / model170501.py
Created Oct 15, 2017
A simple python script that runs a monte carlo simulation of the remaining games in a Major League Soccer season. This is pretty coupled to the database I use, and some shim objects I wrote for that database - but the approach should be clear though.
View model170501.py
import copy
import database
from log import Log
from output import Output
import numpy as np
def calculatePPG(data):
# This expects data in a form of
# {'MIN': {'Points': 8.0, 'PPG': 0.8888888888888888, 'GP': 9.0}, 'TOR': {'Points': 16.0, 'PPG': 1.7777777777777777, 'GP': 9.0}}
@matt-bernhardt
matt-bernhardt / extractor.vbs
Created Mar 7, 2017
A short VBscript that will extract comments from a Word document and store them as a table in Excel. Created for part of a project that involves "coding" a large number of transcripts according to certain arbitrary categories.
View extractor.vbs
Option Explicit
' #############################################################
' #
' # Define Objects and Variables
' #
Dim oFSO
Dim LogFile
Dim strPath
@matt-bernhardt
matt-bernhardt / analysis.R
Last active Dec 7, 2016
MLS offseason turnover data, 2013 - 2015
View analysis.R
data <- read.csv("turnover.csv")
summary(data)
str(data)
# Histograms
# Figure 1 - histogram of turnover by player
summary(data$Pctg.Players)
hist(
View possession_160921.csv
Team Team3 Date H/A Opponent Opp3 Score WDL Passes P.Pctg Attacking A.Pctg Third T.Pctg Crosses C.Pctg Possession
New York Red Bulls NY 3/6/2016 H Toronto FC TOR 0 L 549 0.72 384 0.65 181 0.56 20 0.45 0.63
Toronto FC TOR 3/6/2016 A New York Red Bulls NY 2 W 329 0.58 189 0.47 87 0.44 9 0.11 0.37
Orlando City ORL 3/6/2016 H Real Salt Lake RSL 2 D 373 0.8 274 0.67 146 0.66 38 0.21 0.53
Real Salt Lake RSL 3/6/2016 A Orlando City ORL 2 D 358 0.76 237 0.68 84 0.58 10 0.2 0.47
Chicago Fire CHI 3/6/2016 H New York City FC NYC 3 L 303 0.66 173 0.52 90 0.62 21 0.05 0.39
New York City FC NYC 3/6/2016 A Chicago Fire CHI 4 W 500 0.78 310 0.71 184 0.69 8 0 0.61
FC Dallas DAL 3/6/2016 H Philadelphia Union PHI 2 W 347 0.69 206 0.55 107 0.54 17 0.12 0.49
Philadelphia Union PHI 3/6/2016 A FC Dallas DAL 0 L 375 0.69 237 0.58 117 0.57 17 0.24 0.51
Houston Dynamo HOU 3/6/2016 H New England Revolution NE 3 D 382 0.75 222 0.6 112 0.61 25 0.2 0.52
@matt-bernhardt
matt-bernhardt / winless.csv
Created Aug 6, 2016
Results in Columbus Crew SC history, to identify the longest winless streaks in team history.
View winless.csv
ShortDate CrewScore OppScore Result Last Win Days Since Days Into Season
4/13/1996 4 0 Win 4/13/1996 0 0
4/20/1996 1 2 4/13/1996 7 7
4/27/1996 2 0 Win 4/27/1996 14 14
5/2/1996 4 6 4/27/1996 5 19
5/5/1996 0 0 4/27/1996 8 22
5/11/1996 3 2 Win 5/11/1996 14 28
5/15/1996 2 5 5/11/1996 4 32
5/19/1996 2 4 5/11/1996 8 36
5/26/1996 2 3 5/11/1996 15 43
@matt-bernhardt
matt-bernhardt / 160712 berhalter transactions.csv
Created Jul 13, 2016
A list of all player transactions for Columbus Crew SC under coach Gregg Berhalter
View 160712 berhalter transactions.csv
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 8.
SigningDate,STATUS,Player,Position,Notes
2013-11-22,"Departed","Konrad Warzycha","Midfielder","Warzycha's contract option was declined after the 2013 season as part of new coach Gregg Berhalter's rebuilding."
2013-11-22,"Departed","Drew Beckie","Defender","Beckie's contract option was declined after the 2013 season as part of new coach Gregg Berhalter's rebuilding."
2013-11-22,"Departed","Glauber","Defender","Glauber's contract option was declined after the 2013 season as part of new coach Gregg Berhalter's rebuilding."
2013-11-22,"Departed","Kyle Hyland","Defender","Hyland's contract option was declined after the 2013 season as part of new coach Gregg Berhalter's rebuilding."
2013-11-22,"Departed","Danny O'Rourke","Midfielder","O'Rourke's contract option was declined after the 2013 season as part of new coach Gregg Berhalter's rebuilding."
2013-11-22,"Departed","Jairo Arrieta","Forward","Arrieta's option was declined after the 2013 season as part of new coach Gregg Berhalter's rebuilding."
2013-11-25,"Joined
@matt-bernhardt
matt-bernhardt / ppg_2011-2015.csv
Created Jul 10, 2016
Points Per Game after every round of MLS play, from 2011 - 2015
View ppg_2011-2015.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 40 columns, instead of 36. in line 5.
ID,Season,Team,Playoffs,Position,TeamID,G1,G2,G3,G4,G5,G6,G7,G8,G9,G10,G11,G12,G13,G14,G15,G16,G17,G18,G19,G20,G21,G22,G23,G24,G25,G26,G27,G28,G29,G30,G31,G32,G33,G34
1,2011,Columbus,Yes,4,11,0,0.5,1.33,1.25,1.6,1.5,1.71,1.63,1.44,1.3,1.27,1.25,1.38,1.29,1.4,1.5,1.41,1.5,1.47,1.4,1.48,1.55,1.48,1.54,1.6,1.54,1.48,1.46,1.41,1.37,1.32,1.38,1.42,1.38
2,2011,DC,No,7,12,3,1.5,1,1,1.4,1.17,1,1.25,1.22,1.2,1.36,1.33,1.23,1.21,1.2,1.19,1.29,1.28,1.21,1.3,1.29,1.36,1.35,1.29,1.36,1.31,1.3,1.36,1.31,1.27,1.23,1.19,1.18,1.15
3,2011,Chicago,No,6,13,1,2,1.33,1,0.8,0.83,0.86,0.88,0.89,0.8,0.82,0.83,0.85,1,1,1,1,1,0.95,0.9,0.9,0.86,0.87,0.88,0.96,1.04,1,1.07,1.14,1.2,1.19,1.16,1.21,1.26
4,2011,Colorado,Yes,5,14,3,3,3,2.25,1.8,1.5,1.43,1.63,1.56,1.5,1.45,1.42,1.38,1.36,1.47,1.38,1.29,1.28,1.26,1.35,1.29,1.36,1.35,1.42,1.48,1.54,1.52,1.46,1.41,1.37,1.35,1.41,1.39,1.44
5,2011,New England,No,9,15,1,2,1.67,1.5,1.2,1,1.29,1.13,1.11,1.3,1.18,1.08,1,0.93,0.93,0.94,0.88,0.89,0.84,0.95,0.95,0.95,0.91,0.88,0.88,0.88,0.89,0.96,0.93,0.9
You can’t perform that action at this time.