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
| Go to https://twitter.com/prostomarkeloff |
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
| fn test_params_macro() { | |
| let map: Params = { | |
| trait __AsString { | |
| fn __as_string(self) -> String; | |
| } | |
| impl __AsString for String { | |
| fn __as_string(self) -> String { | |
| self | |
| } | |
| } |
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
| Token = NewType("Token", str) | |
| class ABCToken: | |
| typeof: ClassVar[TokenType] | |
| get_token_type: ClassVar[GetTokenType] | |
| get_token: Union[GetTokenSync, GetTokenAsync] | |
| class ABCSyncToken(ABCToken): | |
| get_token_type = GetTokenType.SYNC |
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 enum import auto, Enum | |
| import typing | |
| import random | |
| class TimeoutError(Exception): | |
| def __str__(self): | |
| return "TimeoutError" | |
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 random | |
| import typing | |
| def true_or_false() -> bool: | |
| return random.choice([True, False]) | |
| class TimeoutError(Exception): | |
| pass | |
| def random_result() -> typing.Union[dict, Exception]: |
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
| new Promise(resolve => { | |
| var offset = -100; | |
| let pageScroll = () => { | |
| window.scrollBy(0, 50); | |
| if (window.pageYOffset === offset) { | |
| return resolve(true); | |
| } | |
| offset = window.pageYOffset; | |
| setTimeout(pageScroll, 50); |
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 contextvars import ContextVar | |
| class MySuperObject: | |
| def hello(self): | |
| print("Hello") | |
| current_super_object: ContextVar[MySuperObject] = ContextVar("current_super_object") | |
| def main(): |
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-based-handlers with states, inheritance and other features. | |
| """ | |
| import asyncio | |
| import typing | |
| import inspect | |
| import functools | |
| from enum import Enum, auto |
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 inspect | |
| from typing import Any, Callable, ClassVar, List, Type, TypeVar, Union, get_type_hints | |
| from fastapi import APIRouter, Depends | |
| from starlette.routing import Route, WebSocketRoute | |
| T = TypeVar("T") | |
| def cbv(router: APIRouter) -> Callable[[Type[T]], Type[T]]: |