Skip to content

Instantly share code, notes, and snippets.

@allisontharp
allisontharp / NHLBracket.py
Last active April 11, 2018 22:31
Generate a radial NHL bracket where your favorite team wins it all! Simulates a 50/50 chance of winning per game. The team with the best of 7 moves on! The console output will show the total number of games for each matchup. The idea came from JohnMLTX's awesome plot on reddit: https://www.reddit.com/r/hockey/comments/8b3ry6/heres_my_radial_brac…
import random
import numpy as np
import matplotlib.pyplot as plt
favoriteTeam = 'TBL'
eastern = ((('TBL', 'NJD'), ('BOS', 'TOR')), (('WSH', 'CBJ'), ('PIT', 'PHI')))
western = ((('NSH', 'COL'), ('WPG', 'MIN')), (('VGK', 'LAK'), ('ANA', 'SJS')))
championship = (eastern, western)
@allisontharp
allisontharp / GameRecommendationByGame.py
Created February 13, 2018 14:23
Input a game you like and it will output games that people who liked that game also like
import pandas as pd
import numpy as np
from scipy.sparse import csr_matrix
import pymysql
from fuzzywuzzy import fuzz
# display results to 3 decimal points, not in scientific notation
pd.set_option('display.float_format', lambda x: '%.3f' % x)
SELECT currentRank.rank, currentRank.bggid, IFNULL(g.name, currentRank.bggid) AS gameName, historicalRank.RowNumber AS StreakInDays
FROM
(
SELECT hg.bggid, hg.rank
FROM hotgame AS hg
WHERE DATE(hg.date) = CURDATE()
) AS currentRank
JOIN
(
SELECT
import sqlite3
from datetime import datetime, date
from operator import itemgetter
firstmonth = '2016-05'
lastmonth = '2016-06'
# Connect to SQLite Database
import glob
from PIL import Image, ImageDraw, ImageFont, PdfImagePlugin, _imaging ## was from PIL
from math import ceil
import os
badge_loc = 'border2.png' # badge template
filename = 'names3.txt' # text file with names
import nflgame as n
import time, smtplib
def send(SUBJECT, TEXT):
gmail_user = 'you@emailaddress.com'
gmail_pwd = 'YourVerySecurePassword'
server = smtplib.SMTP("smtp.gmail.com", 587)
import sqlite3
import matplotlib.pyplot as plt
import numpy as np
db_loc = 'gencon_test.sqlite'
conn = sqlite3.connect(db_loc)
c = conn.cursor()
"""
Pull hotness data from BGG (wwww.boardgamegeek.com) and put into SQLite Db
"""
from datetime import datetime, date
from xml.dom import minidom
import sqlite3, unicodedata, urllib2, time, sys
def translate(name):
try:
@allisontharp
allisontharp / boardgame_inventory_scanner.py
Last active July 14, 2016 23:04
Added check in/out function
import requests
import mysql.connector
from xml.dom import minidom
import urllib2, sys, re
from BeautifulSoup import BeautifulSoup as bs
menu_select = "1"
# to do: check to see if inventory table exists. If not, create it.
# to do: check to see if replica bgg database exists. If not, don't use it.
from xml.dom.minidom import parse
import matplotlib.pyplot as plt
import sqlite3, urllib2, unicodedata, time
import numpy as np
import sys
def strip_accents(s):
return ''.join(c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn')