Skip to content

Instantly share code, notes, and snippets.

View michael-azogu's full-sized avatar
🫥
thinking

free_one_ michael-azogu

🫥
thinking
View GitHub Profile
@michael-azogu
michael-azogu / gravatar.ml
Last active September 5, 2024 11:34
gravatar generator
open OcamlCanvas.V1
(*
todo:
- mark as used
- server endpoints
- perf opt
*)
module IntSet = Set.Make (Int)
@michael-azogu
michael-azogu / bf.ml
Last active September 1, 2024 18:38
brainfuck interpreter ocaml
type instruction =
| In | Out
| Increase | Decrease
| Move | Jump
| MoveBack | JumpBack
| Ignore
let parse =
List.map
@@ function
@michael-azogu
michael-azogu / every-vm-tutorial-you-ever-studied-is-wrong.md
Created June 13, 2024 10:40 — forked from o11c/every-vm-tutorial-you-ever-studied-is-wrong.md
Every VM tutorial you ever studied is wrong (and other compiler/interpreter-related knowledge)

Note: this was originally several Reddit posts, chained and linked. But now that Reddit is dying I've finally moved them out. Sorry about the mess.


URL: https://www.reddit.com/r/ProgrammingLanguages/comments/up206c/stack_machines_for_compilers/i8ikupw/ Summary: stack-based vs register-based in general.

There are a wide variety of machines that can be described as "stack-based" or "register-based", but not all of them are practical. And there are a lot of other decisions that affect that practicality (do variables have names or only address/indexes? fixed-width or variable-width instructions? are you interpreting the bytecode (and if so, are you using machine stack frames?) or turning it into machine code? how many registers are there, and how many are special? how do you represent multiple types of variable? how many scopes are there(various kinds of global, local, member, ...)? how much effort/complexity can you afford to put into your machine? etc.)

  • a pure stack VM can only access the top elemen
@michael-azogu
michael-azogu / .ocaml_ignore
Last active September 18, 2024 14:58
ocaml configs
.vscode/
*todo.txt
*.a
*.o
*.bc
*.cma
*.cmi
*.cmo
*.cmx
@michael-azogu
michael-azogu / _web-framework-render-fns.md
Created December 7, 2023 00:59 — forked from acutmore/_web-framework-render-fns.md
Comparing web framework render functions
@michael-azogu
michael-azogu / esm-package.md
Created October 23, 2023 16:47 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@michael-azogu
michael-azogu / rollup-optimization-research.md
Created October 17, 2023 12:11 — forked from bluwy/rollup-optimization-research.md
Rollup build optimization research

Rollup build optimization research

Rollup builds doesn't scale well in large apps. You need to increase Node's memory with --max-old-space-size=4096 to handle all the modules. This is one of Vite's highest-rated issue.

This file documents various findings and attempts to improve this issue.

How Rollup works

NOTE: I've only been reading Rollup's source code for a while, so some of these may not be accurate.