Skip to content

Instantly share code, notes, and snippets.

View adonig's full-sized avatar

Andreas Donig adonig

  • 94032 Passau, Germany
View GitHub Profile
@adonig
adonig / konsole-auto-darkmode.sh
Created May 5, 2026 08:08
Auto-switch KDE Konsole color scheme to follow the system light/dark mode (bash, XDG Desktop Portal)
# Konsole light/dark auto-switch — broadcasts native Konsole color-schemes
# across all open tabs based on XDG Desktop Portal color-scheme changes.
#
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Andreas Donig
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@adonig
adonig / jsonrepair.py
Created December 28, 2022 13:08
Repair invalid JSON documents in Python
# jsonrepair.py - Repair invalid JSON documents in Python
#
# Just https://github.com/josdejong/jsonrepair ported from TypeScript to Python.
#
# This port won't get updates, because the goal should be to generate this library instead.
#
# See: https://github.com/josdejong/jsonrepair/issues/84
#
import json
@adonig
adonig / index.html
Created May 30, 2018 10:48 — forked from jirik/index.html
Show Klokantech Basic GL Style using ol-mapbox-style
<!DOCTYPE html>
<html>
<head>
<title>Klokantech Basic GL Style using ol-mapbox-style preview</title>
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.19.1/ol.css">
<style>
html, body {
height: 100%;
margin: 0;
@adonig
adonig / code_maximised.sh
Created December 14, 2017 23:46
Start Microsoft Visual Studio Code maximised on Linux. Workaround for https://github.com/Microsoft/vscode/issues/422.
#!/bin/bash
code
while true; do
WINDOW_ID=$(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5 | cut -c 1-9)
WINDOW_CLASS=$(xprop -id $WINDOW_ID WM_CLASS | sed 's/.*= "\([^"]*\)".*/\1/')
if [ "${WINDOW_CLASS,,}" = "code" ]; then
break
fi
done
wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz
@adonig
adonig / context.py
Last active March 17, 2017 18:43
What happens in context, stays in context.
from contextlib import AbstractContextManager
from types import SimpleNamespace
class Context(SimpleNamespace, AbstractContextManager):
def __enter__(self):
self._globals = dict(globals())
globals().update(self.__dict__)
return self