Skip to content

Instantly share code, notes, and snippets.

@bdilday
bdilday / LICENSE.txt
Last active October 3, 2016 20:35
Device orientation for brushing with a mouseover fallback
The MIT License (MIT)
Copyright (c) 2016 Ben Dilday
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.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SO
@bdilday
bdilday / header.csv
Last active September 25, 2016 23:21
teamid yearid playerid pa namefirst namelast namefrac nameweight birthcountry
@bdilday
bdilday / README.MD
Last active September 16, 2016 05:20
lineup PCA

csv file of lineup slot and fielding position for baseball lineups going back to 1902

@bdilday
bdilday / README.md
Last active September 1, 2016 02:51
list of pitcher - catcher combinations (for old timey catcher metrics)

the data for the following R pub

@bdilday
bdilday / result.csv
Last active August 24, 2016 21:10
richie ashburn POs
year home_away withPitcher IPouts BIP AshburnPO
1950 away boroh101 9 8 0
1950 home boroh101 3 5 0
1950 away britj102 5 6 0
1950 home britj102 6 5 1
1950 away candm101 25 34 2
1950 home candm101 31 38 5
1950 away churb101 162 181 24
1950 home churb101 206 236 24
1950 away donnb101 37 44 3
@bdilday
bdilday / main.py
Last active August 11, 2016 02:01
batted ball smoother
from __future__ import print_function
import numpy as np
import sys
import json
def csvToArray(csvfile, skeys=[], ikeys=[], fkeys=[], delimiter=',', vbose=0):
ifp = open(csvfile,'r')
hd = ifp.next()
alias pip-upgrade-all="echo 'pip list -o | cut -d \" \" -f1 | xargs -n1 pip install -U'; pip list -o | cut -d ' ' -f1 | xargs -n1 pip install -U"
@bdilday
bdilday / cumulativeRunDifferential_1871_2015.csv
Last active July 31, 2016 04:29
cumulative run differential for MLB teams from 1871-2015
We can't make this file beautiful and searchable because it's too large.
"team","year","gameNumber","cumulativeRunDifferential"
"CL1",1871,1,-2
"BS1",1871,1,2
"CL1",1871,2,6
"CL1",1871,3,4
"BS1",1871,2,6
"CH1",1871,1,8
"WS3",1871,1,4
"CH1",1871,2,17
"WS3",1871,2,-2
from __future__ import print_function
import copy
class permutor:
def __init__(self, infile='curley_seq.txt', max_entries=-1):
self.indata = self.read_infile(infile)
if max_entries>0:
self.indata = self.indata[0:max_entries]
year_id dsc awo swo krate bbr h1r h2r h3r h4r aruns n
1961 -9.0 0.3179 0.0164 0.1667 0.0444 0.1333 0.0000 0.0000 0.0444 0.4556 90
1961 -8.0 0.3215 0.0167 0.0878 0.1081 0.2095 0.0203 0.0135 0.0203 0.6419 148
1961 -7.0 0.3229 0.0170 0.1476 0.1000 0.1381 0.0286 0.0143 0.0190 0.4905 210
1961 -6.0 0.3202 0.0168 0.1463 0.0718 0.1729 0.0399 0.0053 0.0239 0.5479 376
1961 -5.0 0.3191 0.0167 0.1317 0.0872 0.1477 0.0196 0.0071 0.0356 0.4893 562
1961 -4.0 0.3196 0.0176 0.1088 0.0925 0.1513 0.0425 0.0063 0.0350 0.4600 800
1961 -3.0 0.3200 0.0172 0.1332 0.0806 0.1620 0.0354 0.0066 0.0288 0.4893 1216
1961 -2.0 0.3211 0.0177 0.1257 0.0821 0.1478 0.0385 0.0074 0.0277 0.4655 1766
1961 -1.0 0.3207 0.0180 0.1472 0.0791 0.1667 0.0362 0.0060 0.0259 0.4504 2351