Open in StackEdit Viewer
Gist: https://gist.github.com/shamansir/faedd62ef62cc8c15582
<style type="text/css"> .positive { color: #006600; } .negative { color: #ff0000; } .neutral { color: #cccc00; }
| // 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 } } |
| 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. | |
| */ |
Open in StackEdit Viewer
Gist: https://gist.github.com/shamansir/faedd62ef62cc8c15582
| /* | |
| * Classic example grammar, which recognizes simple arithmetic expressions like | |
| * "2*(3+4)". The parser generated from this grammar then computes their value. | |
| */ | |
| start | |
| = additive | |
| additive | |
| = left:multiplicative "+" right:additive { return left + right; } |
| // x 10 runs | |
| βββββββββββββββββββββββββββββββββββββββ¬ββββββββββββ¬βββββββββββββ¬βββββββββββββββ | |
| β Test β Inp. size β Avg. time β Avg. speed β | |
| βββββββββββββββββββββββββββββββββββββββ΄ββββββββββββ΄βββββββββββββ΄βββββββββββββββ€ | |
| β JSON β | |
| βββββββββββββββββββββββββββββββββββββββ¬ββββββββββββ¬βββββββββββββ¬βββββββββββββββ€ | |
| β Example 1 β 0.69 kB β 0.90 ms β 766.06 kB/s β | |
| β Example 2 β 0.24 kB β 0.30 ms β 787.76 kB/s β | |
| β Example 3 β 0.59 kB β 0.20 ms β 2949.22 kB/s β | |
| β Example 4 β 3.39 kB β 0.70 ms β 4838.17 kB/s β |
| module.exports = (function(){ | |
| /* | |
| * Generated by PEG.js 0.7.0. | |
| * | |
| * http://pegjs.majda.cz/ | |
| */ | |
| function quote(s) { | |
| /* |
| module.exports = (function() { | |
| /* | |
| * Generated by PEG.js 0.7.0. | |
| * | |
| * http://pegjs.majda.cz/ | |
| */ | |
| function peg$subclass(child, parent) { | |
| function ctor() { this.constructor = child; } | |
| ctor.prototype = parent.prototype; |
| /* | |
| * Classic example grammar, which recognizes simple arithmetic expressions like | |
| * "2*(3+4)". The parser generated from this grammar then computes their value. | |
| */ | |
| start | |
| = additive | |
| additive | |
| = left:multiplicative "+" right:additive { return left + right; } |
| // simple observer (pubsub) implementation | |
| define(["underscore", "base/classex", "util/logging"], function(_, Class, Logging) { | |
| var PubSub = Class.extend({}); | |
| PubSub._topics = function() { | |
| if (!window.pubsub) { | |
| window.pubsub = {}; | |
| } | |
| return window.pubsub; |
| #Newbie programmer | |
| def factorial(x): | |
| if x == 0: | |
| return 1 | |
| else: | |
| return x * factorial(x - 1) | |
| print factorial(6) | |
| #First year programmer, studied Pascal |