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
— Да? | |
— Алё! | |
— Да да? | |
— Ну как там с деньгами? | |
— А? | |
— Как с деньгами-то там? | |
— Чё с деньгами? | |
— Чё? | |
— Куда ты звонишь? |
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
# syntax=docker/dockerfile:experimental | |
FROM python:3.7-slim AS base | |
# ENV LANG=C.UTF-8 # Sets utf-8 encoding for Python et al | |
# ENV PYTHONDONTWRITEBYTECODE=1 # Turns off writing .pyc files; superfluous on an ephemeral container. | |
# ENV PYTHONUNBUFFERED=1 # Seems to speed things up | |
ENV PYTHONUNBUFFERED=1 \ | |
PYTHONDONTWRITEBYTECODE=1 \ |
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
# myapp/models.py | |
from django.db import models | |
class MyModel(models.Model): | |
class Meta: | |
abstract = True | |
def __str__(self): | |
data = [f'{k}={v!r}' for k, v in self.__dict__.items() if not k.startswith('_')] |
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
#!/usr/bin/env bash | |
CIPHERS='ALL:eNULL' | |
DELAY=${2:-0.1} | |
SERVER=${1:?usage: $0 <host:port> [delay, default is ${DELAY}s] [ciphers, default is ${CIPHERS}]} | |
MAXLEN=$(openssl ciphers "$CIPHERS" | sed -e 's/:/\n/g' | awk '{ if ( length > L ) { L=length} }END{ print L}') | |
echo Using $(openssl version). | |
declare -A TLSMAP=( [tls1_1]=cipher [tls1_2]=cipher [tls1_3]=ciphersuites ) |
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
# aproducer.py | |
# | |
# Async Producer-consumer problem. | |
# Challenge: How to implement the same functionality, but no threads. | |
import time | |
from collections import deque | |
import heapq | |
class Scheduler: |
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 fastapi import FastAPI, Depends, Query | |
from starlette.requests import Request | |
from starlette.responses import JSONResponse | |
import starlette.status | |
from pydantic import BaseModel, validator | |
import datetime | |
from typing import List | |
from dataclasses import dataclass, field |
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
""" | |
Single Responsibility Principle | |
“…You had one job” — Loki to Skurge in Thor: Ragnarok | |
A class should have only one job. | |
If a class has more than one responsibility, it becomes coupled. | |
A change to one responsibility results to modification of the other responsibility. | |
""" | |
class Animal: | |
def __init__(self, name: str): |
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 @euri10 -- https://gitter.im/tiangolo/fastapi?at=5cd915ed56271260f95275ac | |
import asyncio | |
import pytest | |
from sqlalchemy import create_engine | |
from sqlalchemy_utils import create_database, database_exists, drop_database | |
from starlette.config import environ | |
from starlette.testclient import TestClient |
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: https://doc.qt.io/qt-5/qtcharts-nesteddonuts-example.html | |
import functools | |
import random | |
from PyQt5.QtChart import * | |
from PyQt5.QtGui import * | |
from PyQt5.QtCore import * | |
from PyQt5.QtWidgets import * | |
class Widget(QWidget): |
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
[ | |
{ | |
"date": "Mon Jan 23 13:03:00 2017 -0800", | |
"message": "Recommended by Django https://docs.djangoproject.com/en/1.10/ref/databases/#setting-sql-mode", | |
"title": "SET sql_mode='STRICT_TRANS_TABLES';", | |
"hash": "a395f401c9a6d3e8602b80ecc729d736da871f46", | |
"author": "Simon Willison <[email protected]>" | |
}, | |
{ | |
"date": "Mon Jan 23 11:37:38 2017 -0800", |
NewerOlder