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 / 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==
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;
<!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">
@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));
@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 / Rect.contains.js
Created July 19, 2017 22:31
horrible. dont do this
/**
* Decides if the given rectangle contains the given point within it.
*
* The rectangle is specified by the x-value of the upper-left corner, then the
* y-value, then the width, and then the height, in that order. After that, the
* point whose containment or non-containment is to be determined is specified.
* These values can each be specified either as two separate `number`s or as a
* single `V2`, mixing and matching arbitrarily.
*
* @return {boolean}
/**
* Creates a new `Rect` with the specified top-left corner, width, and height.
* These quantities can be specified in three different ways:
*
* - Four arguments, all `numbers`, specifying the x and y values of the
* top-left corner and width/height, respectively.
* - Two arguments, both `V2`s.
* - One argument, a single `Rect` to be cloned.
*
* @param {number | V2 | Rect} arg1
-- | what
applyInputs :: PlayerState -> PlayerState
applyInputs ps =
foldl' (\ps' inputGroup ->
-- Calculate accelerations for this frame based on input log.
let (# v, pressed, _, t_ #) = foldl' (\(# v, pressed, t0', t_ #) inp ->
let t1 = inp^.timeStamp
down = inp^.isDown
in (# case t0' of
Just t0 -> let thisDt = t1 - t0 in
@AugmentedFifth
AugmentedFifth / select-music-1970-to-1999.txt
Created August 2, 2017 10:09
A little selection of music (concentrating mostly on rock) strictly from 1970 to 1999.
Format
======
Band name
Album name 1 (release year)
Genre(s)
Choice song(s) from this album
Album name 2 (release year)
Genre(s)
Choice song(s) from this album