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
| # Python PEP 3101 specifies the string formatting function that | |
| # replaces the old % operator on strings. In addition, PEP 3105 | |
| # also specifies the behavior of the print(), now standard in | |
| # Python 3. This small cheat-sheet offer an overview of both. | |
| # In Python 2.7 use with: | |
| # from __future__ import print_function | |
| # Print to stderr | |
| >>> from sys import stderr |
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
| #!/usr/bin/env python3 | |
| """ | |
| Collaborative constructors for multiple inheritance. | |
| Python 3 only. If using Python 2.7, collaborative constructor are broken for | |
| positional arguments. | |
| Collaborative constructors allow classes to collaborate in the way constructor | |
| arguments are passed between all classes in the inheritance tree. |
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
| # Run me with: | |
| # python3 setup.py bdist_wheel --cythonize | |
| # ... | |
| if '--cythonize' in argv: | |
| from Cython.Build import cythonize | |
| packaging = { | |
| 'ext_modules': cythonize('lib/**/*.py'), | |
| } |
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
| # Prompt | |
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ [\1]/' | |
| } | |
| export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$\[\033[38;5;166m\]$(parse_git_branch)\[\033[00m\] ' | |
| # Less Colors for Man Pages | |
| export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking | |
| export LESS_TERMCAP_md=$'\E[01;38;5;74m' # begin bold | |
| export LESS_TERMCAP_me=$'\E[0m' # end mode |
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
| # Requires thrid-party awesome module colorlog | |
| import logging | |
| from colorlog import ColoredFormatter | |
| from . import __version__ | |
| log = logging.getLogger(__name__) |
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
| from random import choice | |
| from datetime import datetime | |
| from string import ascii_letters, digits | |
| def generate_string(length, choices=ascii_letters + digits): | |
| return ''.join(choice(choices) for _ in range(length)) | |
| def compare_lookup(length): |
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
| #!/usr/bin/env python3 | |
| """ | |
| pybin2h is a tool for converting binary data to a C-style uchar array for | |
| compiling straight into C/C++ code written in Python 3. | |
| """ | |
| from itertools import islice | |
| __version__ = '0.1.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
| from __future__ import division | |
| from os.path import isfile | |
| from json import dumps | |
| from logging import getLogger | |
| from traceback import format_exc | |
| from base64 import b64encode, b64decode | |
| from multiprocessing import Value, Queue, Event, Process | |
| log = getLogger(__name__) |
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
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| from logging import getLogger as get_logger # noqa | |
| from datetime import datetime | |
| from github import Github | |
| log = get_logger(__name__) |
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
| #!/usr/bin/env bash | |
| set -o errexit | |
| set -o nounset | |
| # set -o xtrace | |
| DOMAIN=${1:-} | |