Skip to content

Instantly share code, notes, and snippets.

@aaronryank
aaronryank / rk.pl
Last active February 28, 2018 01:46
INCOMPLETE RK TO C COMPILER - usage: perl rk.pl < input.rk > output.c
use Text::ParseWords;
print "typedef void *UNTYPED;\n";
print "#define ARGS UNTYPED args[]\n";
print "#define INT __uint128_t\n";
print "#define STR char *\n\n";
my @variables;
my $variable_count = 0;
my @code;
@aaronryank
aaronryank / c-lambda.bash
Last active May 29, 2024 23:09
Convert a C function to a lambda via executable strings.
#!/usr/bin/env bash
read -p "Function return type: " val
if [ "$1" != "mini" ]; then
read -p "Function name: " name
fi
read -p "Function argument list: " list
echo "$val $name($list) {" >f.c
echo "Enter code:"
@aaronryank
aaronryank / ppcg-answers-integers.txt
Last active January 15, 2018 21:59
Frequency of languages in my PPCG answers
1 ;#
1 ABAP
1 ACL2
1 A Pear Tree
1 ASM
1 Awk
1 Babel
1 BaCon
1 Bob
1 Ceylon
@aaronryank
aaronryank / oeis.bash
Last active December 21, 2017 01:47
Downloads all OEIS sequence lists and formats them into C arrays
#!/usr/bin/env bash
# Downloads all OEIS sequence lists and formats them into C arrays
for i in `seq 1 296700`; do
printf -v s "A%.6d" $i
echo $s >/dev/stderr
echo -n "long long int $s[] = {"
wget -qO- https://oeis.org/$s/list | tr -d '\n' | sed 's/^.*<pre>/<pre>/' | cut -c 7- | cut -f1 -d"]" | tr -d '\n'
echo "};"
done
@aaronryank
aaronryank / quine.exe
Last active December 7, 2017 04:08
Windows Executable error quine
The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need an x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.
@aaronryank
aaronryank / setup.bash
Last active December 8, 2017 03:16
Set up a new PC/workstation: wget -qO- https://xf-technologies.github.io/setup | xargs wget
#!/usr/bin/env bash
# test internet connection
wget -q --spider http://google.com
if [ ! $? -eq 0 ]; then
echo "No internet connection, exiting..."
exit $?
fi
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <limits.h>
// Sort it like a human!
// O(2n)
void humansort(int **list, int size)
{

Subtract and branch if less than or equal to zero (SUBLEQ)

Subtract the contents of address a from the contents of address b, store the result in address b, and if the result is non-positive, transfer control to address c. If the result is positive, execution continues to the next instruction in the code. So subleq a, b, c would be equivalent to:

mem[b] -= mem[a];
if (mem[b] <= 0)
    goto c;

A variant of subleq is subneg, which is equivalent to subleq except instead of mem[b] <= 0 it performs mem[b] < 0.

@aaronryank
aaronryank / simple-tc-languages.md
Last active October 3, 2017 04:19
Turing-complete esoteric languages that are easily to implement -- for https://gist.github.com/aaronryank/5eff98fe13c4d05c091982daa56d0c23