Skip to content

Instantly share code, notes, and snippets.

View gliese1337's full-sized avatar

Logan Kearsley gliese1337

View GitHub Profile
@gliese1337
gliese1337 / TM.js
Last active January 5, 2016 09:08
Basic Turing Machine simulator in JS
function TM(tape, alphabet, states, start){
var state, transition, symbol,
counter = 0, stateId = start, pos = 0;
while(true){
symbol = tape[pos];
if(typeof symbol === 'undefined'){
symbol = alphabet[0];
tape[pos] = symbol;
}
state = states[stateId];
@gliese1337
gliese1337 / Multimethod.js
Last active January 12, 2018 02:51
A JavaScript multimethod library.
const clauses = new Symbol();
function Multimethod(){
const self = !!new.target ? this : Object.create(Multimethod.prototype);
self[clauses] = [];
return new Proxy(self,{
apply: function(target, thisArg, args){
let curImpl = () => throw new Error("No Matching Implementation");
let curLen = -1;
for(const { thisPredicate, predicates, impl } of self[clauses]){
import beamcoder from 'beamcoder';
import { Readable, Writable } from 'stream';
async function * transform(demuxer: beamcoder.Demuxer) {
const vdec = beamcoder.decoder({ name: 'h264' });
const adec = beamcoder.decoder({ name: 'aac' });
const venc = beamcoder.encoder({ name: 'h264' });
const aenc = beamcoder.encoder({ name: 'aac' });