A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python - |
| #!/bin/zsh | |
| # pyenv install for CentOS 6.5 x86_64 | |
| yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel zlib libffi-devel | |
| git clone git://github.com/yyuu/pyenv.git ~/.pyenv | |
| export PATH="$HOME/.pyenv/bin:$PATH" | |
| eval "$(pyenv init -)" |
| #!/bin/bash | |
| # bash generate random alphanumeric string | |
| # | |
| # bash generate random 32 character alphanumeric string (upper and lowercase) and | |
| NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
| # bash generate random 32 character alphanumeric string (lowercase only) | |
| cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 |
| def resize(file_path): | |
| # import pdb; pdb.set_trace() | |
| save_path = os.getcwd() + "/tmp/xxx.gif" | |
| im = Image.open(file_path) | |
| if im.format == 'GIF': | |
| # rename file | |
| new_file_path = file_path.split('.')[0] + '.gif' |
| upstream main { | |
| server web1.local:80; | |
| server web2.local:80; | |
| server web3.local:80; | |
| } | |
| location /some/path/ { | |
| if ($host ~* "(.+)\.test\.bugua\.com$") { | |
| set $new_host $1.bugua.com; | |
| } | |
| proxy_set_header Host $new_host; |
| (function() { | |
| if ( typeof Object.prototype.uniqueId == "undefined" ) { | |
| var id = 0; | |
| Object.prototype.uniqueId = function() { | |
| if ( typeof this.__uniqueid == "undefined" ) { | |
| this.__uniqueid = ++id; | |
| } | |
| return this.__uniqueid; | |
| }; | |
| } |
| def datetime_to_seconds(time_in): | |
| epoch = datetime.datetime(1970, 1, 1, tzinfo=pytz.utc) | |
| delta = time_in - epoch | |
| return delta.total_seconds() |
| def get_ip(request): | |
| try: | |
| real_ip = request.META['HTTP_X_FORWARDED_FOR'] | |
| reg_ip = real_ip.split(",")[0] | |
| except KeyError: | |
| try: | |
| reg_ip = request.META['REMOTE_ADDR'] | |
| except KeyError: | |
| return 0 |
| <?xml version="1.0"?> | |
| <!-- | |
| List of KeyCode | |
| https://github.com/tekezo/Karabiner/blob/version_10.4.0/src/bridge/generator/keycode/data/KeyCode.data | |
| List of ModifierCode | |
| https://github.com/tekezo/Karabiner/blob/version_10.4.0/src/bridge/generator/keycode/data/ModifierFlag.data | |
| List of ConsumerKeyCode | |
| https://github.com/tekezo/Karabiner/blob/version_10.4.0/src/bridge/generator/keycode/data/ConsumerKeyCode.data | |
| List of PointingButton | |
| https://github.com/tekezo/Karabiner/blob/version_10.4.0/src/bridge/generator/keycode/data/PointingButton.data |