Skip to content

Instantly share code, notes, and snippets.

@indivisible
indivisible / bf.py
Created April 2, 2021 09:44
Python Brainfuck interpreter in a generator expression
#!/usr/bin/env python3
'''brainfuck interpreter in a single generator expression
im sorry'''
def bf(code):
all(
# we need to yield *something*
@indivisible
indivisible / sierpinski_eulerian_plotter.py
Created March 10, 2020 00:19
G-code generator for plotting a Sierpinski triangle without lifting the tool
#!/usr/bin/env python3
'''
Generate G-code for drawing a Sierpenski triangle, using lines,
only drawing each line once, and never lifting the tool.
This is achieved drawing along an Eulerian cycle
'''
@indivisible
indivisible / twbt 0.47.05 maybe.h
Created March 1, 2020 10:23
tentative untested twbt windows and linux patch for 0.47.04 (the linux patch for p_render_lower_levels might be broken!)
#elif defined(DF_04704)
#ifdef WIN32
#define A_LOAD_MULTI_PDIM 0x140c1f670
#define A_RENDER_MAP 0x1409d8200
#define A_RENDER_UPDOWN 0x1406f0090
static patchdef p_display = { 0x140479beb, 5 };
static patchdef p_dwarfmode_render = { 0x14042d93a, 5 };
@indivisible
indivisible / order_remembered_plugin.py
Created August 5, 2019 11:36
Shuffle plugin with (mostly) preserving previous / next order for Quod Libet
#!/usr/bin/env python3
import random
from quodlibet import _
from quodlibet.plugins.playorder import ShufflePlugin
from quodlibet.qltk import Icons
from quodlibet.util import print_d
@indivisible
indivisible / to_simple_id3v24.py
Created March 27, 2019 21:30
ID3 fixer for android
#!/usr/bin/env python3
'''Simplify MP3 ID3 tags for android compatibility
Converts tags to 2.4, utf8, and strips extended headers
'''
from eyed3.id3 import Tag, ID3_V2_4
#!/bin/sh
# if systemd is used and you need sound, login to $console prior https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747882
# if you can't stand cursor bug, start this script from console, not another X https://bugs.launchpad.net/ubuntu/+source/plasma-workspace/+bug/1684240
# for many games you need running window manager, in that case run script which runs both wm and game via this script
display=1
console=3
tmpdir=$XDG_RUNTIME_DIR/nvidia
busid=$(/usr/bin/lspci | awk '/(3D)|(VGA compatible) controller: NVIDIA/{gsub(/\./,":",$1); print $1}')
@indivisible
indivisible / twbt_patch_maker.py
Created December 10, 2017 22:17
TWBT patch maker for Linux version
#!/usr/bin/env python3
import hashlib
import xml.etree.ElementTree as ET
from itertools import islice
import r2pipe
def md5(path, block_size=2**20):
@indivisible
indivisible / backbrightness.py
Created July 3, 2017 20:24
ACPI backlight to panel gamma converter for Alienware 13 R3 OLED
#!/usr/bin/env python3
# based on:
# https://gist.github.com/joel-wright/68fc3031cbb3f7cd25db1ed2fe656e60
import os
import time
from pathlib import Path
from functools import lru_cache
$ python3 unicode_test.py
Running test on 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118]
Running with locale encoding 'UTF-8'...
Success
$ python2 unicode_test.py
Running test on 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118]
Running with locale encoding 'UTF-8'...
#!/usr/bin/env python3
from pip._vendor import packaging
from packaging.specifiers import SpecifierSet
tests_good = [
'0.99999999',
'0.999999999',
'1.0b9',
'1.0b10',