[ Launch: Tributary inlet ] 1fd86904dcc5b12776e7 by shamansir
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
// take SVG commands and draw this path to HTML5 canvas | |
// commandList should look like that: [ { marker: "M", values: [ 10, 10 ] }, | |
// { marker: "l", values: [ 5, 7 ] }, | |
// { marker: "C", values: [ -5, 7.2, .3, -16, 24, 10 ] }, | |
// . . . | |
// { marker: "z", values: [ ] } ] | |
// there's another gist which has the code to parse SVG paths: | |
// https://gist.github.com/shamansir/0ba30dc262d54d04cd7f79e03b281505 |
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
// svgPathToCommands('M10,10 l 5,7 C-5,7.2,.3-16,24,10 z'); | |
// | |
// produces: | |
// | |
// [ { marker: "M", values: [ 10, 10 ] }, | |
// { marker: "l", values: [ 5, 7 ] }, | |
// { marker: "C", values: [ -5, 7.2, 0.3, -16, 24, 10 ] }, | |
// { marker: "z", values: [ ] } ] | |
// | |
// commandsToSvgPath(svgPathToCommands('M10,10 l 5,7 C-5,7.2,.3-16,24,10 z')) |
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
// based on http://bl.ocks.org/mbostock/3468167 | |
function roundedRect(x, y, width, height, rtl, rtr, rbr, rbl) { | |
return "M" + x + "," + y | |
+ (rtl ? ("v" + rtl | |
+ "a" + rtl + "," + rtl + " 0 0 1 " + rtl + "," + -rtl) : "") | |
+ "h" + (width - (rtl ? rtl : 0) - (rtr ? rtr : 0)) | |
+ (rtr ? ("a" + rtr + "," + rtr + " 0 0 1 " + rtr + "," + rtr) : "") | |
+ "v" + (height - (rtr ? rtr : 0) - (rbr ? rbr : 0)) | |
+ (rbr ? ("a" + rbr + "," + rbr + " 0 0 1 " + -rbr + "," + rbr) : "") |
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
// allows to check if the spy was called with specified arguments in exact order, | |
// like: | |
// ``` | |
// var spy = createSpy('foo'); | |
// spy('a', { prop: 'foo' }); | |
// spy('b', { prop: 'bar' }); | |
// spy('c', { prop: 'baz' }); | |
// spy('d', { prop: 'fuz' }); | |
// expect(spy).toHaveBeenCalledInOrder() {[ |
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 numIter(max) { | |
return function(signal) { | |
if (signal) { | |
var value = 0; | |
return signal.takeWhile(function() { return value < max; }) | |
.map(function() { console.log('iter('+max+')', value); return value++; }) | |
} else { | |
return Kefir.fromBinder(function(emitter) { | |
var value = 0; |
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
// source: http://jspro.brothercake.com/media-events/progress.html | |
// article: http://www.sitepoint.com/essential-audio-and-video-events-for-html5/ | |
(function() | |
{ | |
//create a new video element with "auto" preload and native "controls" | |
var media = document.body.appendChild(document.createElement('video')); | |
media.setAttribute('preload', 'auto'); |
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
Rpd.channeltype('pd/t-num', { | |
show: function(t_num) { return t_num ? t_num.value : '?'; } | |
}); | |
Rpd.channeltype('pd/spinner', { | |
adapt: function(val) { | |
return { value: val, time: Date.now() }; | |
} | |
}); |
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
// inspired by rust-jlens: https://github.com/bkoropoff/rust-jlens/blob/master/src/lib.rs | |
pub trait Step { | |
fn perform(&self, &mut|&str|); | |
fn step1(self) -> Step1<Self> { Step1 { prev: self } } | |
fn step2(self) -> Step2<Self> { Step2 { prev: self } } |
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
module.exports = (function(){ | |
/* Generated by PEG.js 0.6.2 (http://pegjs.majda.cz/). */ | |
var result = { | |
/* | |
* Parses the input with a generated parser. If the parsing is successfull, | |
* returns a value explicitly or implicitly specified by the grammar from | |
* which the parser was generated (see |PEG.buildParser|). If the parsing is | |
* unsuccessful, throws |PEG.parser.SyntaxError| describing the error. | |
*/ |