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 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 |
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
| docker run -d --restart=unless-stopped --name rancher \ | |
| -p 8000:80 -p 8443:443 \ | |
| -v /host/rancher:/var/lib/rancher \ | |
| rancher/rancher:latest |
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
| 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) |
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
| server { | |
| server_name rancher.afonasev.ru; # managed by Certbot | |
| location / { | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Forwarded-Proto $scheme; | |
| proxy_set_header X-Forwarded-Port $server_port; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_pass http://localhost:8000; | |
| proxy_http_version 1.1; |
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
| version: '3.3' | |
| services: | |
| zookeeper: | |
| image: confluentinc/cp-zookeeper:5.0.0 | |
| restart: always | |
| environment: | |
| ZOOKEEPER_CLIENT_PORT: 2181 | |
| ZOOKEEPER_TICK_TIME: 2000 |
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
| server { | |
| listen 80 default_server; | |
| server_name _; | |
| return 301 https://$host$request_uri; | |
| } |
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
| #!/bin/bash | |
| set -e | |
| function db_ready(){ | |
| python << END | |
| import sys | |
| import sqlalchemy | |
| try: | |
| engine_pro = sqlalchemy.create_engine("${DATABASE}").connect() |
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 threadpool(func: FUNC) -> FUNC: | |
| @wraps(func) | |
| def wrapper(*args: Any, **kwargs: Any) -> Awaitable[Any]: | |
| loop = get_event_loop() | |
| callback = partial(func, *args, **kwargs) | |
| return loop.run_in_executor(None, callback) | |
| return wrapper |
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
| @contextmanager | |
| def session(*args: Any, **kwargs: Any) -> Iterator[sa.orm.Session]: | |
| with closing(session_factory(*args, **kwargs)) as _session: | |
| try: | |
| yield _session | |
| except Exception: | |
| _session.rollback() | |
| raise | |
| else: | |
| _session.commit() |
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
| from typing import Any | |
| import requests | |
| REQUEST_DEFAULT_TIMEOUT = 5 | |
| REQUEST_RETRIES = 5 | |
| class SessionWithTimeout(requests.Session): | |
| def request(self, *args: Any, **kwargs: Any): |