Skip to content

Instantly share code, notes, and snippets.

View afonasev's full-sized avatar
🔥

Afonasev Evgeniy afonasev

🔥
View GitHub Profile
curl -sSL https://agent.digitalocean.com/install.sh | sh
useradd user
usermod -aG sudo user
# ZSH
sudo apt-get install zsh -y
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
chsh -s $(which zsh)
@afonasev
afonasev / rancher.sh
Last active September 19, 2018 19:27
docker run -d --restart=unless-stopped --name rancher \
-p 8000:80 -p 8443:443 \
-v /host/rancher:/var/lib/rancher \
rancher/rancher:latest
class Optional:
"""
>>> class User:
... def __init__(self, friend_a, friend_b):
... self.friend_a = friend_a
... self.friend_b = friend_b
...
... def calc(self):
... return 5
@afonasev
afonasev / .py
Created March 14, 2018 09:48
Synchronized method with mutex
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
@afonasev
afonasev / .py
Created March 14, 2018 09:47
SequenceKeyWrapper (bisect with key)
class SequenceKeyWrapper(object):
"""
for bisect with key function
"""
def __init__(self, iterable, key):
self.iterable = iterable
self.key = key
def __getitem__(self, i):
@afonasev
afonasev / .zshrc
Last active September 10, 2021 07:01
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,
[
{ "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} }
]
{
"auto_complete_commit_on_tab": true,
"auto_complete_triggers":
[
{
"characters": ".",
"selector": "source.python - string - comment - constant.numeric"
}
],
"bold_folder_labels": true,
@afonasev
afonasev / .gitconfig
Last active September 16, 2021 15:46
[user]
name = Afonasev Evgeniy
email = [email protected]
[ea]
afonasev = Afonasev Evgeniy
[core]
autocrlf = input
safecrlf = false
editor = /usr/bin/vim
pager = less
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) -