Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Kazantsev mk-fg

View GitHub Profile
@mk-fg
mk-fg / zshrc
Created February 19, 2023 15:07
Doing unholy things with ZLE
View zshrc
# Make ESC-t (transpose-words) work on arguments instead of zsh-words
# Namely, process any two args before cursor, ignoring redirection in-between, if any
_zle-transpose-args() {
res=$(python3 - 3<<<"$CURSOR.$BUFFER" <<'EOF'
import re
pos, line = open(3).read().rstrip('\r\n').split('.', 1)
# open('/tmp/zle', 'w').write(repr([pos, line]))
pos, suffix = int(pos) if pos else -1, ''
View gist:c201071063ba3138ff1c414713723d62
hair_change_decision = {
picture = gfx/interface/illustrations/decisions/decision_personal_religious.dds
title = hair_change_decision
desc = hair_change_decision_desc
confirm_text = hair_change_decision_confirm
is_shown = { NOT = { dynasty = { has_variable = hair_change_decision_used } } }
effect = {
@mk-fg
mk-fg / 0002-Fix-using-mod-local-variable-as-it-will-cause-mp-des.patch
Last active September 5, 2020 15:48
Factorio SwitchButton-1_0 mod fixes 0.1.9 -> 0.1.10
View 0002-Fix-using-mod-local-variable-as-it-will-cause-mp-des.patch
From aed1fdd316d3fad21d051d0264769b2b675d01e3 Mon Sep 17 00:00:00 2001
From: Mike Kazantsev
Date: Sat, 5 Sep 2020 20:14:29 +0500
Subject: [PATCH 2/5] Fix using mod-local variable, as it will cause mp desync
for later-connecting players
---
control.lua | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
View hdmi-boot-delay
#!/usr/bin/env python3
import os, sys, re, time, signal, subprocess as sp
tvs = '/opt/vc/bin/tvservice'
def get_hdmi_res():
# state 0x120006 [DVI DMT (82) RGB full 16:9], 1920x1080 @ 60.00Hz, progressive
View slice-override.py
#!/usr/bin/env python3
import os, sys, glob, re, pathlib as pl
src = pl.Path('/etc/systemd/system')
dst = pl.Path('/run/systemd/system')
for p in map(pl.Path, glob.glob(str(src / '*.slice'))):
unit = p.read_text()
for line in unit.splitlines():
@mk-fg
mk-fg / test.c
Last active October 22, 2019 18:09
View test.c
// Compile & run with: gcc -O1 -o test -lpulse test.c && ./test
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <error.h>
#include <pulse/context.h>
#include <pulse/mainloop.h>
View gui@.service
[Unit]
Conflicts=getty@tty%i.service
After=systemd-user-sessions.service
[Service]
User=gui
PAMName=login
TTYPath=/dev/tty%I
TTYReset=yes
View pactl-list-sinks-and-sources.log
Sink #1
State: IDLE
Name: micspam_output
Description: Micspam
Driver: module-combine-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 19
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
View mail.log
Mar 04 15:13:04 zzz postfix/master[16384]: daemon started -- version 3.4.0, configuration /etc/postfix
Mar 04 15:13:04 zzz systemd[1]: Started Postfix Mail Transport Agent.
Mar 04 15:13:09 zzz postfix/qmgr[16386]: BEBB0A0516: from=<root@zzz.host.xxx.yyy>, size=747, nrcpt=1 (queue active)
Mar 04 15:13:10 zzz postfix/qmgr[16386]: AB86EA24F9: from=<root@zzz.host.xxx.yyy>, size=747, nrcpt=1 (queue active)
Mar 04 15:13:10 zzz postfix/qmgr[16386]: 7B80EA03A8: from=<root@zzz.host.xxx.yyy>, size=1343, nrcpt=1 (queue active)
Mar 04 15:13:10 zzz postfix/smtp[16389]: initializing the client-side TLS engine
Mar 04 15:13:10 zzz postfix/qmgr[16386]: 869C7A23AD: from=<root@zzz.host.xxx.yyy>, size=1343, nrcpt=1 (queue active)
Mar 04 15:13:10 zzz postfix/qmgr[16386]: C6222A1823: from=<root@zzz.host.xxx.yyy>, size=747, nrcpt=1 (queue active)
Mar 04 15:13:10 zzz postfix/smtp[16391]: initializing the client-side TLS engine
Mar 04 15:13:10 zzz postfix/smtp[16392]: initializing the client-side TLS engine
View gist:b5ee8dba35b0349ae8b518ed157b1dfb
Event: time 1550174966.710233, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e1
Event: time 1550174966.710233, type 1 (EV_KEY), code 42 (KEY_LEFTSHIFT), value 1
Event: time 1550174966.710233, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70008
Event: time 1550174966.710233, type 1 (EV_KEY), code 18 (KEY_E), value 1
Event: time 1550174966.710233, -------------- SYN_REPORT ------------
Event: time 1550174966.714253, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e1
Event: time 1550174966.714253, type 1 (EV_KEY), code 42 (KEY_LEFTSHIFT), value 0
Event: time 1550174966.714253, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70008
Event: time 1550174966.714253, type 1 (EV_KEY), code 18 (KEY_E), value 0
Event: time 1550174966.714253, -------------- SYN_REPORT ------------