Skip to content

Instantly share code, notes, and snippets.

@conundrumer
conundrumer / TestFloat.js
Last active August 29, 2015 14:05
EMCAScript (javascript) floating point compliance test
// Specification: http://www.ecma-international.org/ecma-262/5.1/#sec-8.5
// Test code source: http://www.vinc17.org/research/extended.en.html#bugs-js
var x, y, z, d;
x = 9007199254740994; // 2^53 + 2
y = 1 - 1/65536;
z = x + y;
d = z - x;
if (d === 0) {
alert("Using double precision: PASS");
} else if (d === 2) {
@conundrumer
conundrumer / real_peel
Created May 1, 2015 15:29
real_peel(): maps LPC coefficients to waveguide radii
/*----------------------------------------------------------------------------
rt_lpc - real-time LPC analysis/synthesis and visualization
Copyright (c) 2004 Ananya Misra, Ge Wang, Perry R. Cook. All rights reserved.
http://soundlab.cs.princeton.edu/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
va = velocity of point a
vb = velocity of point b
vp = velocity of point c (the point colliding with line ab) perpendicular to line ab
vm = velocity of the center of line ab
w = angular momentum
x = the position of point c on line ab (x==1 ? point c = point a; x==-1 ? point c = point b)
L = length of line ab divided by 2
L = dist(point a, point b) / 2
x = (L - dist(point a, point c) ) / L
@conundrumer
conundrumer / twitchRegex.js
Created February 2, 2016 20:49
really inefficient regex in twitch.tv's embedded chat
// The amount of time it takes for the RegEx to finish depends on the url of the current page:
var short = 'http://iridethelines.forumotion.com/post?p=183422&mode=editpost'
var medium = 'http://iridethelines.forumotion.com/t11564-threads-with-2-pages-freezing-tab#183414'
var reallyLong = 'http://iridethelines.forumotion.com/t10491p150-the-bofficial-b-chuggers-preview-thread-for-men'
var m = new RegExp("^https?://([a-zA-Z0-9]+.)*twitch.tv(:[0-9]+)?/.*$")
var t
t = Date.now(); m.test(short); console.log((Date.now() - t) / 1000)
t = Date.now(); m.test(medium); console.log((Date.now() - t) / 1000)
window.store.dispatch({type:'SET_FRAME_MAX_INDEX', maxIndex: 60 * 40 * 3})
recorder.width = 1920; recorder.height = 1080
/Applications/ffmpeg/ffmpeg -f concat -i <(for f in ./*.webm; do echo "file '$PWD/$f'"; done) -r 60 out.mp4
cam.roundness = 0; cam.pull = 0; cam.push = 0; cam.area = 0.25;
store.dispatch({type: 'SET_AUDIO_OFFSET', offset: 1}) // offset in seconds
store.dispatch({type: 'SET_CAM', cam:{x:0,y:0,z:0.5}}) // 0.5 is default, z > 0