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 asyncio | |
from aiologger import Logger | |
from loguru import logger | |
def async_logging(msg): | |
aio_logger = Logger.with_default_handlers(name='my-logger') | |
method = getattr(aio_logger, msg.record['level'].name.lower()) | |
method(f"AIO LOGGING: {msg}") |
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
pg_dump -U postgres -Fc mfo > mfo.sql | |
docker cp postgres:/mfo.sql mfo.sql | |
docker cp mfo.sql postgres:/mfo.sql | |
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'mfo' AND pid <> pg_backend_pid(); | |
drop database mfo; | |
create database mfo; | |
pg_restore -U postgres -d mfo --clean --create mfo.sql |
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 logging | |
class InsufficientFunds(PaymentSystemError): | |
requested_amount: float = None | |
direction: FinDirection = None | |
account_balance: float = None | |
def __init__(self, *args, direction=None, requested_amount=None, account_balance=None, **kwargs): | |
self.direction = direction |
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
pip install mutmut | |
mutmut run --runner 'python -m pytest -x tests/test_quiz.py' --paths-to-mutate business_logic/credit_history_quiz.py | |
mutmut results # Shows munants IDs (X here) | |
mutmut show X # Shows diff metant/original | |
mutmut apply X # Applies change from mutant to file | |
То stop certain line from mutation (Annoying on log lines) apply whitelisting comment on it: # pragma: no mutate |
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
pytest tests/test_quiz.py --disable-pytest-warnings --cov=business_logic.credit_history_quiz --cov-report term-missing | |
In PyChrm that would be | |
Additional arguments: | |
--disable-pytest-warnings --cov=business_logic.credit_history_quiz --cov-report term-missing | |
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
location /static/ { | |
# error_log /home/aa/kek.log debug; # Очень много информации для дебага именно по этому локэйшену. | |
root /home/aa; | |
# Сами файлы лежат в /home/aa/static/ | |
} |
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
recovery: | |
build: build/postgres/ | |
container_name: recovery | |
network_mode: bridge | |
hostname: recovery | |
restart: always | |
command: tail -f /dev/null | |
volumes: | |
- ./build/postgres/postgresql.conf:/etc/postgresql/postgresql.conf | |
- ./build/postgres/backup.py:/opt/scripts/backup.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
try: | |
self._pass_issue_date = self.person.pass_issue_date if getattr(self.person,'birthday', 0) else None | |
except ValueError: | |
self._pass_issue_date = self.person.pass_issue_date if getattr(self.person,'birthday', 0) else None |
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
# Add existing repo as a submodule in another repo(now it's super-repo) | |
- CD to super-repo | |
- git submodule add https://gitlab.com/e.gan/test-shared-repo.git some_generic_code (some_generic_code is a name of directory under which the code from submodule will reside) | |
- git commit -am "I linked a somerepo as submodule some_generic_code" | |
# Update or downgrade version of submodule to latest in super-repo | |
- CD to some_generic_code (the submodule repo is now manages by "git" command) | |
- git checkout master | |
- CD out of some_generic_code to parent directory(super-repo) |
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 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | |
# Show active connections | |
SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%'; | |
# Show some shit; | |
show processlist; | |
# Create Database with PROPPER unicode encoding | |
create database animarender character set UTF8mb4 collate utf8mb4_unicode_ci; |
NewerOlder