Skip to content

Instantly share code, notes, and snippets.

View martimors's full-sized avatar
🤳

Martin Morset martimors

🤳
  • Copenhagen
View GitHub Profile
@martimors
martimors / split_helm_template.py
Created February 10, 2025 09:56
Split the output of the `helm template` command into multiple yaml files using the source path
#!/usr/bin/env python3
import yaml
from pathlib import Path
import re
import argparse
import os
import sys
class Args(argparse.Namespace):
@martimors
martimors / pre-commit-config.yaml
Last active March 14, 2023 21:56
Pre-commits for a python project
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
args: [--config=./pyproject.toml]
- repo: https://github.com/python-poetry/poetry
rev: 1.3.0
hooks:
- id: poetry-check
@martimors
martimors / cockroach.yaml
Created May 24, 2022 15:01
Run a single-node standalone non-root cockroachdb in kubernetes
---
apiVersion: v1
kind: Service
metadata:
name: cockroachdb
spec:
selector:
app: cockroachdb
type: ClusterIP
ports:
@martimors
martimors / postgresql.yaml
Created May 4, 2022 08:52
Non-root non-persistent postgresql container in kubernetes
---
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
selector:
app: postgres
ports:
- port: 5432
@martimors
martimors / Dockerfile
Created March 31, 2022 08:45
Dockerfile for FastAPI using PDM package manager
# Builder container uses pdm to install dependencies
FROM python:3.10 AS builder
ENV PDM_VERSION=1.13.4
WORKDIR /build
COPY pdm.lock pyproject.toml ./
RUN python -m pip install --upgrade pip setuptools wheel
RUN pip install pdm && pdm install --prod --no-lock --no-editable
@martimors
martimors / pyproject.toml
Created March 31, 2022 08:43
pyproject.toml settings for common linters and formatters
[tool.black]
line-length = 100
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.mypy_cache
| \.tox
| \.venv
| venv
@martimors
martimors / .flake8
Created March 31, 2022 08:42
Sensible flake8 settings for Python
[flake8]
# Specify a list of codes to ignore.
ignore =
E203, # whitespace before ‘:’ (conflicts with black)
E501, # line too long (black will fix this)
W503, # line break before binary operator (conflicts with black)
F821, # undefined name error, (bug in pyflakes)
max-line-length = 100
max-complexity = 12
# Specify the list of error codes you wish Flake8 to report.
@martimors
martimors / .pre-commit-config.yaml
Created March 31, 2022 08:42
Sensible pre-commits to use with Python
# Apply to all files without committing:
# pre-commit run --all-files
# Update this file:
# pre-commit autoupdate
repos:
# format markdown files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.6.1"
hooks:
@martimors
martimors / aaaaah.py
Created October 22, 2021 07:31
Bruteforce environmental variable guessing game because FIX YOUR DOCS
prefixes = ["", "SCHEMA_REGISTRY", "SCHEMA_REGISTRY_SCHEMA_REGISTRY"]
middle = ["CONFLUENT", "KAFKASTORE", "ACL", "TOPIC"]
suffix = ["GROUP_ID", "GROUPID", "CONSUMER_GROUP_ID", "CONSUMER_GROUPID", "GROUP"]
from itertools import permutations
middle_choices = []
for a in range(len(middle)+1):
@martimors
martimors / notebook_to_py_script.sh
Last active September 15, 2020 08:25
Convert all jupyter in path tree to *.py excluting certain directories
# Significantly reduces the size of the repository
# The scripts can be converted back into notebooks, but the cache will be lost
# Excludes the directory ./venv and any directory with a . prefix such as .git
# Converts all jupyter notebooks to python scripts recursively starting from $(pwd)
find . -path ./venv -prune -false -o -name '*.ipynb' | xargs -0 jupyter nbconvert --to script