Skip to content

Instantly share code, notes, and snippets.

View nymous's full-sized avatar
💭
Breaking my Archlinux, again...

Thomas Gaudin nymous

💭
Breaking my Archlinux, again...
View GitHub Profile
@nymous
nymous / vault.js
Last active March 4, 2024 10:07
Vault userscript to display entities and groups names alongside their IDs
// ==UserScript==
// @name Replace Vault IDs with names
// @namespace http://tampermonkey.net/
// @version 2024-03-04
// @description try to take over the world!
// @author You
// @match https://<your vault url>/*
// @icon https://icons.duckduckgo.com/ip2/www.vaultproject.io.ico
// @grant none
// ==/UserScript==
@nymous
nymous / README.md
Last active December 26, 2024 15:40
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

@nymous
nymous / bug.py
Last active March 16, 2021 20:54
Pydantic Literal enum bug in 1.8+
from typing import Literal
from enum import Enum
import logging
from pydantic import BaseModel, ValidationError
from pydantic.utils import version_info
print("=== PYDANTIC INFO ===")
print(version_info())
@nymous
nymous / README.md
Last active November 21, 2020 17:18
Bookmarklet to get a random unplayed movie from your Emby collection

Random unplayed movie in Emby

  1. Go to your Emby interface, open your Movies collection
  2. The URL will look like this: http://1.2.3.4/web/index.html#!/movies?serverId=16fe3a5de47f25fb1de848c0a3f435a9&parentId=fc3b74e25d482b4b1bbd0f314e60f776. Copy the parentId value (the part after parentId=, in this example it's fc3b74e25d482b4b1bbd0f314e60f776
  3. Change the @@MOVIE CATEGORY ID@@ value (between two %22, parentId%3A%20%22@@MOVIE CATEGORY ID@@%22%7D)) in the code below with the value you copied in the previous step (eg. parentId%3A%20%22fc3b74e25d482b4b1bbd0f314e60f776%22%7D)
javascript:(async%20function()%7Bwindow.movies%20%3D%20window.movies%20%7C%7C%20(await%20ApiClient.getItems(await%20ApiClient.getCurrentUserId()%2C%20%7Brecursive%3A%20true%2C%20parentId%3A%20%22@@MOVIE CATEGORY ID@@%22%7D)).Items%3B%0A%20%20%20%20const%20unplayedMovies%20%3D%20movies.filter(movie%20%3D%3E%20movie.UserData.Played%20%3D%3D%3D%20false%20%26%26%20movie.IsFolder%20%3D%3D%3D%20false)%3B%0A%20%20%20%
@nymous
nymous / README.md
Created April 5, 2020 17:12
Pydantic parsing derived classes
@nymous
nymous / sentry.py
Last active February 5, 2020 10:32
Group Sentry events per project
import csv
from collections import Counter
# Download the "Project breakdown" from Sentry
with open("your-file-per-project.csv", "r", newline='') as file:
reader = csv.DictReader(file)
summed = Counter()
for row in reader:
summed.update({row["projectSlug"]: int(row["acceptedEvents"])})
@nymous
nymous / ideas.md
Created December 18, 2017 20:41
Présentation CLOCK
  • JavaScript à la papa, 2009, jQuery, interfaces peu complexes
  • évolution des moteurs JS, naissance de NodeJS, développements front et serveur dans un seul langage, explosion du JS en front, applications SPA...
  • renaissance du langage, nouvelles évolutions avec l'ECMAscript
  • différents frameworks, évolution des méthodes de développement de plus en plus industrielles et complexes (grunt, gulp, webpack)
  • développement du JS comme langage universel, utilisé pour le front web, le back, les applis mobiles (hybrides et/ou natives), les applis desktop...

Keybase proof

I hereby claim:

  • I am nymous on github.
  • I am nymous (https://keybase.io/nymous) on keybase.
  • I have a public key ASBM4TYY-dtuCfvw8tmrXs4_i5wExhVc7Drtmyd-k0_cPwo

To claim this, I am signing this object:

@nymous
nymous / swag.sh
Created September 3, 2017 17:17
Pour recruter les G0
#!/bin/bash
while true
do
clear
echo "
,,:.,::.
,.. ::.
,.. ,,.
.. ,..
.. ,.
@nymous
nymous / BEST_PRACTICES.md
Last active August 29, 2017 15:48
Best practices for every language

Best Practices

Here you can find a number of best practices that you should strive to follow when you develop.
This will ensure that we produce better and safer code, easier to understand, to extend, in short: more maintainable.

Table of Content