Skip to content

Instantly share code, notes, and snippets.

View aryaniyaps's full-sized avatar
🎯
Focusing

Aryan Iyappan aryaniyaps

🎯
Focusing
View GitHub Profile
@vaclavcadek
vaclavcadek / Dockerfile
Last active May 16, 2025 12:36
Simple example of AWS Lambda + custom image, usage: 1) docker build . -t test/hello-world 2) docker run --rm -p 9000:8080 test/hello-world:latest 3) curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"foo": "test"}'
FROM python:3.8-alpine
# Define global args
ARG FUNCTION_DIR="/home/app/"
RUN apk add --no-cache \
libstdc++
# Install aws-lambda-cpp build dependencies
RUN apk add --no-cache \
@samuelcolvin
samuelcolvin / webauthn_client.js
Created November 17, 2021 22:32
demo of webauthn using FastAPI
const log_el = document.getElementById('log')
function log(...messages) {
console.log(...messages)
log_el.innerText += '\n' + messages.map(m => JSON.stringify(m, null, 2)).join(' ')
}
function error(message) {
console.error(message)
log_el.innerText += '\n' + message
@notypecheck
notypecheck / main.py
Last active March 14, 2022 11:50
Strawberry GraphQL Cursor Pagination
import base64
import enum
from typing import Any, Optional, Annotated
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import InstrumentedAttribute, DeclarativeMeta
from sqlalchemy.sql import Select
from gql.modules.users._fields import UserOrder
@nymous
nymous / README.md
Last active April 22, 2025 21:37
Logging setup for FastAPI, Uvicorn and Structlog (with Datadog integration)

Logging setup for FastAPI

This logging setup configures Structlog to output pretty logs in development, and JSON log lines in production.

Then, you can use Structlog loggers or standard logging loggers, and they both will be processed by the Structlog pipeline (see the hello() endpoint for reference). That way any log generated by your dependencies will also be processed and enriched, even if they know nothing about Structlog!

Requests are assigned a correlation ID with the asgi-correlation-id middleware (either captured from incoming request or generated on the fly). All logs are linked to the correlation ID, and to the Datadog trace/span if instrumented. This data "global to the request" is stored in context vars, and automatically added to all logs produced during the request thanks to Structlog. You can add to these "global local variables" at any point in an endpoint with `structlog.contextvars.bind_contextvars(custom

@aryaniyaps
aryaniyaps / generate_webauthn_keys.py
Created March 16, 2025 03:14
Generate WebAuthn Credential Key Pair
import base64
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ec
def generate_webauthn_keys():
# Generate an ECDSA P-256 private key
private_key = ec.generate_private_key(ec.SECP256R1())