Open in StackEdit Viewer
Gist: https://gist.github.com/shamansir/faedd62ef62cc8c15582
<style type="text/css"> .positive { color: #006600; } .negative { color: #ff0000; } .neutral { color: #cccc00; }
Open in StackEdit Viewer
Gist: https://gist.github.com/shamansir/faedd62ef62cc8c15582
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. | |
*/ |
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() }; | |
} | |
}); |
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; |
[ Launch: Tributary inlet ] 1fd86904dcc5b12776e7 by shamansir
// 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() {[ |
// 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) : "") |
var Base = class_({ | |
_init: function(a, b) { | |
this.a = a; | |
this.b = b; | |
}, | |
someMethod: function(a) { | |
this.a = a; | |
}, |
// How to make JQuery-like function in Java | |
// shamansir.github.com (c) | |
public interface ProvidesElements { | |
public Elements[] get(); | |
} | |
public class JQ implements ProvidesElements { |
// === PATHS =================================================================== | |
// M<X> <Y> - move to | |
// L<X> <Y> - line to | |
// C<X1> <Y1> <X2> <Y2> <X3> <Y3> - curve to | |
// Z - close path | |
// lowercase marker means relative coord | |
// Example: "M0 10 L20 20 C10 20 15 30 10 9 Z" | |
// all commands: |