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 | |
def convert(inp): | |
""" | |
* Get the input from user. | |
* Parse the input to extract numbers | |
** Split by comma | |
*** Each item in the list will then be split by '-' | |
**** Populate the number between a-b using range(a,b) | |
>>> convert("") | |
[] |
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 profile_func(filename=None): | |
def proffunc(f): | |
def profiled_func(*args, **kwargs): | |
import cProfile | |
import logging | |
logging.info('Profiling function %s' % (f.__name__)) | |
try: | |
profiler = cProfile.Profile() | |
retval = profiler.runcall(f, *args, **kwargs) | |
profiler.dump_stats(filename or '%s_func.profile' % (f.__name__)) |
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 time import sleep | |
import newrelic.agent | |
newrelic.agent.initialize('newrelic.ini') | |
@newrelic.agent.wsgi_application() | |
def hello_world(environ, start_response): | |
path = environ.get('PATH_INFO') | |
if path.startswith('/slow'): | |
for _ in range(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 sys | |
import newrelic.api.transaction | |
import newrelic.api.function_trace | |
import newrelic.api.in_function | |
import newrelic.api.out_function | |
import newrelic.api.pre_function | |
import newrelic.api.name_transaction | |
from newrelic.api.object_wrapper import callable_name | |
from newrelic.api.web_transaction import WSGIApplicationWrapper |
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
asld |
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 sys | |
import newrelic.api.transaction | |
import newrelic.api.function_trace | |
import newrelic.api.in_function | |
import newrelic.api.out_function | |
import newrelic.api.pre_function | |
import newrelic.api.name_transaction | |
from newrelic.api.object_wrapper import callable_name | |
from newrelic.api.web_transaction import WSGIApplicationWrapper |
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 sys | |
from newrelic.api.function_trace import FunctionTrace | |
from newrelic.api.object_wrapper import ObjectWrapper | |
from newrelic.api.transaction import current_transaction | |
from newrelic.api.pre_function import wrap_pre_function | |
def wrap_handle_exception(*args): | |
transaction = current_transaction() | |
if transaction: |
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.ioloop | |
import tornado.web | |
import os | |
HERE = os.path.dirname(__file__) | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): | |
#self.render(HERE+'fileuploadform.html') | |
self.render('/Users/amjith/playground/python/tornado/async_api/fileuploadform.html') |
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 time import sleep | |
from webtest import TestApp | |
import newrelic.agent | |
newrelic.agent.initialize('newrelic.ini') | |
def hello_world(environ, start_response): | |
path = environ.get('PATH_INFO') | |
if path.startswith('/slow'): |
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 __future__ import print_function | |
import base64 | |
import six | |
#def _encode(name, key): | |
#s = [] | |
#for i in range(len(name)): | |
#s.append(chr(ord(name[i]) ^ ord(key[i % len(key)]))) | |
#return s |
OlderNewer