Skip to content

Instantly share code, notes, and snippets.

View travischambers's full-sized avatar

Travis Chambers travischambers

  • Mililani, HI
  • 14:50 (UTC -10:00)
View GitHub Profile
@nymous
nymous / README.md
Last active June 29, 2024 10:10
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

@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active June 28, 2024 10:38
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@Colelyman
Colelyman / gist:4049013
Created November 9, 2012 23:30
Simon 124 Cole Lyman
// Beginning of our code
int beat_counter = 0;
int rand_array[] = 100;
bool fail = true;
setrandSeed();
do { // loop for each round
rand_array[beat_counter] = rand16();