View dataclass_constructor.py
This file contains 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 dataclasses import dataclass | |
from typing import Self | |
@dataclass | |
class Example: | |
field1: str | |
field2: str | |
@classmethod | |
def from_input_data(cls, data) -> Self: |
View fastapi_postgres_async_example.py
This file contains 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 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 |
View async_fastapi_cache.py
This file contains 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 | |
from functools import wraps | |
from fastapi import FastAPI, Request | |
from fastapi.responses import HTMLResponse | |
from fastapi.templating import Jinja2Templates | |
def cache_response(func): | |
""" |
View Switch-HyperVGpuPartitionAdapter.ps1
This file contains 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
param( | |
[Parameter(Mandatory)][string]$vmName | |
) | |
$InformationPreference = "Continue" | |
$ErrorActionPreference = "Stop" | |
try { | |
$vmPartitionAdapter = Get-VMGpuPartitionAdapter -VMName $vmName | |
if ($vmPartitionAdapter) { | |
Write-Information "Removing Partition Adapter. Checkpoints work." |