Skip to content

Instantly share code, notes, and snippets.

View pvdz's full-sized avatar

Peter van der Zee pvdz

View GitHub Profile
@pvdz
pvdz / txt
Last active December 2, 2015 22:11
Raw isaac point data
Raw data for https://www.reddit.com/r/bindingofisaac/comments/3v79hc/daily_run_point_breakdown_first_floor/
Floor layout: http://imgur.com/OjdfFC1 (crawl space in room above shop, top right rock).
Run as lazarus, starts this run with an explosive pill. when he dies he gets Anemic, may offset certain scores as well.
stage bonus:
- 500 per floor
- dice 5 room does not count
-- (TBD) probably forgetmenow neither
@pvdz
pvdz / gist:3bbe2333fadda54da93f
Created July 2, 2015 07:52
get randomly reordered 1234 (or abcd) without using arrays
var a = 'a', b = 'b', c = 'c', d = 'd';
a = 'a';
var r = RANDOM();
if (r < .5) {
b = a;
a = 'b';
}
r = RANDOM();
if (r < .33) {
c = b;
@pvdz
pvdz / gist:3cccc4f36c8319e09bb7
Created January 29, 2015 20:18
JS1k 2015 bare shim. This is loaded in an iframe dynamically. You can opt for an empty DOM during submit, a 2d canvas, or a webgl canvas. You can also specify max canvas width/height during submit, defaults to 100%. If empty, `a`, `c`, and `g` will obviously not exist. `top.reload()` replaces the iframe containing your demo with a new instance, …
<!doctype html>
<html style="margin: 0; padding: 0; border: 0; width: 100%; height: 100%;">
<head>
<meta charset="utf-8">
</head>
<body style="margin: 0; padding: 0; border: 0; width: 100%; height: 100%;">
<canvas style="display: block; width: WIDTHpx; height: HEIGHTpx;" width="WIDTH" height="HEIGHT"></canvas>
<script>
// shim...
var a = canvas;
@pvdz
pvdz / animworker.js
Last active August 29, 2015 14:07
Creating animated gif. Demonstrates web worker lag after some frames unless respawned. For other deps see https://github.com/antimatter15/jsgif
importScripts('gifencoder/LZWEncoder.js', 'gifencoder/NeuQuant.js', 'gifencoder/GIFEncoder.js');
self.onmessage = function(event) {
//console.log("message!");
//alert("message");
//self.postMessage(event.data);
var frame_index = event.data.frame_index;
var frame_length = event.data.frame_length;
var height = event.data.height;
@pvdz
pvdz / gist:f33a51dc7189d98efe23
Created July 3, 2014 10:31
Right now the sub is never fired. If you uncomment the first line, both subs are fired.
// PubSub.subscribe('foo', function(name, value) {});
PubSub.publish('foo', 'bar');
PubSub.subscribe('foo', function(name, value) {});
@pvdz
pvdz / gist:1b75c28f3a5adfca11a5
Created June 11, 2014 18:21
Silly example to add numbers to 5, after processing, beautified (ugly artifacts left in intentionally because, well, idc)
var yielding = false;
function this_makeFive(n){
var step = 1;
var v1, v0;
var f1, f0;
return function(){
while (true) {
switch (step) {
case 1:
if (n === 3);
@pvdz
pvdz / gist:15a1765d2127b693e040
Created June 11, 2014 18:20
Silly example to add numbers to 5, before processing
var yielding = false;
function this_makeFive(n){
if (n === 3) return this_addOne(n)+1;
else if (n === 1) return this_addThree(n)+1;
else throw 'invalid input, can only hand 1 and 3';
}
function this_addThree(n){
return this_addOne(n) + 2;
}
function this_par_parseCatch(inFunction, inLoop, inSwitch, labelSet){
if (this_tok_nextPuncIfString('catch')) {
var type = this_tok_mustBeNum(0x28, false);
if (type === 13) {
if (this_par_isReservedIdentifier(false)) this_tok_throwSyntaxError('Catch scope var name is reserved');
this_tok_next(false);
} else {
this_tok_throwSyntaxError('Missing catch scope variable');
}
function this_tok_mustBeString(str, nextIsExpr){
if (this_tok_getLastValue() === str) return this_tok_next(nextIsExpr);
this_tok_throwSyntaxError('Expecting current value to be ['+str+'] is ['+this_tok_getLastValue()+']');
}
==>
var this_tok_returnIsYield = false;
function this_tok_mustBeString(str, nextIsExpr){
var tag = 'start';
@pvdz
pvdz / gist:9890540
Created March 31, 2014 11:44
random golf example
var q = Math,
r = 2 * q.PI,
w = q.sin,
x = q.pow,
y = q.max,
Q = q.sqrt;
// =>
var q=Math,w=q.sin,x=q.pow,y=q.max,Q=q.sqrt,r=2*q.PI;