Skip to content

Instantly share code, notes, and snippets.

View Chubek's full-sized avatar

Behrang Nevii Chubek

View GitHub Profile
@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 / README.md
Last active January 19, 2025 22:05
EBNF Grammar for C

c.ebnf contains grammar ofr C99. Note that this is ANSI C, not ISO C, so there are some omissions. The reason I wrote this is, I am currently writing a C compiler, with my own backend (and hopefully, frontend) in OCaml. And I needed to collect the grammar in one place.

How to Read EBNF Grammars?

Reading EBNF grammars is pretty simple:

  • Enclosed within two ?s is a global capture, it does not mean optional. It means 'I am writing a free-style sentence'.
  • Enclosed within { and } means : repeat at least zero times
  • Enclosed within [ and ] means : this is optional
  • Enclosed within ( and ) means : this is a group
@Chubek
Chubek / ECMAScript.ebnf
Last active January 3, 2025 08:08
EBNF Grammar for JavaScript (aka ECMAScript)
# Syntactic Grammar for ECMAScript
ecma-script-module ::= { top-level | ignorable }
top-level ::= statement
| function-declaration
| class-declaration
function-declaration ::= [ "async" ] "function" identifier function-params-postfix compound-statement
@Chubek
Chubek / README.md
Created March 29, 2024 14:29
This is, hands-down, the best way to convert PDFs to EPUB (or any other format)

This document describes several shell pipelines for converting PDF files to any format.

I'm not sure if it's true for all people, but my e-reader sucks at displaying PDF --- which is, in all reality, a giant executable file (we'll discuss this soon). Also, there's dozens of other reasons one may wish to convert a PDF to a better 'text format'. Let's say, you wanna put it up on your website, feed it to a mathematical optimization model, feed it to an script, etc.

Before you read this document, yes, I know there is a utility, nay, dozens that converty PDFs directly to text (like pdftotext). I ALSO know that. there are millions, if not BILLIONS of crappy web services that serve you a malware on the platter alongisde converting the files. So let's not talk about them! It's about "owning" your software, read this!

What are PDF Files?

This is not meant to be a description or history of PDF files, you can consult Sahih Al-Bukhari f

@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 / README.md
Last active December 13, 2024 02:46
EBNF Grammar for AWK

Note: if you wish to understand these notations, please read this: https://gist.github.com/Chubek/52884d1fa766fa16ae8d8f226ba105ad

So, again, why did I write the EBNF grammar for AWK?

Basically, I have two ongoing projects where AWK is involved. Firs is Squawk, and implementation of AWK and second is AWK2c, which obviously translates AWK to C.

Plus, I am thinking of making a Github page called 'The Internet Grammar Database' where I would post EBNF, Yacc, PEG, Lex, definitions of languages. However, I don't have much experience in web development, so if you can help me, let me know (chubakbidpaa [at] riseup [dot] net).

So anyways, awk.ebnf contains the EBNF grammar for AWK. Some considerations:

@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
@Chubek
Chubek / Guillmet.ml
Created October 27, 2024 05:40
The Guillmet Scheme
module Stream = struct
type 'a t = 'a Seq.t ref
exception Empty_stream
let empty = ref Seq.empty
let peek stm =
match !stm () with
| Seq.Nil -> raise Empty_stream