Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ConorOBrien-Foxx's full-sized avatar

Conor O'Brien ConorOBrien-Foxx

View GitHub Profile
@ConorOBrien-Foxx
ConorOBrien-Foxx / -3.md
Last active February 3, 2018 18:58
-3 language

-3

Here's the gist.

Memory

Memory is a map of tapes, where the keys are strings and values are arbitrary-sized integers.

Additionally, there is a set of labels, where the program can jump to.

There is a stack, which contains the operands, which are strings.

@ConorOBrien-Foxx
ConorOBrien-Foxx / matrix_readable.rb
Last active January 20, 2018 22:30
Readable matrix printing
require 'matrix'
module ReadableArrays
def readable(factor: 1, method: :rjust)
repr = to_a.map { |row|
row.map(&:inspect)
}
column_widths = repr.transpose.map { |col|
col.map(&:size).max + factor
@ConorOBrien-Foxx
ConorOBrien-Foxx / koch.ps
Created December 12, 2017 04:50
Koch Snowflake in PostScript
% yes, I really did implement a turtle for this.
%-- turtle functions --%
% CONSTANTS
/T-Angle 0 def
/T-Drawing true def
/T-coorfromangle {
dup T-Angle cos mul exch T-Angle sin mul
} def
@ConorOBrien-Foxx
ConorOBrien-Foxx / 4.rb
Last active November 28, 2017 17:29
4 compiler
$ops = %w(add subtract multiply divide exit print set input loop end)
def getchar
res = STDIN.getc.ord rescue 0
end
class Numeric
def call prog
return unless self == 4
unless prog = prog.delete(' ')[/\A3\.(\d*)4\z/, 1]
import java.util.Scanner;
public class Main {
public static String convert(String name) {
String head = "" + name.charAt(0);
head = head.toUpperCase() + name.substring(1).toLowerCase();
return head;
}
public static void swap(String[] array, int i, int j) {
0e00e-0e00e----|00e00e--|00e00e00e----|00e00e00e----|--e|--e|--e@0e0e00e--00e00e----|00e00e00e--|00e00e--|--e--|--e|000e-0e00e--00e00e-----|--e-@0e00e-0e00e----|00e00e00e----|00e00e00e----|00e00e00e----|--e|--e|--e:@@0e00e00e----|00e00e00e----|--e|00e00e--00e00e----|00e00e00e----|--e|--e00e-0e-0e--@0e00e-0e00e----|00e00e00e----|00e00e00e----|--e00e-0e--|--e@0e00e-0e00e----|00e00e--|00e00e--00e00e----|--e|--e:@00e-0e-0e-|00e0e00e00e--|00e00e--|--e--|00e00e--00e00e--|00e00e--|--e--|--e-|--e@0e00e00e----|00e00e00e----|--e|00e00e--00e00e----|00e00e00e----|--e|--e00e-0e-0e--@0e00e--|00e00e00e----|--e|00e00e--00e00e----|00e00e00e--|00e00e--|--e--|--e0e-|--e@0e00e-0e00e----|00e00e00e----|00e00e00e----|00e00e00e----|--e|--e|--e@0e00e-0e00e----|00e00e00e--00e00e------|00e00e00e--00e00e------|--e|--e@00e--@
#ifndef INCLUDE_MILLISECONDS
#define INCLUDE_MILLISECONDS
#include <time.h>
#ifdef __WIN32
#include <windows.h>
#define M_OS_WINDOWS
#else
#include <sys/time.h>
#define M_OS_SANE
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
typedef struct operator {
char* name;
int prec;
} operator;
/**
* math.js
* https://github.com/josdejong/mathjs
*
* Math.js is an extensive math library for JavaScript and Node.js,
* It features real and complex numbers, units, matrices, a large set of
* mathematical functions, and a flexible expression parser.
*
* @version 2.5.0
* @date 2015-12-05
@ConorOBrien-Foxx
ConorOBrien-Foxx / bf.rb
Last active July 30, 2017 16:43
Ruby BF compiler
preamble = <<'EOF'
#include <stdint.h>
#include <stdio.h>
int main(){
#define S 65536
uint8_t t[S] = {0};
uint8_t m[S] = {0};
uint16_t p = 0, f = 0, z = 0;
int i, q = 0, d = 0, g = 0;