Skip to content

Instantly share code, notes, and snippets.

View sebastianknopf's full-sized avatar

Sebastian Knopf sebastianknopf

View GitHub Profile
@sebastianknopf
sebastianknopf / README.md
Last active June 8, 2026 09:04
mthk-setup

mthk-setup

This utility script generates X509 certificates out of the PKCS12 certificate issued by Mobilithek for client and server authentification. Optinally, the certificates can be installed at the correct location depending on your Linux distribution used. The setup is also able to generate a virtual host with Apache or Nginx.

Prerequisites

  • Linux distributed OS
  • OpenSSL for certificate and key extraction
  • Apache/Nginx for generating a VHost

Usage

Extract certificate, chain and unprotected key:

@sebastianknopf
sebastianknopf / backend.instructions.md
Created May 1, 2026 07:48
Python & Vue WebApp Template w/DockerCompose
description Backend development instructions for Python/FastAPI service. Use when: modifying Python code, API endpoints, database models, migrations, adapters, backend services, or backend tests.
applyTo
backend/**/*.py
backend/pyproject.toml
backend/Dockerfile

Backend Development Instructions

using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
namespace Vdv
{
public class X10File
{
#region Static Helper Methods
public static X10File ReadX10File(string filename, string nullValue = "NULL", string encoding = "utf-8", Dictionary<string, object?>? filter = null)
@sebastianknopf
sebastianknopf / CsvReader.cs
Created January 29, 2026 08:16
utility classes for reading and writing CSV files
using System.Text;
namespace CSV
{
public class CsvReader : IDisposable
{
public List<string> Headers { get; protected set; }
private StreamReader streamReader;
private char delimiter;
@sebastianknopf
sebastianknopf / README.md
Last active February 24, 2026 18:35
dependency free configuration utility for python

This configuraiton utility has three main purposes...

  1. Validate the given configuration for having all required keys
  2. Setting defined default values for optional keys
  3. Putting everything into the Configuration class

After running Configuration.apply_config(...), you simply can access your configs with Configuration.this.is.a.required.key or Configuration.this.is.an.optional.key.

v1.1: Now works also with repeated keys representing a list.

@sebastianknopf
sebastianknopf / x10.py
Created November 27, 2025 20:48
helper class for reading / modifying / writing *.x10 files
import csv
import re
from typing import Iterable
########################################################################################################################
# Helper class for reading and modifying *.x10 files.
########################################################################################################################
def read_x10_file(filename, null_value: str = 'NULL', encoding: str = 'utf-8', filter: dict|None = None) -> "X10File":
@sebastianknopf
sebastianknopf / repeatedtimer.py
Created June 18, 2025 08:28
repeatedtimer.py
from threading import Timer
class RepeatedTimer(object):
def __init__(self, interval, function, *args, **kwargs):
self._timer = None
self.interval = interval
self.function = function
self.args = args
self.kwargs = kwargs
@sebastianknopf
sebastianknopf / basexml.py
Created May 19, 2025 15:32
Utility functions to work with objectified LXML data implemented in Python
import re
def exists(obj, path):
path = path.split('.')
level0 = path[0]
level1 = '.'.join(path[1:])
return obj is not None and hasattr(obj, level0) if len(path) == 1 else exists(getattr(obj, level0), level1) if hasattr(obj, level0) else False
@sebastianknopf
sebastianknopf / datalog.py
Last active June 21, 2025 17:00
datalog.py
import json
import os
from datetime import datetime
from lxml.etree import fromstring
from lxml.etree import tostring
class Datalog:
@classmethod
@sebastianknopf
sebastianknopf / csv2ddb.py
Last active October 13, 2024 19:30
python helper script for memory efficient importing huge CSV files into a DuckDB database
import click
import csv
import duckdb
import polars
@click.command
@click.option('--file', '-f', help='Input CSV file')
@click.option('--db', '-d', help='DuckDB filename')
@click.option('--table', '-t', help='Destination table name to import the CSV file')
@click.option('--create-statement', '-c', default=None, help='Create statement filename for destination table')