Skip to content

Instantly share code, notes, and snippets.

View amjith's full-sized avatar
🐐

Amjith Ramanujam amjith

🐐
View GitHub Profile
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
@amjith
amjith / framework_web.py
Created August 14, 2012 00:16
instrument_webpy
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
@amjith
amjith / hello.py
Created July 5, 2012 20:16
Simple WSGI App
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):
@amjith
amjith / profile_func.py
Created October 13, 2011 04:22
Profiling decorator
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__))
@amjith
amjith / PrintParser.py
Created November 12, 2010 07:06
Python script to parse user input to a list of numbers
#!/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("")
[]