Skip to content

Instantly share code, notes, and snippets.

View pboyer's full-sized avatar

Peter Boyer pboyer

View GitHub Profile
@pboyer
pboyer / ycombinator.js
Created April 1, 2013 01:27
This Gist demonstrates how to derive the applicative order y-combinator in JavaScript. It closely follows John Franco's derivation found here: http://www.ece.uc.edu/~franco/C511/html/Scheme/ycomb.html
// Our initial conception of the factorial function
// Uses straightforward recursion to acheive its purpose
fact =
function(n){
return (n === 1) ? 1 : n * fact(n-1);
};
console.log( fact(5) ); // returns 120
import Html exposing (Html)
import Html.Events exposing (..)
import Html.App as App
import Svg exposing (..)
import Svg.Attributes exposing (..)
import Mouse exposing (Position)
import Json.Decode as Json exposing((:=))
main =
App.program {
@pboyer
pboyer / dynamicArray.ts
Created February 12, 2017 18:46
A generic, dynamically sized TypedArray in TypeScript
interface TypedArray {
readonly length : number;
readonly [n: number]: number;
BYTES_PER_ELEMENT : number;
set(n : ArrayLike<number>, offset : number) : void;
}
interface TypedArrayConstructor<T extends TypedArray> {
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): T;
}

Keybase proof

I hereby claim:

  • I am pboyer on github.
  • I am ptrbyr (https://keybase.io/ptrbyr) on keybase.
  • I have a public key ASCH7bHPaPSZitcJ5kWPhICNHuFCkzVddoRtTcJLvwLgHQo

To claim this, I am signing this object:

@pboyer
pboyer / CMakeLists.txt
Last active June 21, 2018 18:04 — forked from floooh/CMakeLists.txt
copy asset files as fips code-gen job
# a code-gen job must be added to the application's CMakeLists.txt through a call to fips_generate()
fips_begin_app(dragons windowed)
fips_src(.)
fips_generate(FROM files.yml TYPE filecopy OUT_OF_SOURCE ARGS "{ deploy_dir: \"${FIPS_PROJECT_DEPLOY_DIR}\" }")
# REMOVE THIS: n3h5_files(files.yml)
fips_deps(emsctest)
fips_end_app()
@pboyer
pboyer / AsyncNodeGraph.ts
Last active October 5, 2018 00:38
A node graph evaluator with asynchronous evaluation, memoization, and automatic parallelization.
// GraphNodeValue is the type of value a GraphNode evaluation can produce
type GraphNodeValue = any;
// GraphNodeArgs are the arguments of a GraphNode evaluation
type GraphNodeArgs = GraphNodeValue[];
// GraphNodeResult is the result of a GraphNode evaluation
type GraphNodeResult = GraphNodeValue[];
// GraphEnv is the result of a Graph evaluation. Env is short for "environment" in programming language jargon.