import logging
log = logging.getLogger(__name__)
from sqlalchemy import event
from sqlalchemy.engine import Engine
event.listen(Engine, "before_cursor_execute",
lambda conn, cursor, statement,
parameters, context,
executemany: log.info(statement, parameters))
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
| """ | |
| Write a class Calculator in Python that should implement `add` functionality of 2 numbers. | |
| As a user of this class I should be able to make such call "calculator.add(2, 3)". Constructor implementation is of your choice. | |
| If any of numbers is < 1000 class will calculate in memory. | |
| If both numbers are >= 1000 class will calculate via http call to remote server. | |
| If both numbers are >= 100000 class will calculate via SOAP call | |
| Make sure that your Calculator is SOLIDly designed | |
| """ | |
| import abc |
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
| # based on http://serverfault.com/a/96500 | |
| # http://serverfault.com/a/96500 | |
| sudo curl https://gist.githubusercontent.com/howthebodyworks/176149/raw/88d0d68c4af22a7474ad1d011659ea2d27e35b8d/supervisord.sh > /etc/init.d/supervisord | |
| sudo chmod +x /etc/init.d/supervisord | |
| sudo update-rc.d supervisord defaults | |
| # now you can do such things as |
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
| # Orignal version taken from http://www.djangosnippets.org/snippets/186/ | |
| # Original author: udfalkso | |
| # Modified by: Shwagroo Team and Gun.io | |
| import sys | |
| import os | |
| import re | |
| import hotshot, hotshot.stats | |
| import tempfile | |
| import StringIO |
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 ExceptionLoggingMiddleware(object): | |
| def process_exception(self, request, exception): | |
| import traceback | |
| print traceback.format_exc() |