/bin/timber
#!/usr/bin/env python
if __name__ == '__main__':
from timber.scripts.cli import cli
cli()
| import logging | |
| import sys | |
| # ----------- Library code ------------------- # | |
| logger = logging.getLogger(__name__) | |
| # think of this as a global restriction | |
| # even if the handlers want access to lower levels, they don't get it | |
| logger.setLevel(logging.INFO) |
| # LMGTFY | |
| # For best results, have python autoload it | |
| # add to $(sitepackages)/sitecustomize.py | |
| # alias sitepackages="python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'" | |
| import webbrowser | |
| from urllib2 import quote | |
| def lmgtfy(x): | |
| search = "Python {}".format(x.__name__) |
| from __future__ import print_function | |
| from collections import OrderedDict | |
| from numbers import Number | |
| import collections | |
| import sys | |
| PY3 = sys.version_info[0] == 3 | |
| if PY3: | |
| string_types = str, |
| from __future__ import print_function, division | |
| from collections import defaultdict | |
| from functools import wraps | |
| import os | |
| import json | |
| import logging | |
| import threading | |
| import time | |
| import psutil |
| #!/usr/bin/env python | |
| # pylint: disable=W0621 | |
| import json | |
| import math | |
| import re | |
| import sys | |
| # From mercantile | |
| def ul(*tile): |
| from concurrent import futures | |
| from datetime import datetime | |
| import requests | |
| def threadmap(func, seq, concurrency=8): | |
| """Apply function to each item in seq in a concurrent threadpool | |
| Only beneficial for IO-bound tasks because of the GIL | |
| Parameters: |
| Year | Punxsutawney Phil | February Average Temperature | February Average Temperature (Northeast) | February Average Temperature (Midwest) | February Average Temperature (Pennsylvania) | March Average Temperature | March Average Temperature (Northeast) | March Average Temperature (Midwest) | March Average Temperature (Pennsylvania) | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1886 | No Record | |||||||||
| 1887 | Full Shadow | |||||||||
| 1888 | Full Shadow | |||||||||
| 1889 | No Record | |||||||||
| 1890 | No Shadow | |||||||||
| 1891 | No Record | |||||||||
| 1892 | No Record | |||||||||
| 1893 | No Record | |||||||||
| 1894 | No Record |
| #!/usr/bin/env python3.6 | |
| import time | |
| n = 1_000_000 | |
| print("Using .format") | |
| start = time.time() | |
| template = "This is a new {thing} with {x} properties" | |
| for thing, x in zip('abcdefghijklmnopqrstuvwxyz' * int(n/26), range(n)): | |
| _ = template.format(thing=thing, x=x) |
| function coords-for { | |
| if [ $# -lt 1 ]; then | |
| echo "Usage: coords-for LOCATION" | |
| fi | |
| local location=$1 | |
| mapbox geocoding "$location" --features --limit 1 \ | |
| | jq -c ".center|[.[1],.[0]]" \ | |
| | sed 's/\[//g' | sed 's/\]//g' | sed 's/,/\//g' | |
| } |