This file contains hidden or 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 logging | |
# http://stackoverflow.com/a/1049375/407954 | |
class MockHandler(logging.Handler): | |
def __init__(self, *args, **kwargs): | |
self.reset() | |
logging.Handler.__init__(self, *args, **kwargs) | |
def emit(self, record): | |
self.messages[record.levelname.lower()].append(record.getMessage()) |
This file contains hidden or 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
(function($) { | |
$.scrape = function(options) { | |
options = options || {}; | |
var el, page = [], clone; | |
// start with doctype | |
page.push('<!doctype html>'); | |
// build the html tag since this cannot be captured as a child |
This file contains hidden or 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
view = DataView(...) | |
context = DataContext(...) | |
queryset = view.apply(context.apply()) | |
iterator = queryset.raw() | |
for row in iterator: | |
pass |
This file contains hidden or 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
(function(root, factory) { | |
if (typeof define == 'function' && define.amd) { | |
define(['jquery'], function(jQuery) { | |
factory(jQuery); | |
}); | |
} else { | |
factory(root.jQuery); | |
} | |
})(this, function(jQuery) { |
This file contains hidden or 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
var jsondiff = (function() { | |
// Patch helper functions | |
function getParent(paths, path) { | |
return paths[path.substr(0, path.match(/\//g).length)]; | |
} | |
// Checks if `obj` is an array or object | |
function isContainer(obj) { | |
return _.isArray(obj) || _.isObject(obj); |
This file contains hidden or 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 inspect | |
from django.conf import settings | |
from django.utils.importlib import import_module | |
from django.core.exceptions import ImproperlyConfigured | |
class AlreadyRegistered(Exception): | |
pass | |
This file contains hidden or 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 flatten(l, output=None): | |
if output is None: | |
output = [] | |
for x in l: | |
if isinstance(x, (list, tuple)): | |
flatten(x, output) | |
else: | |
output.append(x) | |
return output |
This file contains hidden or 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
" Set color scheme according to current time of day. | |
let hr = str2nr(strftime('%H')) | |
if hr <= 6 || hr > 18 | |
let cs = 'Tomorrow-Night' | |
else | |
let cs = 'Tomorrow' | |
endif | |
execute 'colorscheme '.cs |
This file contains hidden or 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 LdapBackend(ModelBackend): | |
"""Authenticate a user against LDAP. | |
Requires python-ldap to be installed. | |
Requires the following things to be in settings.py: | |
DEBUG - boolean | |
Uses logging module for debugging messages. |
This file contains hidden or 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
" Kick off pathogen | |
call pathogen#infect() | |
" Base | |
set autochdir " change to cwd | |
set autoindent " indent on next line | |
set backspace=2 " allow backspace over indent, eol, start insert | |
set colorcolumn=80 " color column 80 | |
set nocompatible " explicitly turn off compaitable mode with Vi | |
set cursorbind " move cursor to corresponding line and column |