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 newrelic.agent | |
newrelic.agent.initialize('staging.ini') | |
newrelic.agent.register_application(timeout=10.0) | |
def add(a, b): | |
return a + b | |
def sub(a, b): | |
return a - b |
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
Traceback (most recent call last): | |
File "/usr/local/bin/pip", line 5, in <module> | |
from pkg_resources import load_entry_point | |
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2912, in <module> | |
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 550, in _build_master | |
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 563, in _build_from_requirements | |
keys2.append(dist.key) | |
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 742, in resolve |
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
set -g -x PATH $HOME/bin /usr/local/bin $PATH /usr/X11/bin | |
set -g -x TERM xterm-256color | |
# Rbenv settings | |
set -gx RBENV_ROOT /usr/local/var/rbenv | |
. (rbenv init -|psub) | |
# Docker boot2docker | |
set -g -x DOCKER_CERT_PATH /Users/amjith/.boot2docker/certs/boot2docker-vm | |
set -g -x DOCKER_TLS_VERIFY 1 |
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
# Part of a package named foo. | |
__all__ = [] | |
def export(defn): | |
"""Decorator to explicitly mark functions that are exposed in a lib.""" | |
globals()[defn.__name__] = defn | |
__all__.append(defn.__name__) | |
return defn |
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 sys | |
@contextmanager | |
def export(): | |
print "Enter:" | |
yield | |
print sys._getframe(2).f_locals | |
print "Exit" |
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 wrapt | |
class NotFlask(): | |
def __init__(self): | |
self.routes = {} | |
#def route(self, route_str): | |
#@wrapt.decorator | |
#def decorator(f, instance, args, kwargs): | |
#self.routes[route_str] = f |
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
>>> collection = ['django_migrations.py', | |
'django_admin_log.py', | |
'main_generator.py', | |
'migrations.py', | |
'api_user.doc', | |
'user_group.doc', | |
'accounts.txt', | |
] |
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 re # regex module from standard library. | |
>>> def fuzzyfinder(user_input, collection): | |
suggestions = [] | |
pattern = '.*'.join(user_input) # Converts 'djm' to 'd.*j.*m' | |
regex = re.compile(pattern) # Compiles a regex. | |
for item in collection: | |
match = regex.search(item) # Checks if the current item matches the regex. | |
if match: | |
suggestions.append(item) | |
return suggestions |
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
'main_generator.py' - 0 | |
'migrations.py' - 0 | |
'django_migrations.py' - 7 | |
'django_admin_log.py' - 9 |
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 re # regex module from standard library. | |
>>> def fuzzyfinder(user_input, collection): | |
suggestions = [] | |
pattern = '.*'.join(user_input) # Converts 'djm' to 'd.*j.*m' | |
regex = re.compile(pattern) # Compiles a regex. | |
for item in collection: | |
match = regex.search(item) # Checks if the current item matches the regex. | |
if match: | |
suggestions.append((match.start(), item)) | |
return [x for _, x in sorted(suggestions)] |