I hereby claim:
- I am kstrauser on github.
- I am ks (https://keybase.io/ks) on keybase.
- I have a public key whose fingerprint is 19CF F48E 5C06 16B4 4A15 1E80 54D9 906A 294B 7FF3
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| def substrcomparatormaker(column, i, j=None): | |
| """Return a comparator that tests for the substring of 'column' | |
| from 'i' to 'j', as specified with Python slice values. This | |
| means setting the start column to i + 1 because Python is 0-based | |
| and SQL is 1-based, and setting the length to j - i. | |
| Please don't create new tables that use this! It's only for legacy, | |
| unnormalized data where multiple values are lumped together in a single | |
| column. |
| #!/usr/bin/env python | |
| """ | |
| Build wheels of all currently installed packages (as listed by "pip freeze") | |
| """ | |
| import glob | |
| import importlib | |
| from subprocess import call |
| from itertools import count | |
| def fizz(): | |
| for i in count(1): | |
| yield '' if i % 3 else 'fizz' | |
| def buzz(): | |
| for i in count(1): | |
| yield '' if i % 5 else 'buzz' |
| >>> import mock | |
| >>> m = mock.Mock() | |
| >>> m.assert_called_once() # Old version of Mock? This may not be what you expect. | |
| <Mock name='mock.assert_called_once()' id='4558624144'> | |
| >>> assert_called_once = mock.Mock.assert_called_once # Doesn't exist. Now you know! | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> | |
| AttributeError: type object 'Mock' has no attribute 'assert_called_once' |
| function workon () { | |
| # Find the configured virtualenvwrapper home, or use Kirk's | |
| # clearly excellent choice. | |
| if [[ -z $PROJECT_HOME ]]; then | |
| envs=$PROJECT_HOME | |
| else | |
| envs=~/Envs | |
| fi | |
| # Override the paths for specific environments |
I use this decorator in unittest modules to verify that a particularly-named object exists:
def existsin(namespace):
"""Given a namespace, this decorator asserts that an object with
the same name as the function it's wrapping (minus ) exists in that
namespace"""
def wrapper(namedunittest):
assert namedunittest.__name__.startswith('test_'), \
"The wrapped '%s' function doesn't look like a unit test" % namedunittest.__name__
| """ | |
| Requirements: | |
| * A Wordpress Blog | |
| * Ghost export file (json). | |
| * Python Packages: python-wordpress-xmlrpc | |
| >>> pip install python-wordpress-xmlrpc | |
| WARNING: |
| #!/usr/bin/env python | |
| from collections import Counter | |
| spammers = [ | |
| {"domain": "lewohner.top", "ip": "5.189.207.59", "asn": "AS50896", "mx": "mxsrv.mailasrvs.pw"}, | |
| { | |
| "domain": "vesigarna.site", | |
| "ip": "185.71.1.152", | |
| "asn": "AS200557", |
| #!/usr/bin/env python | |
| import itertools | |
| import pathlib | |
| value = 0 | |
| seen = set() | |
| for line in itertools.cycle( | |
| int(line) for line in pathlib.Path("input/1.txt").read_text().splitlines() |