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 BasketBase(type): | |
| def __new__(mcs, classname, bases, class_dict): | |
| class_dict['actions'] = {} | |
| class_dict['basketactions'] = {} | |
| for elem in class_dict: | |
| if elem.startswith("action_"): | |
| class_dict['actions'][elem.replace("action_","")] = class_dict[elem] | |
| if elem.startswith("basketaction_"): | |
| class_dict['basketactions'][elem.replace("basketaction_","")] = class_dict[elem] | |
| for elem in class_dict.keys(): |
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
| function! PyLintCwindow() | |
| " some comment | |
| if g:pymode_lint_cwindow == 1 | |
| let g:pymode_lint_cwindow = 0 | |
| else | |
| let g:pymode_lint_cwindow = 1 | |
| endif | |
| endfunction |
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
| function rconfirm(){ | |
| if [[ ${SSH_CONNECTION:0} != 0 ]];then | |
| local confirm | |
| echo " ___ " | |
| echo "{o,o}" | |
| echo "|)__)" | |
| echo "-\"-\"-" | |
| echo "O RLY?" | |
| read -q confirm |
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
| global !p | |
| def fb(string, c=0): | |
| '''Count brackets''' | |
| left_bracket = string.find("(") | |
| if left_bracket > -1: | |
| string = string[left_bracket + 1:] | |
| right_bracket = string.find(")") | |
| if right_bracket > -1: | |
| if string[:right_bracket].find("(") == -1: | |
| c += 1 |
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
| function! RunDoctests() | |
| let fname = expand('%:p') | |
| :w<cr> :vne | |
| :set ft=python | |
| :set buftype=nofile | |
| :setlocal noswapfile | |
| :exec ':silent r!python2 -m doctest -f' fname | |
| endfunction | |
| autocmd FileType python nnoremap T :call RunDoctests()<cr> |
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
| redir => lsoutput | |
| !ls /home/pielgrzym/.vimsessions | |
| redir END | |
| return split(lsoutput, '\r')[1:] |
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
| #!/bin/zsh | |
| i=1 | |
| sp="/-\|" | |
| echo -n ' ' | |
| while true | |
| do | |
| printf "\b${sp:i++%${#sp}:1}" | |
| done |
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
| better_which(){ | |
| tput smcup | |
| local -i i="$1" | |
| shift | |
| while : ; do | |
| tput clear | |
| "$@" | |
| sleep $i | |
| trap 'break' 2 | |
| done |
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
| watch_todo(){ | |
| tput smcup | |
| while : ; do | |
| tput clear | |
| echo -n "${bg[cyan]}[[[ TODO: ]]]$reset_color\n" | |
| if [[ -n $1 ]]; then | |
| todo.sh "$@" | |
| else | |
| todo.sh ls | |
| fi |
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 mean(Z): | |
| def sr(x, y): | |
| cnt = x[1] + 1 | |
| return x[0]+y, cnt, (x[0]+y)/cnt | |
| return reduce(sr, Z, [0,0,0])[2] | |
| assert mean([1,2,3]) == 2 | |
| assert mean([1.5, 2.5, 3.5]) == 2.5 | |
| assert mean([1]) == 1 | |
| assert mean([-2.0, 2.0, 0.0]) == 0 |