Skip to content

Instantly share code, notes, and snippets.

@vxgmichel
vxgmichel / amerge.py
Created May 16, 2024 15:54
Merge of async generators using anyio
import random
import asyncio
from contextlib import asynccontextmanager
from typing import AsyncIterable, AsyncIterator, TypeVar
from anyio import create_memory_object_stream, create_task_group
from anyio.abc import ObjectReceiveStream, TaskStatus
from anyio.streams.memory import MemoryObjectSendStream
T = TypeVar("T")
@veekaybee
veekaybee / normcore-llm.md
Last active July 11, 2025 21:17
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

@parmus
parmus / aliases.sh
Last active September 18, 2024 19:59
YAML syntax highlighting in less using yq
# YAML syntax highlight for the terminal. Just pipe YAML through it.
alias yc='yq -C eval-all'
# Less with YAML syntax highlighting
alias yless='yq -C eval-all | less -R'
@akrylysov
akrylysov / README.md
Last active October 2, 2024 17:32
Fast Intel-on-ARM Docker on macOS with Lima and Rosetta

macOS 13 Ventura introduced support of running amd64 binaries with Rosetta inside of arm64 Linux VMs when using Apple Virtualization framework.

Lima VM v0.14.0 and later support the new feature.

Setup:

# Install Docker client and Lima
brew install docker docker-compose docker-credential-helper lima
@Kludex
Kludex / main.py
Created December 5, 2022 08:58
Uvicorn logging for prod & dev
import logging
import sys
from typing import List
import structlog
import uvicorn
from fastapi import FastAPI
from structlog.stdlib import ProcessorFormatter
from structlog.types import Processor
@gordthompson
gordthompson / postgresql_df_upsert.py
Last active March 17, 2025 21:46
Build a PostgreSQL INSERT … ON CONFLICT statement and upsert a DataFrame
# Copyright 2024 Gordon D. Thompson, [email protected]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@nymous
nymous / README.md
Last active July 11, 2025 15:54
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

@sts10
sts10 / rust-command-line-utilities.markdown
Last active July 14, 2025 01:02
A curated list of command-line utilities written in Rust

A curated list of command-line utilities written in Rust

Note: I have moved this list to a proper repository. I'll leave this gist up, but it won't be updated. To submit an idea, open a PR on the repo.

Note that I have not tried all of these personally, and cannot and do not vouch for all of the tools listed here. In most cases, the descriptions here are copied directly from their code repos. Some may have been abandoned. Investigate before installing/using.

The ones I use regularly include: bat, dust, fd, fend, hyperfine, miniserve, ripgrep, just, cargo-audit and cargo-wipe.

  • atuin: "Magical shell history"
  • bandwhich: Terminal bandwidth utilization tool
@phortuin
phortuin / signing-git-commits.md
Last active July 11, 2025 12:49
Set up a GPG key for signing Git commits on MacOS (M1)

Based on this blogpost.

To sign Git commits, you need a gpg key. GPG stands for GNU Privacy Guard and is the de facto implementation of the OpenPGP message format. PGP stands for ‘Pretty Good Privacy’ and is a standard to sign and encrypt messages.

Setting up

Install with Homebrew:

$ brew install gpg
@davidfowl
davidfowl / .NET6Migration.md
Last active April 11, 2025 11:12
.NET 6 ASP.NET Core Migration