Skip to content

Instantly share code, notes, and snippets.

@diefans
diefans / threadpool_contextvars.py
Created June 26, 2025 08:33 — forked from nkhitrov/threadpool_contextvars.py
ThreadPoolExecutor with contextvars and asyncio
import contextvars
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
current_user = contextvars.ContextVar("ID of current user")
shared_user = contextvars.ContextVar("ID of shared user")
def say_hello():
time.sleep(1)
@diefans
diefans / .Xresources
Created October 14, 2024 13:44 — forked from Pitometsu/.Xresources
dotfiles
Xcursor.theme: ATER
! UI elements
Emacs.menuBar: 0
Emacs.toolBar: 0
Emacs.verticalScrollBars: off
! Font settings
Emacs.FontBackend: xft,x
Emacs.font: Inconsolata LGC-8.6
@diefans
diefans / test_sqlalchemy+asyncpg.py
Created July 5, 2024 10:17 — forked from rafaelhenrique/test_sqlalchemy+asyncpg.py
Sqlalchemy + Asyncpg + Pytest = <3
# reference: https://github.com/sqlalchemy/sqlalchemy/issues/5626
import pytest
import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
Base = orm.declarative_base()
@diefans
diefans / tiltfiles-collection.md
Created January 20, 2024 14:56 — forked from rasheedamir/tiltfiles-collection.md
tiltfiles-collection
# note that helm tempates are converted into yaml and a kubectl apply is run on the yaml object, ie `helm ls` will not show anything

# TODO move these to config files
settings = {
  "start_kind": True,
  "preload_images_for_kind": True,
  "deploy_metallb": True,
  "deploy_ambassador_api": False,
  "deploy_ambassador_edge_gateway": False,
@diefans
diefans / kongwithingress.yaml
Created January 10, 2024 10:36 — forked from bgarcial/kongwithingress.yaml
Installing kong to work ingress on Kubernetes
apiVersion: v1
kind: Namespace
metadata:
name: kong
---
apiVersion: v1
kind: Secret
metadata:
@diefans
diefans / gnome_40_wayland_nvidia.nix
Created October 29, 2022 15:54 — forked from wochap/gnome_40_wayland_nvidia.nix
Nixos config for wayland and nvidia 470
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
let
# Get the last working revision with nvidia 460.x
nixos-unstable-pinned = import (builtins.fetchTarball {
name = "nixos-unstable_nvidia-x11-470.57.02";
@diefans
diefans / k3s_helm_install.sh
Created July 7, 2022 10:38 — forked from icebob/k3s_helm_install.sh
K3S + Helm installing
# Install K3S
curl -sfL https://get.k3s.io | sh -
# Copy k3s config
mkdir $HOME/.kube
sudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
sudo chmod 644 $HOME/.kube/config
# Check K3S
kubectl get pods -n kube-system
@diefans
diefans / nixos_python_patch_venv_bins.md
Created April 5, 2022 17:02 — forked from GuillaumeDesforges/nixos_python_patch_venv_bins.md
How to: make Python dependencies installed via pip work on NixOS

How to: make Python dependencies installed via pip work on NixOS

The issue

  • You are using NixOS
  • You start working on a Python project
  • You manage the dependencies in a classic Python virtual environment using pip or poetry

You won't be able to import some of those libraries.

@diefans
diefans / settings.lua
Created March 12, 2022 19:15 — forked from lalitmee/settings.lua
nvim settings
local fn = vim.fn
local api = vim.api
local executable = function(e)
return fn.executable(e) > 0
end
local opts_info = vim.api.nvim_get_all_options_info()
local opt = setmetatable(
{}, {
@diefans
diefans / sync-history.sh
Created September 24, 2021 10:10 — forked from jan-warchol/sync-history.sh
Synchronize history across bash sessions
# Synchronize history between bash sessions
#
# Make history from other terminals available to the current one. However,
# don't mix all histories together - make sure that *all* commands from the
# current session are on top of its history, so that pressing up arrow will
# give you most recent command from this session, not from any session.
#
# Since history is saved on each prompt, this additionally protects it from
# terminal crashes.