Skip to content

Instantly share code, notes, and snippets.

View timvw's full-sized avatar

Tim Van Wassenhove timvw

View GitHub Profile
@timvw
timvw / .tmux.conf
Last active February 12, 2026 12:48
Tmux config with Zellij-style shortcut hints bar - training wheels for tmux newcomers
# =============================================================================
# Tmux Training Wheels Configuration
# A Zellij-inspired shortcut hints bar for tmux newcomers
#
# Blog post: https://timvw.be/2026/02/12/tmux-training-wheels-a-zellij-inspired-shortcut-hints-bar/
# =============================================================================
# --- General settings ---
set -g mouse on # Enable mouse support (scroll, select, resize)
set -g history-limit 100000 # Generous scrollback buffer
@timvw
timvw / aws.tf
Created February 9, 2025 18:25
Terraform for Authentik as IdentityProvider in AWS Identity Center
# Authentik SAML Provider
resource "authentik_provider_saml" "aws" {
name = "AWS IAM Identity Center"
authorization_flow = data.authentik_flow.default_authorization_flow.id
invalidation_flow = data.authentik_flow.default_invalidation_flow.id
acs_url = "https://eu-central-1.signin.aws.amazon.com/platform/saml/acs/XXXX"
audience = "https://eu-central-1.signin.aws.amazon.com/platform/saml/d-YYYY"
issuer = "https://eu-central-1.signin.aws.amazon.com/platform/saml/d-YYYY"
signing_kp = data.authentik_certificate_key_pair.default.id
sp_binding = "post"
@timvw
timvw / main.py
Created September 10, 2024 12:34
Entrypoint for FastAPI/uvicorn application executed as python script
import uvicorn
if __name__ == "__main__":
'''
Entrypoint to run the FastAPI application (without using the FastAPI/Uvicorn CLI).
Because a python script can't import relatively, we apply a sys.path hack to import the application.
Typically you do not need this and simply invoke one of the following:
* rye run fastapi dev ./src/backend/app.py
* fastapi run dev ./src/backend/app.py
@timvw
timvw / gist:a71c222b93c11e7d0d2b0f0b02220ea6
Last active May 15, 2024 09:33
python importlib for modules with keyword in path
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
models = importlib.import_module("api.lambda.models")
@timvw
timvw / gist:4419f55e4b52a719655b0ea8ce5cbd2e
Created May 14, 2024 08:38
raise openai.RateLimitError
import httpx
request = httpx.request("GET", "https://google.com")
response = httpx.Response(429, request=request)
err = openai.RateLimitError(
"you are making too many requests...", response=response, body=None
)
raise err
@timvw
timvw / openapi-client-generator.sh
Created May 13, 2024 07:54
Generate python openapi client
docker run \
-v $PWD:/local \
openapitools/openapi-generator-cli generate \
-i /local/myapplication/stacks/apis/my_api.yaml \
-g python \
-o /local/target/openapi/python
@timvw
timvw / gist:d1c59acb70e0357b8ef34022ef4864fa
Created May 9, 2024 20:45
Remove password from pdf (preview bug)
LC_ALL=C sed -i '' -e 's/\/EncryptMetadata false/\/EncryptMetadata true/g' ~/Desktop/kbvb_wedstrijdblad_tornooien___formulier_v.1.3.pdf
@timvw
timvw / .profile
Created April 30, 2024 07:58
Shell function to load a dotenv file
dotenv() {
readonly env_file=${1:?"The env_file must be specified."}
set -o allexport
source ${env_file}
set +o allexport
}
@timvw
timvw / mysql.txt
Created April 30, 2024 07:44
mysql
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -u root
To start mysql now and restart at login:
brew services start mysql
==> postgresql@16
This formula has created a default database cluster with:
initdb --locale=C -E UTF-8 /opt/homebrew/var/postgresql@16
For more details, read:
https://www.postgresql.org/docs/16/app-initdb.html
postgresql@16 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
If you need to have postgresql@16 first in your PATH, run: