Skip to content

Instantly share code, notes, and snippets.

View monomere's full-sized avatar
☺️

monomere monomere

☺️
  • Europe
View GitHub Profile
@monomere
monomere / bitcode.h
Created January 30, 2025 23:32
speedrun vm (and compiled language)
// Copyright 2025 monomere
// MIT License
#ifndef SRVM_BITCODE_H_
#define SRVM_BITCODE_H_
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
enum srvm_instr_op : uint8_t {
@monomere
monomere / examples.om
Created October 28, 2024 20:32
abomination
# Some example programs in Om to showcase just how bad it is to program in.
# These are from my CS course.
$Task2 = {
@_ = $_;
/Cone = [
$h = @_/input-float (@_/string "height");
$r = @_/input-float (@_/string "little radius");
$R = @_/input-float (@_/string "big radius");
M/if ($h /less-than-or-equal-to 0/f) { @_ = @_; @h=$h;@r=$r;@R=$R; /do = [
@monomere
monomere / qlock.c
Created July 21, 2024 14:14
quine clock in c. CC-BY-3.0
int f[10]={56,0,11,48,56,51,40,20,1972},x,y,j,b,d,w,k,sleep(
int),printf(const char*,...);long t,time(long*);char*s,*v,*g
,*ctime(long*);void p(int c){printf("\e[%sm%c",x<32&&y<5&&((
x/4%3!=2&&x%4<3&&(j=v[x/4],d=f[j],d=0x7bff-16*j-2*(!d?d:d-64
-j/6*3072+(16<<(1<<(((j+3)/4*3+1)/2)))),b=(d>>((4-y)*3+2-x%4
))&1))||y%2!=0&&!((x+3)%12))?"31;7":"",c);x-=c==10?++y,x:-1;
}int main(){s="int f[10]={56,0,11,48,56,51,40,20,1972},x,y,"
"j,b,d,w,k,sleep(\nint),printf(const char*,...);long t,time"
"(long*);char*s,*v,*g\n,*ctime(long*);void p(int c){printf("
"\"\\e[%sm%c\",x<32&&y<5&&((\nx/4%3!=2&&x%4<3&&(j=v[x/4],d="
@monomere
monomere / digits1.c
Created July 21, 2024 00:27
prints ascii-drawing digits 0-9.
// CC-BY-3 // monomere // A[1] = '█' //
#include <stdio.h>
int F[]={56,0,11,48,56,51,40,20,1972,0}
,x,y,i,j,b,d,D[6];char*A=" #";void p(){
d=0x7bff-16*j-2*(!d?d:d-64-j/6*3072+(16
<<(1<<(((j+3)/4*3+1)/2))));for(i=5;i-->
0;){b=d>>(i*3)&7;printf("%c%c%c\n",A[b/
4],A[b/2%2],A[b&1]);}putchar('\n');}int
main(){for(j=10;d=F[j-1],j-->0;)p();}//
@monomere
monomere / lc.js
Last active June 4, 2024 21:23
polymorphic hindley milner in 69 (96 incl. parser) (110 incl. example) lines of cursed functional js. CC-BY-NC.
/** by monomere, under CC-BY-NC. last updated 4th of july, 2024. */
const hindleymilner = () => ((
nextId = 1,
Err = e => (_, b = x => Err(x)) => b(e),
Ok = x => (a, _ = x => Err(x)) => a(x),
K = v => _ => v,
strty = ([kind, ...data], p = false) => ((P = x => p ? `(${x})` : x) => ({
'fun': (lhs, rhs) => P(`${strty(lhs, true)} → ${strty(rhs)}`),
'meta': ([[s, t]]) => s ? strty(t) : `?${t}`,
})[kind]?.(...data) ?? `${kind[0].toUpperCase() + kind.slice(1)}`)(),
@monomere
monomere / lc.py
Last active May 10, 2024 14:11
hindley-milner (algo w) with limited adts and mutual recursion in python. (wip) [v0.2]
# by monomere
# Apache License 2.0
# the code is horrible and undocumented,
# might change that later :P
# requires python >=3.12
# requires the parsita python package (for parsing)
# you can remove the parser code and play around with the ast directly tho
@monomere
monomere / qqc.py
Last active September 13, 2024 07:22
Tiny compiler written in python that generates text LLVM IR.
# License: MIT
# Author: monomere
# Changelog:
# Note: With every update, the doc comment is almost always updated
# to reflect new additions/improvements to the language.
# Update 7.1 - 2024/09/13:
# - Fix variadic arguments not being passed.
# Update 7 - 2024/01/27:
# - Add changelog note.
@monomere
monomere / setup-imgui.py
Last active August 1, 2023 06:53
dear imgui setup script :)
#!/usr/bin/env python3
# Original Author: monomere
# This is Public Domain, but would be cool if you still credit me :)
import os, inquirer, urllib.request, typing, json
IMGUI_REPO = 'ocornut/imgui'
T = typing.TypeVar('T')
TupleTagCommit = tuple[str, str]