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 / 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