Skip to content

Instantly share code, notes, and snippets.

View AugmentedFifth's full-sized avatar
🍎
apfelschusss

Zachary Comito AugmentedFifth

🍎
apfelschusss
View GitHub Profile
@AugmentedFifth
AugmentedFifth / CircularBuffer.js
Created July 18, 2017 05:00
Efficient, pure Javascript circular buffer implementation supporting both Arrays and TypedArrays that presents interfaces for cons-style, LIFO, FIFO, and ordinary indexing.
/**
* Creates a new `CircularBuffer` with the specified `capacity`,
* which must strictly be a positive integer.
*
* We here use the term "zero element", which refers to exactly `null` if the
* `CircularBuffer` is backed by an `Array`, and refers to exactly `0` if it is
* backed by a `TypedArray`. Note that using this constructor will always yield
* a `CircularBuffer` backed by an `Array`. Use the
* `CircularBuffer.fromArray()` function any time a `TypedArray` backing is
* required.
@AugmentedFifth
AugmentedFifth / main.rs
Created July 14, 2017 22:34
Compiled to WebAssembly and calling into directly from JavaScript
extern crate libc;
#[macro_use]
extern crate lazy_static;
use std::sync::Mutex;
use std::vec::Vec;
lazy_static! {
static ref BUFFER: Mutex<Vec<i32>> = Mutex::new(Vec::with_capacity(8));
<!DOCTYPE html>
<html lang="en">
<head>
<title>Linux-compatible multiplayer games that don&#39;t suck</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<!DOCTYPE html>
<html lang="en">
<head>
<title>Linux-compatible multiplayer games that don&#39;t suck</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
function Trie(valueCons, hasValue=false) {
"use strict";
const constructorFailure = new TypeError(
"Tries must be initialized with a valid constructor " +
"of an iterable type as the first argument."
);
if (typeof valueCons !== "function") {
throw constructorFailure;
@AugmentedFifth
AugmentedFifth / hack-chat-emojis.js
Last active May 6, 2017 03:19
Causes ASCII emoji shorthand of the form 🤷 to be re-rendered as an associated emoji character(s) in hack.chat.
// ==UserScript==
// @name hack.chat emoji support
// @namespace A4
// @version 0.1.0
// @description Causes ASCII emoji shorthand of the form :shrug: to be
// rerendered as an associated emoji character(s)
// @author A4
// @match https://hack.chat/?*
// @grant GM_addStyle
// ==/UserScript==