Skip to content

Instantly share code, notes, and snippets.

View Chubek's full-sized avatar

Behrang Nevii Chubek

View GitHub Profile
@Chubek
Chubek / README.md
Created July 7, 2025 03:51
A small virtual keyboard driver for Linux (LKM)

clemore_virtdev.c is the Linux virtual keyboard driver for my key remapper, Clemore.

After compiling it with this Makefile:

obj-m += clemore_virtdev.o

all:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
@Chubek
Chubek / README.md
Created July 6, 2025 06:13
Fish function to remove ANSI escape sequences

I made this function to be able to render manpages with bat -lman --pager=most, but compile it with GROFF instead of mandoc(1).

It's very easy to prepare mandoc(1)-compiled manpages with bat(1). All you have to do is to filter it through col -xb.

But GROFF uses ESC[..;word ESC[... sequences (aka ANSI) so it's a bit hard.

My Fish function deansify takes a file either via STDIN or --file/-f and da-ANSI-fies it tou STDOUT.

Pretty simple. Now you can do zcat (man -w <manpage>) | groff -man -Tascii | deansify | bat -lman --pager=most (I highly recommend using most(1) as your default pager!).

@Chubek
Chubek / README.md
Last active July 12, 2025 07:56
Provisio WIP

Thanks to everyone who's helping me!

Progress:

  • Added regex parse function.

This project is [currently] called Provisio. It's a table-driven LL(1) parser generator, targeting C, written in Perl. It also a built-in lexer generator. That's what I'm focusing on first.

I'm burned out a lil bit because I've been working on, non-stop, for several weeks. The DFA/NFA facilities have been fully written. There's even a DFA minimizer!

I don't wanna use Thompson Construction for parsing the regex. It's so 1969! The syntax of its regex is mostly-compliant with ERE. It lacks the collation classes (like [[=ll=]] but it has character classes like [[:alpha:]]. It also has trails foo/bar and flags.

@Chubek
Chubek / mynerdfonts.md
Created June 28, 2025 13:49
My Nerdfonts, and a bit of fora

Hey. I have three aliases in Fish for listing Nerd Fonts, the list is the result of lsnedfonts-nofilter. The aliases are:

# I realize this ain't 'good' by any means
        alias lsnerdfonts-nofilter="fc-list | grep NerdFont | cut -d'/' -f6 | cut -d':' -f1 | cu
t -d'-' -f1"
        alias lsnerdfonts-all="fc-list  | grep NerdFont | sed -E 's/NerdFont(Mono|Propo)//' | un
iq | cut -d'/' -f6 | cut -d':' -f1 | cut -d'-' -f1"
        alias lsnerdfonts-propo="fc-list  | grep NerdFontPropo | sed -E 's/NerdFontPropo//' | un
iq | cut -d'/' -f6 | cut -d':' -f1 | cut -d'-' -f1"
def lcs_diff(seq1, seq2):
m, n = len(seq1), len(seq2)
dp = [[0] * (n + 1) for _ in range(m + 1)]
# Build the DP table
for i in range(1, m + 1):
for j in range(1, n + 1):
if seq1[i - 1] == seq2[j - 1]:
dp[i][j] = dp[i - 1][j - 1] + 1
else:
@Chubek
Chubek / chubak.hwinfo
Created January 30, 2025 09:22
My hwinfo
============ start debug info ============
libhd version 21.72u (x86-64) [7688]
using /var/lib/hardware
kernel version is 6.9
----- /proc/cmdline -----
initrd=\EFI\Pop_OS-5f791d9b-2fe4-4f57-b3ca-32fba6b2c192\initrd.img root=UUID=5f791d9b-2fe4-4f57-b3ca-32fba6b2c192 ro quiet loglevel=0 systemd.show_status=false splash
----- /proc/cmdline end -----
debug = 0xff7ffff7
probe = 0x15938fcdaa17fcf9fffe (+memory +pci +isapnp +net +floppy +misc +misc.serial +misc.par +misc.floppy +serial +cpu +bios +monitor +mouse +scsi +usb -usb.mods +modem +modem.usb +parallel +parallel.lp +parallel.zip -isa -isa.isdn +isdn +kbd +prom +sbus +int +braille +braille.alva +braille.fhp +braille.ht -ignx11 +sys -bios.vbe -isapnp.old -isapnp.new -isapnp.mod +braille.baum -manual +fb +pppoe -scan +pcmcia +fork -parallel.imm +s390 +cpuemu -sysfs -s390disks +udev +block +block.cdrom +block.part +edd +edd.mod -bios.ddc -bios.fb -bios.mode +input +block.mods +bios.vesa -cpuemu.debug -scsi.noserial +wlan -bios.crc -hal +bios.vram +bios.acpi -b
@Chubek
Chubek / rdsoseport.txt
Created December 28, 2024 20:40
RDSOSReport
+ cat /lib/dracut/dracut-105
dracut-105
+ echo /proc/cmdline
/proc/cmdline
+ sed -e 's/\(ftp:\/\/.*\):.*@/\1:*******@/g;s/\(cifs:\/\/.*\):.*@/\1:*******@/g;s/cifspass=[^ ]*/cifspass=*******/g;s/iscsi:.*@/iscsi:******@/g;s/rd.iscsi.password=[^ ]*/rd.iscsi.password=******/g;s/rd.iscsi.in.password=[^ ]*/rd.iscsi.in.password=******/g' /proc/cmdline
initrd=\cb392f924a85432bb0854cb5f0ad20d7\6.12.6-arch1-1\initrd nvme_load=YES nowatchdog rw root=UUID=52445911-a89c-4fef-8995-c265e0d75f43 resume=UUID=3e53de3a-5a27-46c0-a4c5-e222bd94cf15 rw root=UUID=52445911-a89c-4fef-8995-c265e0d75f43 resume=UUID=3e53de3a-5a27-46c0-a4c5-e222bd94cf15 systemd.machine_id=cb392f924a85432bb0854cb5f0ad20d7
+ '[' -f /etc/cmdline ']'
+ for _i in /etc/cmdline.d/*.conf
+ '[' -f '/etc/cmdline.d/*.conf' ']'
+ break
@Chubek
Chubek / memory.c
Created December 7, 2024 22:10
Arena stack
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "memory.h"
#define ALIGNMENT 8
#define DEFAULT_REGION_SIZE 8096
type genotype =
{ dominant : char
; recessive : char
}
and punnette =
{ lower_left : char * char
; upper_left : char * char
; lower_right : char * char
; upper_right : char * char
@Chubek
Chubek / LyVM.c
Last active November 9, 2024 05:42
LyVM: the Tiny VM
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>
#define MAX_CODE_SIZE 4096