Skip to content

Instantly share code, notes, and snippets.

View jerry-git's full-sized avatar

Jerry Pussinen jerry-git

View GitHub Profile
import typing
import uuid
from dataclasses import dataclass
class InstanceWithId(typing.Protocol):
@property
def id(self) -> str:
...
import datetime as dt
from dataclasses import dataclass, field
import apischema
import pytest
def to_timestamp(d: dt.datetime) -> int:
return int(d.timestamp())
@jerry-git
jerry-git / vax_app.py
Last active September 19, 2022 04:14
Simple modern Python web app
import datetime as dt
import os
import motor
from beanie import Document, Indexed, PydanticObjectId, init_beanie, operators
from fastapi import FastAPI, Response, status
from pydantic import BaseModel
app = FastAPI()
@jerry-git
jerry-git / celery_error_callback_example.py
Created March 22, 2018 12:36
A simple example about how to use error callbacks in celery
"""
celery -A celery_error_callback_example.celery worker --loglevel=info
python celery_error_callback_example.py
"""
import time
from celery import Celery
celery = Celery(