Skip to content

Instantly share code, notes, and snippets.

View a-milogradov's full-sized avatar

alexey.milogradov a-milogradov

View GitHub Profile
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()
EZschedule tests
All data generated with random data
# Number of objects:
In [95]: Complex.objects.count()
Out[95]: 1000
In [96]: Facility.objects.count()
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
@a-milogradov
a-milogradov / vimrc
Created December 21, 2014 14:28
vimrc
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
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
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)