Useful coding notes that I come across
git diff [branch_1] [branch_2] | pep8 --diff
https://github.com/darold/pgFormatter http://people.planetpostgresql.org/dfetter/index.php?/archives/78-Formatting!.html
import pdb; pdb.set_trace();
import pdb, traceback, sys
def bombs():
a = []
print a[0]
if __name__ == '__main__':
try:
bombs()
except:
type, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
You could do this while in pdb to launch a temporary interactive Python session with all the local variables available:
(pdb) !import code; code.interact(local=vars())
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>
Single line list of keys from dictionary
[key for key, value in dictionary.iteritems()]
import inspect
inspect.getmembers([class], predicate=inspect.ismethod)
git grep [options] [-e] [...] [[--] ...]
https://pypi.python.org/pypi/pep8radius
on Mac
copy selected part: visually select text(type v or V in normal mode) and type :w !pbcopy
copy the whole file :%w !pbcopy
past from the clipboard :r !pbpaste
https://wiki.python.org/moin/Vim
#!/usr/bin/env python
"""
Python source code - replace this with a description of the code and write the code below this text.
"""
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
https://realpython.com/blog/python/asynchronous-tasks-with-django-and-celery/
https://hg.python.org/cpython/file/3dc602b1f4a2/Lib/test/test_threading.py
.vimrc
":set mouse=a"
"set mouse=nicr"
"remove .swp files"
set noswapfile
set ruler
"highlight text"
syntax on
" number tab"
if exists("+showtabline")
function MyTabLine()
let s = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= '%' . i . 'T'
let s .= (i == t ? '%1*' : '%2*')
let s .= ' '
let s .= i . ')'
let s .= ' %*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let file = bufname(buflist[winnr - 1])
let file = fnamemodify(file, '%@')
if file == ''
let file = '[No Name]'
endif
let s .= file
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
return s
endfunction
set stal=2
set tabline=%!MyTabLine()
endif
kubectl -n kube-system describe secret default
Export environment variables from file
set -o allexport
source conf-file
set +o allexport