Skip to content

Instantly share code, notes, and snippets.

View dan-osull's full-sized avatar

Dan O'Sullivan dan-osull

View GitHub Profile
from dataclasses import dataclass
from typing import Self
@dataclass
class Example:
field1: str
field2: str
@classmethod
def from_input_data(cls, data) -> Self:
@dan-osull
dan-osull / fastapi_postgres_async_example.py
Created October 28, 2022 19:04
Async PostgreSQL with FastAPI dependency injection & SQLAlchemy
import os
from abc import ABC, abstractmethod
from typing import AsyncIterator, Optional
import uvicorn
from dotenv import load_dotenv
from fastapi import Depends, FastAPI
from fastapi.responses import JSONResponse
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
import asyncio
from functools import wraps
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
def cache_response(func):
"""
param(
[Parameter(Mandatory)][string]$vmName
)
$InformationPreference = "Continue"
$ErrorActionPreference = "Stop"
try {
$vmPartitionAdapter = Get-VMGpuPartitionAdapter -VMName $vmName
if ($vmPartitionAdapter) {
Write-Information "Removing Partition Adapter. Checkpoints work."