Skip to content

Instantly share code, notes, and snippets.

View wbolster's full-sized avatar
🎹
🦄

wouter bolsterlee wbolster

🎹
🦄
View GitHub Profile
@waszil
waszil / attrs_lazy_loading.py
Last active December 4, 2021 21:55
Lazy loading attributes with python attrs
"""
Example for creating classes with attrs that contain lazy-loaded fields.
"""
import attr
_lazy_fields_container_name = "_lazy_fields"
_lazy_field_metadata_key = "lazy"
_lazy_loader_function_prefix = "lazy_loader__"
@IanColdwater
IanColdwater / twittermute.txt
Last active April 22, 2024 17:26
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@huntrar
huntrar / full-disk-encryption-arch-uefi.md
Last active May 10, 2024 19:16
Arch Linux Full-Disk Encryption Installation Guide [Encrypted Boot, UEFI, NVMe, Evil Maid]

Arch Linux Full-Disk Encryption Installation Guide

This guide provides instructions for an Arch Linux installation featuring full-disk encryption via LVM on LUKS and an encrypted boot partition (GRUB) for UEFI systems.

Following the main installation are further instructions to harden against Evil Maid attacks via UEFI Secure Boot custom key enrollment and self-signed kernel and bootloader.

Preface

You will find most of this information pulled from the Arch Wiki and other resources linked thereof.

Note: The system was installed on an NVMe SSD, substitute /dev/nvme0nX with /dev/sdX or your device as needed.

@yyscamper
yyscamper / jsonb_remove_keys.sql
Created February 26, 2018 09:49
PostgreSQL: Remove Multiple Keys From JSONB
CREATE OR REPLACE FUNCTION jsonb_remove_keys(
jdata JSONB,
keys TEXT[]
)
RETURNS JSONB AS $$
DECLARE
result JSONB;
len INT;
target TEXT;
@judy2k
judy2k / know_thyself.py
Last active July 5, 2022 06:35
__qualname__ implementation in Python 2
from inspect import isclass
import __builtin__
# We're going to overwrite object, so we need to squirrel away the old one:
obj = object
# Metaclass, overriding the class' __getattribute__,
# so that __qualname__ can be generated and cached on access:
class QualnameMeta(type):
@marshallpierce
marshallpierce / temporenc.md
Last active February 2, 2017 01:20
Temporenc alternate encoding

Date

temporenc v1:

100YYYYY YYYYYYYM MMMDDDDD

lifthrasiir v1:

YYYYYYYY YYYYMMMM DDDDD111

@meeuw
meeuw / injectinput.py
Last active September 27, 2021 09:40
Simple script to replace xdotool when using Gnome/Wayland for entering keystrokes using evdev. This requires root.
# MOVED TO: https://github.com/meeuw/injectinput
#!/usr/bin/python3
import evdev
import sys
upper = { '!': '1', '@': '2', '#': '3', '$': '4', '%': '5', '^': '6', '&': '7', '*': '8', '(': '9', ')': '0' }
with evdev.UInput() as ui:
escape = False
@bradfa
bradfa / backups-with-bup.md
Last active September 3, 2021 13:54
Backups with bup

Exact Steps: Doing backups with bup to an external hard disk

Initial setup and first backup:

  1. Mount hard disk to /mnt/usb (you are strongly encouraged to use luks encryption on this disk!)
  2. mkdir /mnt/usb/.bup && bup init -r /mnt/usb/.bup to create and initialize a .bup directory on the USB disk. You may need to do some sudo and chmod/chgrp action depending on how your USB disk gets mounted. You'll save the actual files from backups here later.
  3. bup init to create the core bup repo in your home directory, the index will live here
  4. bup index ~/ to index your home directory
  5. bup index /etc to index your /etc directory
  6. bup save -n ${HOSTNAME}-etc -r /mnt/usb/.bup /etc to save the backup of your /etc directory to your USB disk. This backup set will result in a branch named after ${HOSTNAME}-etc, so that if you backup other PCs to this same .bup directory on your USB disk, you'll be able to see each one in a separate branch
@gonejack
gonejack / mapper-0.74.map
Last active February 26, 2024 11:19
Colemak keymap for DOSBox, put this file to %LOCALAPPDATA%\DOSBox
hand_shutdown "key 290 mod1"
hand_capmouse "key 291 mod1"
hand_fullscr "key 13 mod2"
hand_pause "key 19 mod2"
hand_mapper "key 282 mod1"
hand_speedlock "key 293 mod2"
hand_recwave "key 287 mod1"
hand_caprawmidi "key 289 mod1 mod2"
hand_scrshot "key 286 mod1"
hand_video "key 286 mod1 mod2"
@nZac
nZac / sqlalchemy_debugger.py
Last active April 16, 2019 13:07
SQLAlchemy query to compiled SQL string
try:
import sqlparse.format as sqlformat
except ImportError:
def sqlformat(query, **kwargs):
"""Monkey patch sqlparse.format if package not installed"""
return query
def debug_query(query, engine):
"""Return a parametrized and formated sql query for debugging