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
def who_called_me(show_filename=False, out=None, indent=' '): | |
def _wrapper(fn): | |
def _inner_wrapper(*args, **kwargs): | |
import sys | |
import inspect | |
output = out or sys.stdout | |
assert hasattr(output, 'write'), \ | |
'argument \'out\' of function \'who_called_me\' must have a write method' | |
index = 0 | |
stack = inspect.stack() |
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
EZschedule tests | |
All data generated with random data | |
# Number of objects: | |
In [95]: Complex.objects.count() | |
Out[95]: 1000 | |
In [96]: Facility.objects.count() |
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 SomeView(View): | |
def dispatch(self, request, *args, **kwargs): | |
# imports and start profiling | |
import cProfile, pstats, StringIO | |
pr = cProfile.Profile() | |
pr.enable() | |
# all logic runs here |
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
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required |
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
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required |
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
def generate_script_from_xls(xls_name, table, cols, types): | |
cur.execute("delete from {}".format(table)) | |
xl_book = xlrd.open_workbook(unicode(xls_name, "utf-8"), formatting_info=True) | |
sheet = xl_book.sheet_by_index(0) | |
dot_index = len(xls_name) - xls_name[::-1].index('.') - 1 | |
script_name = xls_name[:dot_index] + ".txt" | |
comma_separated_cols = ", ".join(cols) |