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 dual_decorator(func): | |
"""This is a decorator that converts a paramaterized decorator for no-param use.""" | |
# modified from http://stackoverflow.com/a/10288927/1231454. | |
@functools.wraps(func) | |
def inner(*args, **kw): | |
if ((len(args) == 1 and not kw and callable(args[0]) | |
# Exceptions are callable; the next line allows us to accept them as args. | |
and not (type(args[0]) == type and issubclass(args[0], BaseException)))): | |
return func()(args[0]) |
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 | |
from __future__ import print_function | |
""" | |
./%s 'cmd' <id-argname> <redef-argname> [<redef-argname>...] | |
Given the current environment: | |
IDARG=1 | |
FOO1=foovalue | |
BAR1=barvalue | |
FOO2=foo-unused |
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 contextlib import contextmanager | |
import logging | |
@contextmanager | |
def all_logging_disabled(highest_level=logging.CRITICAL): | |
""" | |
A context manager that will prevent any logging messages | |
triggered during the body from being processed. | |
:param highest_level: the maximum logging level in use. |
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 tornado | |
class RequestContextHandler(tornado.web.RequestHandler): | |
def _execute(self, transforms, *args, **kwargs): | |
# following the example of: | |
# https://github.com/bdarnell/tornado_tracing/blob/master/tornado_tracing/recording.py | |
global_data = {} # add whatever here, e.g. self.request |
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 bash | |
# executables prefix | |
_prefix="/usr/bin" | |
# git executable | |
_git="$_prefix/git" | |
# branch from which to generate site | |
_origbranch="source" | |
# branch holding the generated site |
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
find /localdisk/winter-snapshot/code/ -mindepth 2 -maxdepth 2 | xargs -P 32 -n 1 -I {} bash -c 'cd $1; git checkout -q $(git rev-list -n 1 --before="2012-11-30" $(git rev-parse --abbrev-ref HEAD)) -- || pwd' -s {} 2>&1 | tee outputfile |
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 proboscis import test, after_class, TestProgram | |
@test | |
class Test(object): | |
@after_class | |
def will_skip_but_should_not(self): | |
pass | |
@test |
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 operator import itemgetter | |
from gmusicapi import Api | |
api = Api() | |
api.login('me@gmail.com', 'my-password') | |
# => True | |
lib = api.get_all_songs() |
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.path | |
import requests | |
#Google client api imports | |
import gflags | |
import httplib2 | |
from apiclient.discovery import build | |
from oauth2client.file import Storage | |
from oauth2client.client import OAuth2WebServerFlow |
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 logging | |
import mutagen | |
log = logging.getLogger(__name__) | |
def copy_md_tags(from_fname, to_fname): | |
"""Copy all metadata from *from_fname* to *to_fname* and write. |