This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AudioVis { | |
constructor() { | |
this.analyser = … | |
this.data = new Uint8Array(…) | |
this.frequencies = new Uint8Array(…) | |
} | |
populateArrays() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(typeof document !== 'undefined') { | |
// normal script tag | |
console.log("Hello #1") | |
navigator.serviceWorker.register( | |
document.currentScript.src | |
) | |
} else { | |
// running as a service worker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
importScripts('https://unpkg.com/sw-toolbox@3.6.0/sw-toolbox.js') | |
toolbox.router.get('/:path*', toolbox.cacheFirst, { | |
origin: /fonts\.(gstatic|googleapis)\.com/, | |
cache: { | |
name: 'fonts-v1', | |
maxEntries: 10 | |
} | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let delayed = new Promise(r => setTimeout(r, 500, 'hello')) | |
let element = Object.assign( | |
document.createElement('div'), | |
{textContent: 'hello'} | |
) | |
Object.assign(element.style, { | |
background: 'red' | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(root) { | |
Object.assign(document.body.style, { | |
'transform': 'perspective(500px) rotateY(12deg) rotateX(9deg) rotateZ(-4deg) translate3d(56%, 26%, -516px)', | |
'transform-origin': '0 0', | |
'transform-style': 'preserve-3d' | |
}) | |
const node_style = { | |
'outline': '3px solid rgba(255,0,150,0.5)', | |
'transform-style': 'preserve-3d', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// includes regression | |
// https://unpkg.com/regression@1.4.0/build/regression.min.js | |
var canvas = document.createElement('canvas') | |
var ctx = canvas.getContext('2d') | |
document.body.appendChild(canvas) | |
Object.assign(canvas.style, {border:'1px solid #ccc', margin:0}) | |
var m = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rgb = new Uint8ClampedArray(50 * 3); | |
// Set the colours of a particular light (i) at a given intensity (s) | |
function set(r, g, b, i, s){ | |
i *= 3; | |
if(i > 0) { | |
rgb[i] = rgb[i] + ((r - rgb[i]) * s); i++; | |
rgb[i] = rgb[i] + ((g - rgb[i]) * s); i++; | |
rgb[i] = rgb[i] + ((b - rgb[i]) * s); i++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chunkToWAV = (function(chunkSize){ | |
var head = atob( | |
'UklGRiQAAABXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YQAAAAA=' | |
) | |
var buffer = new ArrayBuffer(head.length + chunkSize) | |
var view = new DataView(buffer) | |
for (var i = 0; i < head.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {ctx, w, h} from 'canvas' | |
import {loop, drawEdge, scale, rotateX, rotateY, rotateZ} from 'helpers' | |
const pM = $M([ | |
[1, 0, 0, 0], | |
[0, 1, 0, 0], | |
[0, 0, 1, 0], | |
[0, 0, 0.005,0.995] | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cluster = require('cluster'); | |
var http = require('http'); | |
var numCPUs = require('os').cpus().length; | |
if (cluster.isMaster) { | |
// Fork workers. | |
for (var i = 0; i < numCPUs; i++) { | |
cluster.fork(); | |
} |