Skip to content

Instantly share code, notes, and snippets.

View matt-bernhardt's full-sized avatar
💭
Learning Rails...

Matthew Bernhardt matt-bernhardt

💭
Learning Rails...
View GitHub Profile
@matt-bernhardt
matt-bernhardt / README.md
Last active February 15, 2018 03:05
Columbus Attendance Changes In Context

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 October 15, 2017 02:38
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.
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 March 7, 2017 22:23
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.
Option Explicit
' #############################################################
' #
' # Define Objects and Variables
' #
Dim oFSO
Dim LogFile
Dim strPath
@matt-bernhardt
matt-bernhardt / analysis.R
Last active December 7, 2016 20:02
MLS offseason turnover data, 2013 - 2015
data <- read.csv("turnover.csv")
summary(data)
str(data)
# Histograms
# Figure 1 - histogram of turnover by player
summary(data$Pctg.Players)
hist(
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 August 6, 2016 03:11
Results in Columbus Crew SC history, to identify the longest winless streaks in team history.
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 July 13, 2016 02:15
A list of all player transactions for Columbus Crew SC under coach Gregg Berhalter
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 July 10, 2016 15:27
Points Per Game after every round of MLS play, from 2011 - 2015
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
@matt-bernhardt
matt-bernhardt / crew_attendance_thru_160630.csv
Created June 30, 2016 16:10
Data and analysis scripts around Columbus Crew attendance
ID Date Season Month GameNumber Hscore Ascore Visitor Venue Attendance Temperature
10992 4/13/1996 19:30 1996 4 1 4 0 D.C. United Ohio Stadium 25266 60
10993 4/20/1996 19:30 1996 4 2 1 2 Tampa Bay Mutiny Ohio Stadium 24343 66
10997 5/11/1996 19:30 1996 5 3 3 2 New England Revolution Ohio Stadium 24750 56
10999 5/19/1996 16:00 1996 5 4 2 4 Colorado Rapids Ohio Stadium 20184 78
11002 6/8/1996 13:30 1996 6 5 3 3 Sporting Kansas City Ohio Stadium 16526 67
11003 6/19/1996 19:30 1996 6 6 2 2 Colorado Rapids Ohio Stadium 13093 78
11006 6/30/1996 15:00 1996 6 7 0 4 New York Red Bulls Ohio Stadium 17261 84
11009 7/11/1996 19:30 1996 7 8 1 1 New England Revolution Ohio Stadium 13751 68
11010 7/20/1996 19:30 1996 7 9 3 4 San Jose Earthquakes Ohio Stadium 18156 67
@matt-bernhardt
matt-bernhardt / README.md
Last active May 8, 2016 05:06
Reconstructed Passing Chord Diagram

This is an attempt to reconstruct the passing matrix for soccer players. It was originally developed by the MLS website, but then abandoned more than a year ago.