Skip to content

Instantly share code, notes, and snippets.

@alganet
alganet / c89cc.sh
Last active August 20, 2026 14:00
c89cc.sh - standalone C89/ELF64 compiler in pure portable shell
#!/bin/sh
# ISC License
# Copyright (c) 2026 Alexandre Gomes Gaigalas <alganet@gmail.com>
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  • Shall i implement it?
  • No ...
@andrejbauer
andrejbauer / wlem.agda
Last active June 19, 2023 04:40
A formal proof that weak excluded middle holds from the familiar facts about real numbers.
{-
Weak excluded middle states that for every propostiion P, either ¬¬P or ¬P holds.
We give a proof of weak excluded middle, relying just on basic facts about real numbers,
which we carefully state, in order to make the dependence on them transparent.
Some people might doubt the formalization. To convince yourself that there is no cheating, you should:
* Carefully read the facts listed in the RealFacts below to see that these are all
just familiar facts about the real numbers.
-- 1. Prove X⁷≡X in the polynomial quotient semiring ℕ[X]/(X≡X²+1)
-- 2. Define a map toType : ℕ[X]/(X≡X²+1) → Type,
-- using the semiring structure of Type and the fact that
-- the equation T≡T²+1 holds for the type of binary trees T.
-- 3. We deduce T⁷ ≡ T, by T⁷ ≡ toType X⁷ ≡ toType X ≡ T
-- 4. ???
-- 5. Profit
{-# OPTIONS --cubical #-}
module S where
@vmxdev
vmxdev / hello.asm
Last active June 23, 2022 15:49
8086 16-bit helloworld.com
; nasm hello.asm -fbin -o hello.com
; to run in DosBox: dosbox hello.com
org 100h
section .text
start:
mov ax, 13h
int 10h

*excerpt from slab6.txt in the SLAB6 download found at http://advsys.net/ken/download.htm#slab6 *

VOX file format

Both SLABSPRI&SLAB6(D) support a simpler, uncompressed voxel format using the VOX file extension. Here's some C pseudocode that describes the format:

long xsiz, ysiz, zsiz;          //Variable declarations
char voxel[xsiz][ysiz][zsiz];
@vmxdev
vmxdev / fact.c
Last active February 3, 2021 05:48
Calculate factorials using gmp
/*
* $ cc -O3 -Wall -pedantic -Wextra fact.c -lgmp
*/
#include <stdio.h>
#include <gmp.h>
static void
factorial(long n, mpz_t r)
{
@vmxdev
vmxdev / fizzbuzz.s
Last active October 14, 2020 10:24
fizzbuzz in GNU assembly
/*
* To compile and link:
*
* $ gcc -Wall -pedantic -Wextra fizzbuzz.s -no-pie -o fizzbuzz
*/
.data
/* Strings to print */
fizz: .asciz "fizz\n"
@dim13
dim13 / try.c
Created August 9, 2019 12:28
try/catch in plain c
#include <err.h>
#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
static sigjmp_buf exception;
#define try if (!sigsetjmp(exception, 1))
#define catch else
#define throw siglongjmp(exception, 1)
@kumbasar
kumbasar / imagetest.sh
Created April 25, 2019 19:29
How To Create a NTFS Image File in Linux
#!/bin/bash
set -x
image="test.img"
label="test"
mntdir=`mktemp -d`
sudo dd status=progress if=/dev/zero of=$image bs=6M count=1000 && sync
echo 'type=7' | sudo sfdisk $image