Skip to content

Instantly share code, notes, and snippets.

View CartfordSam's full-sized avatar

Sam Cartford CartfordSam

  • Minneapolis, MN
View GitHub Profile
@CartfordSam
CartfordSam / schemas.py
Last active March 19, 2024 16:31
Pydantic v1.10 handle _id with extended BaseModel
from pydantic import BaseModel, root_validator
# NOTE: this works (for me) with pydantic==1.10.13,
# but we'll be upgrading to v2 and you can do the same
# thing with the model_validator
# considerations:
# - I'm using this in FastAPI, mostly read-only to my users,
# so I don't have a need to keep the ObjectId, and convert
# back to the bson ObjectId as-needed
@CartfordSam
CartfordSam / translate_morse.py
Created March 11, 2020 14:32
Translates letters and punctuation to and from morse code
ltom = {
"A" : ".-",
"B" : "-...",
"C" : "-.-.",
"D" : "-..",
"E" : ".",
"F" : "..-.",
"G" : "--.",
"H" : "....",
"I" : "..",