- Authentik (Proxy too) + Traefik + App + Portainer docker-compose file.
- Locust load testing script.
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
// Some points that made me surprised: | |
// - Variable's states: mutability and immutability. | |
// - Strong typing. | |
// - Statements and expressions, e.g. syntactic scope is an expression. | |
// - Loop labels and break as an expression. | |
use std::io; | |
use rand::Rng; | |
const MAX_INPUT_NUMBER: u8 = u8::MAX; // Constant variable (3.1) and Scalar `u8` data type (3.2). |
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
from contextlib import suppress | |
from typing import NamedTuple | |
from pydantic import create_model_from_namedtuple, BaseModel, root_validator | |
class FunctionNumber101(NamedTuple): | |
width: float | |
height: float |
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
from typing import NamedTuple | |
class FunctionNumber101(NamedTuple): | |
width: float | |
height: float | |
def area(self): | |
if self.width <= 0 or self.height <= 0: | |
raise ValueError("width and height must be positive") |
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
from pydantic import create_model | |
def create_pydantic_model(name: str, **kwargs): | |
""" | |
Create a pydantic model. | |
:param name: name of the BaseModel class to create. | |
:param kwargs: BaseModel' fields. | |
""" |
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 test_same_name(session_same_name): | |
s, models = session_same_name | |
username = s.query(models['User'].__class__).first().name | |
actorname = s.query(models['Actor'].__class__).first().name | |
assert username == actorname |
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 pytest | |
from pytest_mock_resources import create_postgres_fixture | |
from sqlalchemy.orm import Session | |
from model import Actor, User | |
pg = create_postgres_fixture( | |
*[Actor, User] | |
) |
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
from sqlalchemy import Column, Integer, String | |
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() | |
class User(Base): | |
__tablename__ = "user" | |
__table_args__ = {"schema": "names"} |