Skip to content

Instantly share code, notes, and snippets.

View Chubek's full-sized avatar

Behrang Nevii Chubek

View GitHub Profile
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
@Chubek
Chubek / GourmetParsec.ml
Created October 12, 2024 11:40
GourmetParsec.ml: OCaml Parser Combinator
module ParseFuncs = struct
type 'a t = string -> ('a * string) option
let success (p: 'a t) : 'a t =
fun input ->
match p input with
| Some (result, rest) as x -> x
| None -> None
let failure (_: 'a t) : 'a t =
@Chubek
Chubek / README.md
Last active October 3, 2024 01:03
Simple TTS Script based on clipboard

The file speakup.py contains a simple script to do TTS on Linux.

The way you use it is:

1- Install https://github.com/myshell-ai/MeloTTS and pip3 install pyperclip.

2- Install sudo apt-get install xbindkeys

3- Place speakup.py in /etc/speakup.py

@Chubek
Chubek / README.md
Last active September 24, 2024 08:36
SimpleCNF; a Configuration Management package for LaTeX

The file simplecnf.sty contains a very simple 'Configuration Management' facility to use with LaTeX.

It accepts INI-like files, either as files:

foo = bar
sipyek = nod
@Chubek
Chubek / README.md
Last active September 24, 2024 08:32
SimpleTRS: A LaTeX Package for typesetting Term-rewriting systems!

I am writing a literate program (with NoWEB), a toolset for Lua that happens to include a Partial evaluator, a Meta-tracer, a pretty-printer etc.

In the appendix, I provide extra information like Lua's BNF grammar (using SimpleBNF) and the Term-rewriting rules for Partial evaluation.

I did not find a LaTex package intended for typesetting TRS, so (with some help from GPT), I created simpletrs.sty (below), which povides the simpletrs package. It's a package for typesetting Term-rewriting rules.

It's a quite simple package. Providse 4 commands:

1- \trule for typesetting normal TRS rules;

@Chubek
Chubek / CurryZoo.lua
Created September 8, 2024 22:53
The Lua Combinatory Logic Zoo!
#!/usr/bin/env lua
function I(x)
return x
end
function K(x, y)
return x
end
@Chubek
Chubek / README.md
Created August 21, 2024 13:50
Ramkal, a parser for ISO Pascal (in D)

ramkal.d contains a so-and-so ready parser for the ISO variant of the Pascal language. It was mainly an experiment. I am done with it.

You can look at the source for influence, and ideas.

Note: Several additional constructs have been defined.

@Chubek
Chubek / README.md
Created July 15, 2024 12:22
The 'map' function is the same as Kleene star (regex *)!

The map function and Kleene Star (regex *) are the same! (homomorphic)

In functional languages, and most modern imperative languages which implement functional features, we often have a map function. In λ-> (simply-typed λ-calc) we could describe the type of this function as:

Γ ⊢ λfλmα.m(α) : (A -> B) -> [A] -> Unit

Let me explain what this notation means.