View test_foo.py
""" Tests for `foo` package.
uses `pytest`. `pytest` resources:
* https://docs.pytest.org/en/latest/
* https://pragprog.com/book/bopytest/python-testing-with-pytest
also uses `responses`, for mocking HTTP exchanges with `requests` library:
* https://github.com/getsentry/responses
View remove_punc.py
#http://stackoverflow.com/questions/265960/best-way-to-strip-punctuation-from-a-string-in-python
import re, string
table = string.maketrans("","")
regex = re.compile('[%s]' % re.escape(string.punctuation))
def test_re(s): # From Vinko's solution, with fix.
return regex.sub('', s)
def test_trans(s):
View SanitizedString.py
""" throw your strings to SanitizedString and "ensure" they have been sanitized, such as removing control characters.
SanitizedString will avoid running redundantly, by checking type of the input (good for Very Big Strings)
>>> hello = SanitizedString(chr(0) + "hello")
>>> assert hello == "hello"
>>> assert chr(0) not in hello
>>> assert SanitizedString(hello) == hello
at time of writing there is only one sanitization filter in use:
View logging.yml
version: 1
formatters:
simple:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
verbose:
format: "%(levelname)-8s %(asctime)s %(name)s %(filename)s:%(lineno)s | %(funcName)s | %(message)s"
very_verbose:
format: "%(levelname)-8s %(asctime)s %(name)s %(pathname)s:%(lineno)s | %(funcName)s | %(message)s"
handlers:
console:
View _fix_pip_import_error.md

It can come up while installing anything really. I'm not sure exactly which versions of pip are affected, I know I had 1.5.6 and it was affected.

These examples are grabbed from my system level Python, but of course you should use a virtualenv.

  Running setup.py install for simplegeneric
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Library/Python/2.7/site-packages/setuptools/__init__.py", line 12, in <module>
        import setuptools.version
View sonarqube and gradle and analysis mode.md

SonarQube not "uploading"? Be careful about sonar.analysis.mode=issues (or, if using Gradle, systemProp.sonar.analysis.mode=issues). This analysis mode seems required for some purposes (some plugins maybe?), but it was making Gradle not generate the report or upload it to SonarQube server. I haven't figured out the details yet but I wanted to leave this memo...

View omnifocus_solarized_light_fantastaque.ofocus-style
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>colorPalette</key>
<dict>
<key>ArchiveExpectationsBarBottomColor</key>
<dict>
<key>a</key>
<real>0.20000000000000001</real>
View ipython_embed_example.py
# -*- coding: utf-8 -*-
if __name__ == "__main__":
# Code code code...
# Code code code...
# Code code code...
from IPython import embed; embed()
View logging_formatter_string.py
import logging
LOGGING_FORMAT_DEBUG = '%(levelname)-5s:%(name)s:%(module)s.%(funcName)s() L%(lineno)d | %(asctime)s %(message)s'
LOGGING_FORMAT_DEFAULT = "%(levelname)-5s:%(name)s:%(message)s"
# stuff ...
logger = logging.getLogger('<library_or_product_name>')
handler = logging.StreamHandler(stream=sys.stderr)
logger.addHandler(handler)
View steeef_hangtwenty.zsh_theme
# prompt style and colors based on Steve Losh's Prose theme:
# http://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
#
# vcs_info modifications from Bart Trojanowski's zsh prompt:
# http://www.jukie.net/bart/blog/pimping-out-zsh-prompt
#
# git untracked files modification from Brian Carper:
# http://briancarper.net/blog/570/git-info-in-your-zsh-prompt
export VIRTUAL_ENV_DISABLE_PROMPT=1