Skip to content

Instantly share code, notes, and snippets.

View mk-fg's full-sized avatar

Mike Kazantsev mk-fg

View GitHub Profile
@mk-fg
mk-fg / sqlite-test.py
Last active December 25, 2023 07:23
Simple benchmark for different SQLite python stdlib module options
#!/usr/bin/env python
import contextlib as cl, collections as cs, multiprocessing as mp
import os, sys, random, time, secrets, pathlib as pl
class TestDB:
_db, _db_schema = None, ['''
create table if not exists data (
import os, network
try: import uasyncio as asyncio
except ImportError: import asyncio
async def wifi_client(ap_base, ap_map):
def ssid_str(ssid):
try: return ssid.decode() # mpy 1.20 doesn't support errors= handling
except UnicodeError: return repr(ssid)[2:-1] # ascii + backslash-escapes
[monitor-filters]
# All filters are applied to channel names and are case-insensitive
ignore one specific "bot-commands" channel = starsector.bot-commands
skip forum threads in specific guild = glob:starsector.forum.=*
who-gives-a-shit-about-wordle (and anything ending in .wordle) = glob:*.wordle
actually, ignore threads in forum-like channels anywhere = re:^[^.]+\.(forum|discuss)\.=.*
@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
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(-)
#!/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
#!/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
// 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>
[Unit]
Conflicts=getty@tty%i.service
After=systemd-user-sessions.service
[Service]
User=gui
PAMName=login
TTYPath=/dev/tty%I
TTYReset=yes
[21:21:42]*** Welcome to the rdircd discord-irc bridge, mk-fg
[21:21:42]*** Your host is wyrm, running rdircd 1.89
[21:21:42]*** This server was created at 2019-02-09 16:13:49 UTC
[21:21:42]*** wyrm rdircd-1.89 DOQRSZaghilopswz CFILMPQSbcefgijklmnopqrstvz
[21:21:42]*** AWAYLEN=200 CASEMAPPING=ascii CHANLIMIT=#:512 CHANTYPES=#~ CHANMODES=eIbq,k,flj,CFLMPQScgimnprstz CHANNELLEN=80 ELIST=C NETWORK=rdircd NICKLEN=64 PREFIX=(ov)@+ are supported by this server
[21:21:42]*** SAFELIST STATUSMSG=@+ TOPICLEN=390 USERLEN=32 are supported by this server
[21:21:42]*** There are 1 users and 0 invisible on 5 server(s)
[21:21:42]*** 0 operator(s) online
[21:21:42]*** 191 channels formed
[21:21:42]*** I have 1 client(s) and 5 server(s)
@mk-fg
mk-fg / splash.c
Last active August 9, 2018 08:42
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <jpeglib.h>
#include "VG/openvg.h"
#include "VG/vgu.h"
#include "./src/fontinfo.h"
#include "./src/libshapes.h"
/*