Skip to content

Instantly share code, notes, and snippets.

View RafaelWO's full-sized avatar
🤔
thinking...

RafaelWO

🤔
thinking...
  • Salzburg, Austria
  • 21:14 (UTC -12:00)
View GitHub Profile
import datetime
import sys
from typing import Optional
import colorama
import pyramid.config
from loguru import logger
from pyramid.request import Request
from pyramid.response import Response
@matthiasr
matthiasr / gpg_wsl2.md
Last active March 30, 2025 10:58
GPG signing with full gpg-agent support in WSL2: the easy way

Problem statement

Signing with GPG in Windows System for Linux (WSL2) does not work smoothly out of the box. Notably, when using a TTY-based pinentry, signing in Visual Studio Code does not work at all.

Solution

  1. Install Gpg4Win: winget install -e GnuPG.Gpg4win or download and install manually
  2. Start Kleopatra and generate or import keys
  3. Insert links to gpg.exe inside of WSL:
@andgineer
andgineer / db_fixture.py
Created June 9, 2020 15:38
pytest Fixture to rollback all DB changes after test
from sqlalchemy import event
from sqlalchemy.orm import sessionmaker
from app.db.session import engine
import pytest
import app.tests.config
@pytest.fixture(
scope='function',
autouse=True # New test DB session for each test todo we need it only for tests with Client fixture
@yanqd0
yanqd0 / dl_requests_tqdm.py
Last active April 16, 2025 11:52
Python requests download file with a tqdm progress bar
import requests
from tqdm import tqdm
def download(url: str, fname: str, chunk_size=1024):
resp = requests.get(url, stream=True)
total = int(resp.headers.get('content-length', 0))
with open(fname, 'wb') as file, tqdm(
desc=fname,
total=total,
@tomlankhorst
tomlankhorst / docker-swarm-gpu.md
Last active March 17, 2025 06:40
Instructions for Docker swarm with GPUs
@rubo77
rubo77 / rotatescreen.sh
Last active April 2, 2025 08:31
This script rotates the screen (tested on a Lenovo Yoga 730-15iwl) (source: https://askubuntu.com/a/1217290/34298)
#!/bin/bash
# This script rotates the screen and touchscreen
# by Ruben Barkow-Kuder: https://gist.github.com/rubo77/daa262e0229f6e398766
#### configuration
# find your Touchscreen device with `xinput`
TouchscreenDevice="$(xrandr |grep eDP|cut -d" " -f1)"
if [ "$1" = "--help" ] || [ "$1" = "-h" ] ; then
@gene1wood
gene1wood / aws-lambda-relative-import-no-known-parent-package.md
Last active February 13, 2025 22:07
Python relative imports in AWS Lambda fail with `attempted relative import with no known parent package`

Python relative imports in AWS Lambda fail with attempted relative import with no known parent package

The Problem

In AWS Lambda if I attempt an explicit relative import like this

.
├── lambda_file.py
└── example.py
@dazza-codes
dazza-codes / check_numpy_types.md
Last active January 13, 2025 12:59
Checking numpy types
@Rajeshr34
Rajeshr34 / wkhtmltopdf.sh
Last active February 18, 2025 00:30
Wkhtmltopdf With Patched QT Setup Ubuntu 16+
cd ~
apt-get install libfontenc1 xfonts-75dpi xfonts-base xfonts-encodings xfonts-utils openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig -y
#https://github.com/wkhtmltopdf/wkhtmltopdf/releases
#replace arch
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
apt --fix-broken install
@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)