Skip to content

Instantly share code, notes, and snippets.

View mara004's full-sized avatar
💭
on recovery

mara004

💭
on recovery
View GitHub Profile
@mara004
mara004 / layereddict.py
Last active July 23, 2026 11:42
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
@mara004
mara004 / yt_revanced.md
Last active June 13, 2025 22:20
On Procuring YouTube ReVanced

In the course of this process, you will download several apps from external sources. To be on the safe side, you'll want to check each APK with https://www.virustotal.com/ before installation. You are also encouraged to use Firefox with uBlockOrigin and the Badware Risks filter list enabled, as a precaution against scamming sites.

  1. Install ReVanced Manager from https://github.com/ReVanced/revanced-manager/releases/latest or https://revanced.app/download
  2. Open ReVanced Manager (grant permission to install apps when asked for). Tap Patches -> Select an app. Look for YouTube and the Suggested: version. It should be in the 3rd line. (Do not use the 1st line, that's your installed version of YouTube.)
  3. Go to https://www.apkmirror.com/ and search for YouTube $VERSION, where $VERSION is the suggested version you have determined in (2). (Alternatively, tap on the Suggested: ... field to do a browser search that may lead you to the apkmirror site in question.) Once you've found the right APK, downlo
@mara004
mara004 / phone_oss.md
Last active July 17, 2025 19:56
Open-source software for mobile phones
  • F-Droid
  • Firefox (with uBlockOrigin and Dark Reader)
  • Thunderbird (K9 Mail), (FreeMail)
  • VLC, KeePassDX, KDE Connect
  • NewPipe, LibreTube, YTDLnis, Seal
  • Signal, Wire
  • Termux
  • AdAway
  • Magisk/Zygisk, TWRP +? Zygisk Assistant or similar
  • LineageOS
@mara004
mara004 / run_with_args.py
Last active January 26, 2026 23:58
Wrap a python module's CLI entrypoint with argfiles support
#! /usr/bin/env python3
# SPDX-FileCopyrightText: 2026 mara004 <geisserml@gmail.com>
# SPDX-License-Identifier: BSD-2-Clause
import sys
import shlex
from pathlib import Path
from importlib import import_module
from importlib.metadata import entry_points
@mara004
mara004 / SOFTWARE_TODO.txt
Last active October 30, 2025 16:35
My software tasks
ghostscript:
- handle formats
pdfjs:
- File a bug report at node-canvas asking to expose cairo_image_surface_create_for_data()
priv:
- Write a hosts file management script (using Steven Black's hosts)
local: