Skip to content

Instantly share code, notes, and snippets.

View reimundklain's full-sized avatar

Reimund Klain reimundklain

  • ConDevTec GmbH
  • Munich
View GitHub Profile
@reimundklain
reimundklain / sqa_cte.py
Last active July 3, 2022 20:08
SQLAlchemy ancestors, descendants query via recursive query with ORM Results
from sqlalchemy import Index, Column, ForeignKey, Integer, String
from sqlalchemy.orm import relationship
class Node(Base):
id = Column(Integer, primary_key=True, index=True)
parent_id = Column(ForeignKey("node.id"), nullable=True)
name = Column(String(256), index=False, nullable=False)
__table_args__ = (
Index("ix_node_parent", id, parent_id, unique=True),
@reimundklain
reimundklain / hetzner-dedicated-wipe-and-install-nixos-luks-raid-lvm.sh
Last active December 14, 2023 17:55
Insall NixOS form hetzner rescue system with LUKS RAID1 LVM
#!/usr/bin/env bash
# Installs NixOS on a Hetzner server, wiping the server.
#
# This is for a specific server configuration; adjust where needed.
#
# Prerequisites:
# * Update the script wherever FIXME is present
#
# Usage:
@reimundklain
reimundklain / filters.py
Last active July 24, 2019 09:22
Jinja2 sort natural sort alphanum
import re
from jinja2.filters import environmentfilter, make_attrgetter, ignore_case
@environmentfilter
def sort_alphanum(environment, value, reverse=False, case_sensitive=False, attribute=None):
"""
https://blog.codinghorror.com/sorting-for-humans-natural-sort-order/
Extended use in jinja2
"""
# install deps
apt update && apt install libxpm-dev
phpbrew update
phpbrew install -j $((nproc + 1)) 7.4 +default +json +gd +ctype +dom +openssl +iconv +zip +xml +hash +mbstring +fpm +mysql +intl
phpbrew ext install redis stable
phpbrew ext install opcache stable
phpbrew ext install gd -- \
--enable-gd-native-ttf \
--with-gd=shared \
@reimundklain
reimundklain / CachedHttpServletRequest.java
Last active November 9, 2018 15:34
Re- Reable HttpServletRequest with HttpServletRequestWraper
package de.retarus.edi.gate.filter;
import com.google.common.io.ByteStreams;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;