This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import datetime | |
import sys | |
# Pass your OAuth token | |
token = sys.argv[1] | |
# Fetch all private repos (lazy - assumes only two pages) | |
headers = {'Authorization': 'token %s' % token} | |
response = requests.get( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from django.db import connection | |
def setUp(): | |
""" | |
Create custom database tables before test suite runs | |
""" | |
execute_from_file('stores_table.sql') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ================================================== | |
" VIMRC file for David Winterbottom (@codeinthehole) | |
" ================================================== | |
" Inspiration {{{ | |
" ----------- | |
" See http://www.youtube.com/watch?v=aHm36-na4-4 | |
" | |
" Good articles: | |
" - http://alexpounds.com/blog/2014/06/06/the-vimrc-antiques-roadshow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
# Open the Github page for the... | |
# ...repo homepage (included for consistency) | |
open = !hub browse -- | |
# ...repo commits | |
opencommits = !hub browse -- commits | |
# ...commit page for HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TangentLabs_Sniffs_BestPractice_SensibleTernarysSniff implements PHP_CodeSniffer_Sniff | |
{ | |
/** | |
* @return array | |
*/ | |
public function register() | |
{ | |
return array(T_INLINE_THEN); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TwillTestCase(TestCase): | |
""" | |
Simple wrapper around Twill to make writing TestCases easier. | |
Commands availabel through self.command are: | |
- go -> visit a URL | |
- back -> back to previous URL | |
- reload -> reload URL | |
- follow -> follow a given link | |
- code -> assert the HTTP response code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from logging import FileHandler as BaseFileHandler | |
import os | |
class EnvFileHandler(BaseFileHandler): | |
""" | |
Custom filehandler that uses the LOG_ROOT setting to determine the folder | |
to store log files in. | |
We have to do some tricky stuff to avoid circular imports. To this end, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def curry(f, *args, **kwargs): | |
def curried(*more_args, **more_kwargs): | |
return f(*(args+more_args), **dict(kwargs, **more_kwargs)) | |
return curried | |
class Person(object): | |
def __init__(self, name, gender): | |
self.name = name | |
self.gender = gender |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Extract version number from setup.py | |
RELEASE_NUM=`grep version setup.py | cut -d\' -f2` | |
# Push to PyPi | |
python setup.py sdist upload | |
# Tag in Git and push to remote | |
git tag $RELEASE_NUM -m "Tagging release $RELEASE_NUM" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
from optparse import OptionParser | |
import unittest | |
from collections import defaultdict | |
# Constants for each hand | |
ROYAL_STRAIGHT_FLUSH = 10 | |
STRAIGHT_FLUSH = 9 | |
FOUR_OF_A_KIND = 8 |
OlderNewer