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
def get_obj_by_path(path): | |
""" | |
Example: | |
obj = get_obj_by_path('module.Object') | |
""" | |
module_path, target = path.rsplit('.', maxsplit=1) | |
module = __import__(name=module_path, fromlist=(target,)) | |
return getattr(module, target) |
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
import collections | |
class NoStrIterable(collections.Iterable): | |
""" | |
'isinstance(smt, NoStrIterable)' | |
instead of | |
'isinstance(smt, collection.Iterable) and not isinstance(smt, str)' | |
""" |
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
import subprocess | |
from pathlib import Path | |
import typer | |
def main(task_name: str): | |
task_dir = Path(task_name) | |
code_path = task_dir / 'code.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
def convert_timestamp_to_local_tz(dt): | |
if dt.tzinfo is None: | |
return dt | |
# convert to utc | |
utc_dt = dt - dt.utcoffset() | |
utc_dt = utc_dt.replace(tzinfo=None) | |
offset = ( | |
dt.datetime.now().replace(minute=0, second=0, microsecond=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
[user] | |
name = Afonasev Evgeniy | |
email = [email protected] | |
[ea] | |
afonasev = Afonasev Evgeniy | |
[core] | |
autocrlf = input | |
safecrlf = false | |
editor = /usr/bin/vim | |
pager = less |
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
Show hidden characters
{ | |
"auto_complete_commit_on_tab": true, | |
"auto_complete_triggers": | |
[ | |
{ | |
"characters": ".", | |
"selector": "source.python - string - comment - constant.numeric" | |
} | |
], | |
"bold_folder_labels": true, |
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
[ | |
{ "keys": ["ctrl+tab"], "command": "next_view" }, | |
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" }, | |
{ "keys": ["ctrl+t"], "command": "show_panel", "args": {"panel": "console", "toggle": true} }, | |
{ "keys": ["ctrl+alt+c"], "command": "exec", "args": {"kill": true} } | |
] |
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
export ZSH=/Users/afonasev/.oh-my-zsh | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
ZSH_THEME="amuse" | |
fpath+=~/.zfunc | |
autoload -U compinit && compinit | |
plugins=( | |
docker, git, django, colored-man, colorize, github, |
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
class SequenceKeyWrapper(object): | |
""" | |
for bisect with key function | |
""" | |
def __init__(self, iterable, key): | |
self.iterable = iterable | |
self.key = key | |
def __getitem__(self, i): |
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
def synchronized_method(mutex_attr='mutex'): | |
def decorator(method): | |
@wraps(method) | |
def wrapped(instance, *args, **kw): | |
with getattr(instance, mutex_attr): | |
return method(instance, *args, **kw) | |
return wrapped | |
return decorator |
OlderNewer