Skip to content

Instantly share code, notes, and snippets.

@cheery
cheery / bootloader.coffee
Created January 29, 2014 19:43
How would I get source maps working here? The scripts are loaded from inside an archive, they need to be wrapped into modules so they find each other.
zip.workerScriptsPath = "lib/"
$ ->
archiveURL = 'app.zip'
requestBlob archiveURL, {
load: (blob) ->
new ZipReader blob, {
load: (entries) ->
console.log "loaded"
runModule(archiveURL, entries, {}, 'scripts/main')

Overview

The format is supposed to contain the same elements as JSON, and annotate it with tag strings and attribute objects.

Every value, string, number, object, array, true, false, null, can be annotated.

Special attributes

Some attributes are reserved for special purpose. For example comment, layout, diff, to name some.

@cheery
cheery / README.md
Last active August 29, 2015 13:57
Source Maps and Coffeescript Modules

Source Maps and Coffeescript Modules

In these files, the browser compiles and loads the coffee-script code, with a module system provided by the bootloader in main.js.

The source maps in this gist are not working. They are giving me line after the source of the logging in Chrome 33. In firefox 27, it doesn't seem to work at all.

I would like you to solve a problem for me: Figure out how to get the source maps working in this setting. Provide an option for embedding the source along the source map and the code. Provide way to specify a source URL, to make it easier to locate the module.

As a reward, you are making client-side browser development bit less intimidating.

from asyncio import schedule, http, log
from asyncio.log import Logger
import sys
import stream
axis49 = "/dev/snd/midiC2D0"
def main():
fd = stream.open(axis49, 'rb')
schedule(read_midi, fd)
@cheery
cheery / dsp.js
Last active August 29, 2015 14:03
Feed into wavepot.com
var tau = Math.PI * 2;
var dot = 2.0;
var a = [
[69-4, 69-2, 69, 69, 69-4],
[ 8, 8, 4, 4, 4]
];
var b = [
[69-4, 69-2, 69, 69, 69, 69, 69+1, 69, 69-2],
[ 8, 8, 8, 8, 8, 8, 4, 4, 4]
@cheery
cheery / lr.py
Last active August 29, 2015 14:04
LR(1) canonical table construction
def main():
terminals = {"*", "+", "0", "1"}
rules = [
rule("E", "E", "*", "B"),
rule("E", "E", "+", "B"),
rule("E", "B"),
rule("B", "0"),
rule("B", "1"),
]
table, analysis = build_canonical(terminals, rules, accept="E")
@cheery
cheery / hlp.py
Created July 19, 2014 19:59
Simple high pass and low pass filters with frequency cutoff
/*
simple high pass and low pass filters with frequency cutoff.
*/
var tau = Math.PI*2;
var v = 0;
lp = LP();
hp = HP();
function dsp(t) {
@cheery
cheery / osc.js
Created July 25, 2014 00:11
Oscillators that blend without phase shifting. Not huge difference but noticeable.
var mi = Math.PI/2;
var pi = Math.PI;
var tau = Math.PI*2;
function arp(ts, x, y, z) {
return Math.sin(x * Math.exp(-ts * y)) * Math.exp(-ts * z);
}
var sin = Math.sin;
@cheery
cheery / fm_bang.js
Created July 25, 2014 11:52
Frequency modulation
var pi = Math.PI;
var tau = Math.PI*2;
function arp(ts, x, y, z) {
return Math.sin(x * Math.exp(-ts * y)) * Math.exp(-ts * z);
}
var sin = Math.sin;
var cos = Math.cos;
@cheery
cheery / karplus.js
Last active August 29, 2015 14:04
Karplus-Strong
/*
Sort of string instrument simulation. I'm not sure where it's going to.
http://boxbase.org/sequencer/
*/
var hpi = Math.PI/2;
var pi = Math.PI;
var tau = Math.PI*2;
var sin = Math.sin;
var cos = Math.cos;