Skip to content

Instantly share code, notes, and snippets.

View commadelimited's full-sized avatar

Andy Matthews commadelimited

View GitHub Profile
@commadelimited
commadelimited / flask.py
Created November 23, 2014 06:21
Multiple Flask URL routes on a single method
@course.route('/courses/<slug>_<id>/print/')
@course.route('/courses/<slug>_<id>/')
def show_course(slug=None, id=None):
# how do I know whether /print was used, or just normal?
pass
@commadelimited
commadelimited / harlem-shake.js
Created February 15, 2013 02:38
Harlem Shake Bookmarklet deconstructed
javascript: (function () {
function c() {
var e = document.createElement("link");
e.setAttribute("type", "text/css");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", f);
e.setAttribute("class", l);
document.body.appendChild(e)
}
function h() {
@commadelimited
commadelimited / models.py
Last active November 21, 2020 08:33
Looping over an object somehow adds an extra two interactions
class StudentAssignments(BaseModel):
assignment = ForeignKeyField(Assignment)
student = ForeignKeyField(User)
grade = IntegerField(null=True)
@commadelimited
commadelimited / timing.py
Created November 12, 2019 21:12
Test the time difference between directly accessing properties on a nested object, vs saving an intermediate variable.
# importing the required module
import timeit
# code snippet to be executed only once
setup = """
class FauxClass(object):
pass
page = FauxClass()
page.url = 'the url'
@commadelimited
commadelimited / bgg_games.py
Last active September 29, 2018 16:53
Show the owned games overlap of two BGG users
########################################
# DO NOT CHANGE ANYTHING BELOW THIS LINE
########################################
import sys
from boardgamegeek.api import BoardGameGeek
bgg = BoardGameGeek()

Keybase proof

I hereby claim:

  • I am commadelimited on github.
  • I am commadelimited (https://keybase.io/commadelimited) on keybase.
  • I have a public key ASAQmZtWglS2Z-B6hCkNWza35Z27cYczUaVejn80xPvBqgo

To claim this, I am signing this object:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
How many unique, simultaneous, players can my board game collection support?
"""
import sys
from boardgamegeek import BGGClient
# -*- coding: utf-8 -*-
from boardgamegeek.api import BGGClient
from slugify import slugify as slug
print 'Generate hashtags!'
game_id = raw_input("BGG game id: ")
bgg = BGGClient()
bgg_game = bgg.game(game_id=game_id)
@commadelimited
commadelimited / bgg_designers.py
Created March 6, 2017 21:51
Pull a list of unique played games for X-Y time period, print game name, id, designers, and play count.
from datetime import datetime
from boardgamegeek.api import BoardGameGeek
bgg = BoardGameGeek()
username = 'commadelimited'
start = '2013-01-01'
end = '2017-03-07'
mindate = datetime.strptime(start, '%Y-%m-%d')
maxdate = datetime.strptime(end, '%Y-%m-%d')
@commadelimited
commadelimited / config.ru
Last active October 24, 2016 05:32
Config.ru example
use Rack::Static,
:urls => ["/images", "/js", "/css", "/data"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'