Skip to content

Instantly share code, notes, and snippets.

View Kirill-Shklyarenko's full-sized avatar
🎯
Focusing

Kirill Shklyarenko Kirill-Shklyarenko

🎯
Focusing
View GitHub Profile
@nymous
nymous / README.md
Last active April 27, 2026 01:57
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

func SendPushNotification(deviceTokens []string) error {
decodedKey, err := getDecodedFireBaseKey()
if err != nil {
return err
}
opts := []option.ClientOption{option.WithCredentialsJSON(decodedKey)}
app, err := firebase.NewApp(context.Background(), nil, opts...)
@franklinmoy3
franklinmoy3 / opkg_updater.sh
Last active February 21, 2026 10:09
OpenWRT OPKG update all installed packages
#!/bin/sh
# Example of job definition (as add job using crontab -e):
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
# 30 02 15,28 * * /root/opkg_updater.sh
@uudashr
uudashr / Dockefile
Last active July 15, 2022 00:52
Docker and entrypoint
# == Builder ==
FROM golang:1.13.7-alpine3.11 as builder
RUN apk add --no-cache \
bash=5.0.11-r1 \
git=2.24.1-r0 \
mercurial=5.2.1-r0 \
openssh-client=8.1_p1-r0
ARG SSH_PRIVATE_KEY
@101t
101t / python-cheatsheet.md
Last active December 20, 2025 17:22
Python Cheatsheet
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active May 6, 2026 08:33
Conventional Commits Cheatsheet
@lacoski
lacoski / celery.py
Created November 26, 2018 01:49 — forked from ashwoods/celery.py
Sentry Django & Celery >=4.0 integration
# If following the official celery documentation for integration django
# you might have a `celery.py` file that looks like this.
from __future__ import absolute_import, unicode_literals
import os
import logging
from celery import Celery
# from celery.utils.log import get_task_logger
from celery import signals
@ww9
ww9 / context_keys_as_struct_not_int_or_string.md
Last active October 24, 2025 04:26
Why use empty struct{} and not int or string for context.Value() key types in #go

Use struct{} as keys for context.Value() in Go

In the other file of this gist I detail why we should use struct{} as context.Value() keys and not int or string. Open gist to see main.go but the TLDR is:

	type key struct{}
	ctx = context.WithValue(ctx, key{}, "my value") // Set value
	myValue, ok := ctx.Value(key{}).(string) // Get value
@AveYo
AveYo / .. MediaCreationTool.bat ..md
Last active May 5, 2026 12:29
Universal MediaCreationTool wrapper for all MCT Windows 10 versions - MOVED TO github.com/AveYo/MediaCreationTool.bat
@coryodaniel
coryodaniel / k8s.Makefile
Last active August 9, 2023 23:37
A makefile for doing common things with kubectl
##################################################
## A makefile for doing common things with kubectl
##################################################
ifndef K8S_PROJECT_NAME
$(error K8S_PROJECT_NAME is not set. Please set this to your k8s project namein YOUR Makefile)
endif
UNAME_S := $(shell uname -s)
STAGING_NAMESPACE = staging-${K8S_PROJECT_NAME}