cd ~
pyenv global 3.6.6 3.7.0
pip install tox
cd ~/workspace/xxx/project-name
pyenv local 3.6.6 3.7.0
tox
This file contains 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
""" | |
API request logger: | |
One record per each API request received | |
1) Logs to a file in logstash format. | |
App logger: | |
Your usual logger that just writes down what the code is doing. | |
Mostly quiet on production except when errors happen. | |
Includes stack traces. |
This file contains 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
import re | |
class _ValueNotSet(object): | |
pass | |
ValueNotSet = _ValueNotSet() | |
This file contains 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
""" | |
Gets list of functions in a module, preserve declaration order. | |
This cannot be done with inspect.getmembers() or dir() because they lose the order. | |
Have to construct AST with ast. | |
""" | |
import ast | |
import importlib | |
import os.path |
This file contains 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
class universal_decorator: | |
wrappers = [] | |
def __init__(self, method): | |
self.original_method = method | |
self.method = self.original_method | |
self.apply_decorators() | |
def apply_decorators(self): | |
for wrapper in self.wrappers: |
This file contains 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
def context_entering_decorator(context_manager): | |
""" | |
Creates a context-entering decorator that does not fail to do its job | |
if the underlying function is actually a generator function. | |
""" | |
def decorator(func): | |
if inspect.isgeneratorfunction(func): | |
@functools.wraps(func) | |
def wrapped(*args, **kwargs): |
This file contains 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
def filter1(r): | |
return r % 3 == 0 | |
def filter2(r): | |
return r % 5 == 0 | |
def apply_all(records, *filters): |
This file contains 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
import collections | |
from typing import Iterable | |
class Vertex: | |
def __init__(self, value, graph: "Graph"): | |
self._graph = graph | |
self.value = value | |
def __hash__(self): |
This file contains 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
import math | |
from kivy.base import runTouchApp | |
from kivy.clock import Clock | |
from kivy.lang import Builder | |
from kivy.properties import ObjectProperty, StringProperty | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.uix.recycleview import RecycleView | |
I hereby claim:
- I am jbasko on github.
- I am jbasko (https://keybase.io/jbasko) on keybase.
- I have a public key ASCG6JaPj_Yn7o53c-omTdE900qmWFTal4bHwtRK2OJjlgo
To claim this, I am signing this object:
OlderNewer