Skip to content

Instantly share code, notes, and snippets.

View toastdriven's full-sized avatar

Daniel Lindsley toastdriven

View GitHub Profile
@toastdriven
toastdriven / import_order.py
Created June 18, 2014 17:43
My preferred import ordering/style for Python code.
# Python *built-ins*
import datetime
import os
import time
# Pip-installed *Python* libraries
import boto
import requests
# Django *built-ins*
@toastdriven
toastdriven / sc2_must_watches.md
Last active July 11, 2016 19:30
Must-Watch VODs for any SC2 player
from django.contrib.auth.models import User
from tastypie import fields
from tastypie.resources import ModelResource
from profiles.models import Profile
class UserResource(ModelResource):
# Assumes a OneToOneField on the ``Profile``.
bio = fields.CharField(attribute='profile__bio', blank=True, default='', readonly=True)
website = fields.CharField(attribute='profile__website', blank=True, default='', readonly=True)
@sebleier
sebleier / gist:1473587
Created December 13, 2011 19:49
Big-Q notation

Big-Q Notation

Big-Q notation is exactly the same as Big-O notation, except for the understanding that the constant multiplier for the asymptotic bound function is greater.

For example Big-O is defined as:

f(x) <= C * g(x)

Big-Q notation could be defined as:

import operator
from haystack.query import SearchQuerySet, SQ
stuff = ['foo', 'bar', 'baz']
the_filters = reduce(operator.or_, [SQ(tag=tag_name) for tag_name in stuff])
sqs = SearchQuerySet().filter(the_filters)
@toastdriven
toastdriven / profiling.rst
Created November 9, 2011 06:42
Getting QCacheGrind Running & Working With Python Profilers

Get QCacheGrind Running

  • brew install qt --with-qt3support
  • brew install graphviz
  • sudo ln -s /usr/local/bin/dot /usr/bin/dot (?)
  • svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdesdk/kcachegrind kcachegrind
  • cd kcachegrind/qcachegrind
  • qmake -spec 'macx-g++'
  • make
@dennmart
dennmart / .osx
Created September 8, 2011 18:54
Sensible defaults for Mac OS X Lion
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Enable the 2D Dock
defaults write com.apple.dock no-glass -bool true
# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true
# Disable menu bar transparency
@toastdriven
toastdriven / mytwilight.tmTheme
Created July 29, 2011 16:04 — forked from epicserve/sublime_text_2_notes.md
My Sublime Text 2 Setup
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Daniel Lindsley</string>
<key>name</key>
<string>My Twilight</string>
<key>settings</key>
<array>
@carljm
carljm / postactivate
Created July 12, 2011 18:21
Yo dawg, I heard you like Ruby...
#!/bin/bash
# This hook is run after every virtualenv is activated.
export OLD_GEM_HOME=$GEM_HOME
export GEM_HOME=$VIRTUAL_ENV/gems/
export GEM_PATH=
export PATH=$VIRTUAL_ENV/gems/bin:$PATH
@zyegfryed
zyegfryed / gist:814432
Created February 7, 2011 14:25
Tastypie OAuth
from oauth2 import Error
from django.utils.translation import ugettext as _
from tastypie.authentication import Authentication
from oauth_provider.utils import initialize_server_request, send_oauth_error, get_oauth_request
from oauth_provider.consts import OAUTH_PARAMETERS_NAMES
from oauth_provider.store import store, InvalidTokenError