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 logging | |
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(name)s %(threadName)s %(message)s') | |
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) |
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
# run it like `docker-compose up -d` | |
# then go to http://localhost:15672 and login with user and password `guest` | |
version: '3.8' | |
services: | |
rabbitmq: | |
image: rabbitmq:3.10-management-alpine | |
restart: always | |
# environment: | |
# - RABBITMQ_DEFAULT_USER=guest |
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 truncate_db(engine): | |
# delete all table data (but keep tables) | |
# we do cleanup before test 'cause if previous test errored, | |
# DB can contain dust | |
meta = MetaData(bind=engine, reflect=True) | |
con = engine.connect() | |
trans = con.begin() | |
con.execute('SET FOREIGN_KEY_CHECKS = 0;') | |
for table in meta.sorted_tables: | |
con.execute(table.delete()) |
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
""" | |
useful for local development and unit tests when tasks are run syncronously | |
""" | |
from your_app.settings import TESTING | |
from celery import Task | |
from celery.canvas import Signature | |
def run_task(task_signature: Signature): | |
if TESTING: |
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
# put custom modules to ./custom_addons | |
version: '2' | |
services: | |
postgresql: | |
image: docker.io/bitnami/postgresql:13 | |
volumes: | |
- 'postgresql_data:/bitnami/postgresql' | |
environment: | |
# ALLOW_EMPTY_PASSWORD is recommended only for development. | |
- ALLOW_EMPTY_PASSWORD=yes |
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
{ | |
"consumer": { | |
"name": "OrderService" | |
}, | |
"provider": { | |
"name": "UserService" | |
}, | |
"interactions": [ | |
{ | |
"description": "GetUser API call for UserA", |
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
<?php | |
/* | |
Пример программного кода для работы с API сервиса Яндекс.Директ | |
В примере использован рекомендуемый синтаксис для работы с API сервиса Яндекс.Директ | |
на языке PHP с использованием протокола JSON и авторизацией по токенам. | |
Обращаем внимание, что все текстовые данные должны быть в кодировке UTF8 |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<style> | |
[data-toggle="collapse"][aria-expanded="true"] > .js-rotate-if-collapsed | |
{ | |
-webkit-transform: rotate(180deg); |
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 format_exception_as_python_does(e: BaseException): | |
# taken from https://stackoverflow.com/a/35498685 | |
return traceback.format_exception(type(e), e, e.__traceback__) | |
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
# pip install saga_py | |
from saga import SagaBuilder, SagaError | |
counter1 = 0 | |
counter2 = 0 | |
def _print_counters(): | |
global counter1, counter2 | |
print(f'After this action, {counter1=}, {counter2=} \n') |
NewerOlder