Skip to content

Instantly share code, notes, and snippets.

View jefftriplett's full-sized avatar
Living the dream

Jeff Triplett jefftriplett

Living the dream
View GitHub Profile
@jefftriplett
jefftriplett / signals.py
Last active April 1, 2016 08:43 — forked from voldmar/signals.py
Django management command to trace / list all signals. My fork is just a few cleanups where CommandError wasn't referenced, etc.
# coding:utf-8
import gc
import inspect
import weakref
from django.core.management.base import BaseCommand, CommandError
from django.dispatch import Signal, saferef
from optparse import make_option
@jefftriplett
jefftriplett / gist:5851007
Last active December 18, 2015 21:59
Taming the new Django Docs banner.
// ==UserScript==
// @name Django Docs Banner removal
// @namespace http://use.i.E.your.homepage/
// @version 0.0.2
// @description Removes the annoying "dev-warning" at the top of the website.
// @include https://docs.djangoproject.com/*
// @copyright 2013+, Jeff Triplett (Update by @fcurella)
// ==/UserScript==
@jefftriplett
jefftriplett / whyslow.md
Last active December 17, 2015 03:09
pip outdated --list slowness

pip-outdated without caching

$ time pip-outdated.py --clear
rebuilding package-cache...
# bad package name, skipping...
# bad package name, skipping...
# bad package name, skipping...
# bad package name, skipping...
altgraph (0.9 != 0.10.2)

bonjour-py is not available on PyPI

@jefftriplett
jefftriplett / requests_forecast.py
Created March 28, 2013 04:25
Quick and dirty forecast.io wrapper.
import datetime
import pytz
import requests
import time as time_mod
FORECAST_TEMPLATE = 'https://api.forecast.io/forecast/{apikey}/{latitude},{longitude}{time}{si}'
class Forecast(object):
@jefftriplett
jefftriplett / ncaa-bracket-2013.md
Last active December 15, 2015 05:49
2013 NCAA Men's Basketball Guess

2013 NCAA Men's Basketball

I modified bracket-maker and ran my own custom dataset. KU came out the winner 4 out of the first 7 times I ran the data. Hardly scientific but I liked the results so I thought it might be fun to post publicly. If only the actual tournament worked like this.

Midwest

round 1

Louisville (1) vs. North Carolina A&T (16)
winner: Louisville (1)

@jefftriplett
jefftriplett / default.md
Last active December 14, 2015 16:59
Github responsive resize weirdness
try:
from urllib.parse import parse_qs
parse_qs # placate pyflakes
except ImportError:
try:
from urlparse import parse_qs
except ImportError:
# fall back for Python 2.5
from cgi import parse_qs
@jefftriplett
jefftriplett / views.py
Created March 1, 2013 16:35
Using Django 1.5's StreamingHttpResponse
"""
Demo adapted from this stackoverflow question:
http://stackoverflow.com/questions/2922874/how-to-stream-an-httpresponse-with-django
- Updated `HttpResponse` to use `StreamingHttpResponse`
- I changed the blank spaces from 1024 to 10240 so that my browser would
update every second vs. every 4 seconds.
"""
@jefftriplett
jefftriplett / gist:4996644
Created February 20, 2013 16:04
digitalocean quick stats
root@server2013:~# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 2
model name : QEMU Virtual CPU version 1.0
stepping : 3
microcode : 0x1
cpu MHz : 1999.999
cache size : 4096 KB
import os
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))