Skip to content

Instantly share code, notes, and snippets.

View hitch17's full-sized avatar

John hitch17

View GitHub Profile
@hitch17
hitch17 / easy_py_objects.py
Last active October 1, 2020 23:01
Code for the blog post "MySQL and CSV to Python Objects (Made Easy)" on eng.kaching.com
# unnecessary for DictObj, but the other code uses it.
import urllib2
import csv
import os
class DictObj ( dict ):
"A wrapper for dictionaries that feel like py objects"
def __getattr__(self, key):
if key in self:
return self[key]

Keybase proof

I hereby claim:

  • I am hitch17 on github.
  • I am hitch (https://keybase.io/hitch) on keybase.
  • I have a public key whose fingerprint is 8C6B D25F C68C 2B5E B7E2 CF81 D308 D239 5FD4 F99A

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am hitch17 on github.
  • I am hitch (https://keybase.io/hitch) on keybase.
  • I have a public key whose fingerprint is F787 A88D 6736 B8CD BEB5 154C 7058 33C9 47EE F02B

To claim this, I am signing this object:

@hitch17
hitch17 / fantasy-team-comparison.r
Created January 24, 2012 21:04
Computes mean, standard deviation, win percentage and pythagorean expectation from results of fantasy sports matchups, and graphs them.
library(reshape)
matchups <- read.csv('league-matchups.csv') # dont forget to set working directory or change the full path
league.sd <- sd(matchups$team_actual_points)
league.mean <- mean(matchups$team_actual_points)
weeks <- max(matchups$week)
team.melted <- melt(matchups, id.vars="place", measure.vars="team_actual_points")
places <- cast(team.melted, place ~ variable, fun.aggregate=mean)$place