Skip to content

Instantly share code, notes, and snippets.

View joshschmelzle's full-sized avatar
༼ つ ◕_◕ ༽つ ø

jsz joshschmelzle

༼ つ ◕_◕ ༽つ ø
View GitHub Profile
@joshschmelzle
joshschmelzle / README.md
Created March 1, 2023 21:03 — forked from nymous/README.md
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

@joshschmelzle
joshschmelzle / push-to-someone-elses-pr.md
Created November 4, 2022 02:21 — forked from wtbarnes/push-to-someone-elses-pr.md
Brief instructions for how to modify and push to someone else's PR on github

How to Push to Someone Else's Pull Request

Let's say contributor has submitted a pull request to your (author) project (repo). They have made changes on their branch feature and have proposed to merge this into origin/master, where

origin -> https://github.com/author/repo.git

Now say you would like to make commits to their PR and push those changes. First, add their fork as a remote called

@joshschmelzle
joshschmelzle / oui3.py
Last active October 16, 2023 00:31 — forked from flagranterror/oui3.py
Handy OUI lookup script for Python 3+. Tested on Windows 10.
#!/usr/bin/python
# Who owns the OUI? IEEE knows.
#
# Auto-refreshes once a month.
# Run with -u to force update.
from urllib.request import urlopen
from getpass import getuser
import codecs
@joshschmelzle
joshschmelzle / nginx.conf
Created June 8, 2017 00:44 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048