⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,
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
# Standard Library | |
from typing import ( | |
Any, | |
Callable, | |
Dict, | |
FrozenSet, | |
List, | |
Optional, | |
Sequence, | |
Set, |
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
"""Simple content negotiation | |
Usage: | |
Example 1: | |
from renderers import render | |
@router.post("/myapp/items/") | |
async def api_login(item: Item, accept: Optional[str] = Header(default='application/jwt')): |
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 alembic.config import Config | |
from alembic.script import ScriptDirectory | |
from flask_migrate import downgrade, upgrade, stamp | |
from flask_project import create_app | |
from flask_project.config import TestingConfig | |
from flask_project.database import db # db = flask_sqlalchemy.SQLAlchemy() | |
# in conftest.py | |
@pytest.fixture |
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
######## | |
# app.py | |
######## | |
# Example of how I use it in my project. This file cannot be run as-is. | |
# The only difference with the example in the fastapi_singleton module docstring is | |
# the use of a subclassed FastAPI application to define type annotations | |
import fastapi | |
import fastapi_singleton |
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
""" | |
Usage: | |
Make sure that redis is running on localhost (or adjust the url) | |
Install uvicorn or some other asgi server https://asgi.readthedocs.io/en/latest/implementations.html | |
pip install -u uvicorn | |
Install dependencies |
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 | |
import logging | |
import time | |
from functools import lru_cache | |
import uvicorn | |
from aiocache import cached | |
from fastapi import FastAPI, APIRouter, Depends | |
logger = logging.getLogger(__name__) |
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
#!/bin/bash | |
# NAS IP: 192.168.1.10 in this example | |
# DHCP scope reservation for macvlan: 192.168.1.210/28 (Details below) | |
## Network: 192.168.1.210/28 | |
## HostMin: 192.168.1.211 | |
## HostMax: 192.168.1.224 | |
## Hosts/Net: 14 | |
# Create a Synology macvlan0 bridge network attached to the physical eth0, and add the ip range scope (sudo) |
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
UserCreateT = TypeVar("UserCreateT", bound=UserCreate) | |
UserCreateRequestT = TypeVar("UserCreateRequestT", bound=UserCreateRequest) | |
UserInDBT = TypeVar("UserInDBT", bound=UserInDB) | |
UserUpdateT = TypeVar("UserUpdateT", bound=UserUpdate) | |
UserApiT = TypeVar("UserApiT", bound=UserBaseInDB) | |
UserOrmT = TypeVar("UserOrmT", bound=BaseUser) | |
logger = logging.getLogger(__name__) |
by Tatiana Mac
Last updated 14 April 2021
As speaking comes with immense privilege, I have crafted a speaker rider to set expectations and boundaries around my engagement. I am grateful to all the conference organisers who have brilliantly hosted me. I would love to continue to exercise this privilege to speak at conferences, and use this privilege to make the landscape more accessible and beneficial to tech's most historically excluded and marginalised communities.
😫 I provide a lot of explanations for those of you who never had to consider these things. Most thoughtful conferences I've attended check most of these boxes intrinsically, particularly when conference runners are experienced speakers. They get it.