Skip to content

Instantly share code, notes, and snippets.

View mara004's full-sized avatar
πŸ”„

mara004

πŸ”„
View GitHub Profile
@mara004
mara004 / micro-settings.json
Created October 14, 2026 19:43
Editor config
{
"colorcolumn": 100,
"colorscheme": "monokai-dark",
"keepautoindent": true,
"softwrap": true,
"tabstospaces": true,
"wordwrap": true
}
@mara004
mara004 / env.txt
Last active October 13, 2026 19:25
How to fix Qt/KDE application theming in Enlightenment
QT_QPA_PLATFORMTHEME=kde # not gtk2
QT_STYLE_OVERRIDE=Breeze
@mara004
mara004 / git_net_additions.py
Last active August 28, 2026 20:37
Analyze net additions with git
# SPDX-FileCopyrightText: 2026 geisserml <geisserml@gmail.com>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
# This is essentially a copy of https://github.com/pypdfium2-team/pypdfium2/blob/11c67012f256abd3c402c47e9abe26bfbc3d182e/utils/dev/git_net_additions.py
# Please check pypdfium2's main branch for possible updates.
# Augment `git diff --numstat` with a delta column (net additions, i.e. additions-deletions), and sort the output by that column.
# This helps maintainers analyze net growth (or degrowth) between refs on a per file basis, ordered by relevance, with the highest net additions shown first. (Author's note: AOTW, neither git itself, nor GitHub, nor any other tool I'm aware of seemed to offer that functionality.)
# For completeness, this script also adds a churn column (absolute additions+deletions) as in `git diff --stat`. Validates the final result against `git diff --shortstat`.
@mara004
mara004 / regextract.py
Last active August 8, 2026 16:35
`grep -o` substitute for pythoneers
import re, sys
pattern = sys.argv[1]
out_pattern = sys.argv[2]
string = sys.argv[3]
match = re.search(pattern, string)
result = out_pattern % match.groups()
print(result, end="")
@mara004
mara004 / layereddict.py
Last active October 15, 2026 16:20
Layered dictionary (__missing__ hook)
class layereddict (dict):
def __init__(self, layer, **kwargs):
super().__init__(**kwargs)
self._layer = layer
def __missing__(self, key):
return self._layer[key]
@mara004
mara004 / class_kit.py
Last active July 26, 2026 18:05
Cached properties with slots, via metaclass (Clean, declarative variant)
# SPDX-FileCopyrightText: 2026 geisserml <geisserml@gmail.com>
# SPDX-License-Identifier: MPL-2.0
import stl # local
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from functools import cached_property as cached_prop_typehint
else:
def cached_prop_typehint(func):
@mara004
mara004 / class_kit_old.py
Last active July 23, 2026 07:22
Cached properties with slots, via metaclass (Hacky variant)
# SPDX-FileCopyrightText: 2026 geisserml <geisserml@gmail.com>
# SPDX-License-Identifier: MPL-2.0
from typing import TYPE_CHECKING
from stl import cached_property
if TYPE_CHECKING:
from functools import cached_property
def _func_visitor(cp_map):
@mara004
mara004 / cached_property.py
Last active July 23, 2026 12:57
Custom cached property implementation (backward compatible)
# SPDX-FileCopyrightText: 2026 geisserml <geisserml@gmail.com>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
# See also
# https://github.com/pypdfium2-team/pypdfium2/blob/950aeb49b8aa1b5e9bc248b1ff293d4e586bf41b/src/pypdfium2_stl/shared/stl.py
# https://stackoverflow.com/a/78825819/15547292
# https://gist.github.com/mara004/076e3110aba8e8a3f8a6f2c84af350ee
class cached_property:
"""
@mara004
mara004 / .XCompose
Last active July 18, 2026 14:56
Custom compose sequences
# Dump your /usr/share/X11/locale/en_US.UTF-8/Compose below and save as ~/.XCompose
<Multi_key> <minus> <numbersign> : "‑" U2011 # NONBREAKING HYPHEN
@mara004
mara004 / at_function_exit.py
Created August 8, 2025 13:45
Exit hanlder for function
# SPDX-FileCopyrightText: 2025 geisserml <geisserml@gmail.com>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
import functools
class finally_decorator:
def __init__(self, callback):
self._callback = callback