Skip to content

Instantly share code, notes, and snippets.

View christophmeissner's full-sized avatar

Christoph Meißner christophmeissner

View GitHub Profile
@christophmeissner
christophmeissner / sqlite3dumper.py
Created February 10, 2024 20:09
Dump and compress a sqlite3 db into an bzip2 compressed SQL file
import argparse
import bz2
import itertools
import os
import subprocess
import sys
try:
from humanize import naturalsize
except ImportError:
@christophmeissner
christophmeissner / leipzig_allris_paper_tree_extractor.py
Created February 8, 2024 16:06
Extract document lineage (aka. as tree) information for a given paper from Leipzig's Ratsinformationssystem "ALLRIS" + OParl (Council Information System)
import argparse
import logging
import re
from urllib.parse import urljoin
import requests
from lxml import etree, html
logger = logging.getLogger(__name__)
@christophmeissner
christophmeissner / org.psf.blackd.plist
Last active May 19, 2023 17:47
org.psf.blackd.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.psf.blackd.plist</string>
<key>Name</key>
<string>blackd</string>
@christophmeissner
christophmeissner / Measurement+Convinience.swift
Created March 10, 2023 21:50
Swift Extension for Measurement<Unit> to add convinience initializers
import Foundation
/**
Shortcuts to instanciate Measurement<...> objects directly by calling the unit with it's value.
For example...
let distance = Measurement<UnitLength>(value:123.4, unit:.meters)
...becomes...
@christophmeissner
christophmeissner / brace_format_logging.py
Created April 13, 2022 14:54
Python BraceFormatLoggerAdapter logger adapter for "brace format" messages (eg. `logger.info("number: {}", 123)`)
import logging
class BraceFormatMessage:
def __init__(self, fmt, *args, **kwargs):
self.fmt = fmt
self.args = args
self.kwargs = kwargs
def __str__(self):
@christophmeissner
christophmeissner / serial_prompt.py
Created June 2, 2021 09:43
Cheapo Python Serial Prompt
# coding: utf-8
import serial
if __name__ == "__main__":
encoding = "windows-1252"
tty = "/dev/tty.usbserial-A10JWRZV"
baudrate = 9600
timeout = 1
with serial.Serial(tty, baudrate=baudrate, timeout=timeout) as ser:
print(ser)
@christophmeissner
christophmeissner / example.cs
Created September 13, 2019 08:28 — forked from brandonmwest/example.cs
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));

Some Notes on PyCharm

Scope Pattern for "No Tests"

Sometimes, you want to search for the name of a method only within the code, not in the test. When the tests are spread all over the project, that is quite hard to do, since you can not simply exclude the test suit from the search scope.

Use the exclusion pattern !(file:*test*||file:*/*test*//*) in a PyCharm scope pattern, to exclude all files, that are having...

  • ... the term test in it (!file:*test*), or
#!/usr/bin/env python
import os
import subprocess
import sys
PATH = os.environ["PATH"]
if '/usr/local/bin' not in PATH:
PATH = "/usr/local/bin:{}".format(PATH)
env = {"PATH": PATH}
@christophmeissner
christophmeissner / oclint.yaml
Created January 12, 2018 13:06
Default OCLint rule configuration file
################################################################################
# #
# Sample OCLint configuration file with current (v0.13) default values. #
# #
# Place this file in the directory you invoke oclint from and rename it #
# to '.oclint' #
# #
# See http://oclint-docs.readthedocs.io/en/stable/howto/rcfile.html #
# #
################################################################################