Skip to content

Instantly share code, notes, and snippets.

View Chubek's full-sized avatar

Behrang Nevii Chubek

View GitHub Profile
@Chubek
Chubek / 6502-instr.tsv
Created September 11, 2025 11:11
6502 instructions, with mnemonics, opcodes, bytes, cycles
ADC N=+,Z=+,C=+,I=-,D=-,V=+, immediate, 0x69 2 2
ADC N=+,Z=+,C=+,I=-,D=-,V=+, zeropage, 0x65 2 3
ADC N=+,Z=+,C=+,I=-,D=-,V=+, zeropage,X, 0x75 2 4
ADC N=+,Z=+,C=+,I=-,D=-,V=+, absolute, 0x6D 3 4
ADC N=+,Z=+,C=+,I=-,D=-,V=+, absolute,X, 0x7D 3 4*
ADC N=+,Z=+,C=+,I=-,D=-,V=+, absolute,Y, 0x79 3 4*
ADC N=+,Z=+,C=+,I=-,D=-,V=+, (indirect,X), 0x61 2 6
ADC N=+,Z=+,C=+,I=-,D=-,V=+, (indirect),Y, 0x71 2 5*
AND N=+,Z=+,C=-,I=-,D=-,V=-, immediate, 0x29 2 2
AND N=+,Z=+,C=-,I=-,D=-,V=-, zeropage, 0x25 2 3
@Chubek
Chubek / 6502-instrs.tsv
Last active September 14, 2025 16:14
6502 Instructions Dataset (with numeric opcodes and address modes)
ADC N=+,Z=+,C=+,I=-,D=-,V=+ immediate 0x69 2 2
ADC N=+,Z=+,C=+,I=-,D=-,V=+ zeropage 0x65 2 3
ADC N=+,Z=+,C=+,I=-,D=-,V=+ zeropageX 0x75 2 4
ADC N=+,Z=+,C=+,I=-,D=-,V=+ absolute 0x6D 3 4
ADC N=+,Z=+,C=+,I=-,D=-,V=+ absoluteX 0x7D 3 4*
ADC N=+,Z=+,C=+,I=-,D=-,V=+ absoluteY 0x79 3 4*
ADC N=+,Z=+,C=+,I=-,D=-,V=+ indirectX 0x61 2 6
ADC N=+,Z=+,C=+,I=-,D=-,V=+ indirectY 0x71 2 5*
AND N=+,Z=+,C=-,I=-,D=-,V=- immediate 0x29 2 2
AND N=+,Z=+,C=-,I=-,D=-,V=- zeropage 0x25 2 3
@Chubek
Chubek / README.md
Created September 3, 2025 03:03
Fish function for getting the value of IRR against USD

Get-IRR2USD Fish Function

Below is a small, tiny Fish shell function that, when ran, notifies you of the price of IRR against USD. For example:

$ get-irr2usd
> USD <-> IRR XCHG Price: 1036862IRR

It does not have any parameters, but it takes one extra step, and saves the result of your query into a file specified by the GET_IRR2USD_LOG_FILE environment variable. You can set this variable in $XDG_CONFIG_HOME/fish/config.fish. On most distributions, this is equivalent to ‍÷/.config/fish/config.fish.

@Chubek
Chubek / demo.tex
Created September 1, 2025 21:45
LaTeX demo
\documentclass[12pt,a4paper]{article}
% --- Packages for General Utilities ---
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{lipsum} % filler text
\usepackage{microtype} % better typography
% --- Page and Graphics ---
#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <uchar.h>
#define FNV_32_PRIME 0x1000193U
#define FNV_32_OFFSET_BASIS 0x811c9dc5U
@Chubek
Chubek / c-machine.c
Created August 24, 2025 17:04
Seidl&Wilhelm Imperative VM (chapter 2, C-Machine)
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define OP_Add 1
#define OP_And 2
#define OP_Alloc 3
@Chubek
Chubek / symtbl.c
Last active August 18, 2025 20:52
Small symbol table in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "object.h"
#include "symtbl.h"
symtbl_t *
symtbl_new (size_t max_buckets)
@Chubek
Chubek / rob-pike-lexer.go
Created August 10, 2025 21:30
Rob Pike-style lexer in Golang
package lexer
import (
"fmt"
"patina-lang/internal/token"
"strings"
"unicode/utf8"
)
const EOF rune = -1
@Chubek
Chubek / vim-helpfile.ebnf
Created August 2, 2025 21:37
Vim/Neovim helpfile grammar
(* Core Structure *)
HelpFile = FirstLine, { Section | FreeContent }, [ Modeline ] ;
FirstLine = TagDef, Tab, Description, Newline ;
Section = Heading, SeparatorLine, { Block } ;
FreeContent = { Block } ;
(* Headings and Separators *)
Heading = TextLine ;
SeparatorLine = "=", "=", "=", { "=" }, Newline ; (* Min 3 '=' *)
ColumnHeading = Text, " ~", Newline ;
@Chubek
Chubek / skinna_hash32.c
Last active July 23, 2025 22:01
Skienna hash
#define PHI 0x585f14dULL
static inline uint32_t
_skiena_hash32 (const uint8_t *msg, size_t msg_len)
{
static uint16_t rand_map[UCHAR_MAX] = {
0x144, 0x1ab, 0x13c, 0x028, 0x1c3, 0x107, 0x193, 0x174, 0x00c, 0x160,
0x142, 0x0fe, 0x01f, 0x1b0, 0x198, 0x160, 0x10f, 0x185, 0x015, 0x051,
0x057, 0x138, 0x17e, 0x199, 0x1f5, 0x01e, 0x1f2, 0x01f, 0x174, 0x0b7,
0x085, 0x0a5, 0x200, 0x14d, 0x188, 0x168, 0x1e4, 0x1ef, 0x15c, 0x14e,