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
| ### Keybase proof | |
| I hereby claim: | |
| * I am pielgrzym on github. | |
| * I am pielgrzym (https://keybase.io/pielgrzym) on keybase. | |
| * I have a public key whose fingerprint is 661F 1ECA AD56 830A 98CC AC29 6549 E7D0 F0EB 09F8 | |
| To claim this, I am signing this object: |
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 OV | |
| def vals | |
| ['a', 'b', 'c'] | |
| end | |
| # this will make this work: | |
| # OV.new == 'a' | |
| # true | |
| # OV.new == 'b' | |
| # true |
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
| import sys | |
| import functools | |
| class der(object): | |
| def __init__(self, h): | |
| if isinstance(h, float): | |
| self.h = h | |
| else: | |
| self.h = sys.float_info.epsilon*1000 |
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 |
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
| 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
| #!/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
| 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
| 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
| 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 |
NewerOlder