Skip to content

Instantly share code, notes, and snippets.

View juftin's full-sized avatar
🤠
wranglin' data

Justin Flannery juftin

🤠
wranglin' data
View GitHub Profile
@juftin
juftin / epic_oauth2_client.py
Last active October 17, 2023 18:50
Epic EHR Integration with an HTTPX Client - authlib==1.2.1
"""
Epic OAuth2 Client
"""
from __future__ import annotations
import datetime
import logging
import os
import pathlib
"""
Organization
https://www.hl7.org/fhir/organization.html
"""
import os
from typing import Type, TypeVar
import uvicorn
@juftin
juftin / aicli.py
Last active September 14, 2023 01:54
OpenAI powered AI Streaming CLI in just a few lines of code
import os
from datetime import datetime, timezone
from pathlib import Path
import openai
import rich.traceback
from prompt_toolkit import PromptSession
from prompt_toolkit.history import FileHistory
from rich.console import Console
from rich.live import Live
@juftin
juftin / gist.py
Last active August 31, 2023 19:28
string literals
from typing import Literal, TypedDict
DENSE_CALCIUM_VOLUME: Literal["denseCalciumVolume"] = "denseCalciumVolume"
FATTY_FIBROUS_VOLUME: Literal["fattyFibrousVolume"] = "fattyFibrousVolume"
TOTAL_CALCIFIED_PLAQUE_VOLUME = "totalCalcifiedPlaqueVolume"
class TypedCleerlyDict(TypedDict):
denseCalciumVolume: float
fattyFibrousVolume: float
@juftin
juftin / README.md
Last active August 19, 2023 19:56
FastAPI Users + SQLModel

FastAPI Users + SQLModel

You will notice that the SQLModel example is very similar to the SQLAlchemy example for fastapi-users. This is because SQLModel is built on top of SQLAlchemy and pydantic.

There are a few important differences you should take note of:

app/db.py

@juftin
juftin / rotation.py
Last active October 24, 2022 17:37
Rotating through AWS Profiles to Overwrite the Default
#!/usr/bin/env python3
"""
AWS Profile Rotation Script
"""
import argparse
import configparser
import pathlib
from copy import deepcopy
@juftin
juftin / recursive_namespace.py
Last active November 25, 2022 17:37
Recursive SimpleNamespace Extension
"""
Extending the SimpleNamespace Class
"""
import datetime
from functools import singledispatch
from types import SimpleNamespace
from typing import Any
@juftin
juftin / json_encoding.py
Last active July 1, 2023 07:12
Custom JSON Encoder function
"""
Custom JSON Encoding
Thanks Pydantic! https://github.com/samuelcolvin/pydantic/blob/master/pydantic/json.py
"""
from collections import deque
from dataclasses import asdict, is_dataclass
import datetime
from decimal import Decimal
@juftin
juftin / cohorting.py
Last active April 8, 2022 15:00
Reproducible Cohorting
"""
Reproducible Cohorting for Experiments
"""
import hashlib
import logging
from typing import Dict, Optional, Tuple
import numpy as np
from pandas import DataFrame
@juftin
juftin / month_completion.py
Created September 5, 2020 20:49
Python: Retrieve Percent Through Month
#!/usr/bin/env python3
# Author:: Justin Flannery (mailto:juftin@juftin.com)
"""
An Easy Script for Retrieving the Percent Through the Current Month
"""
from calendar import monthrange
from datetime import datetime