Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
DmitrySoshnikov / r-proto-class-class.js
Created November 15, 2011 13:00
R-Proto-Class-Class.js
/**
* r-proto-class-class.js
* Ruby's semantics
*
* Features:
* - super calls
* - using Object.create for inheritance
* - Class.new is a wrapper over Class.allocate and Class.initialize
*
* See also version w/o class(...) wrapper: https://gist.github.com/1366953
@DmitrySoshnikov
DmitrySoshnikov / r-proto-class.js
Created November 15, 2011 12:22
R-Proto-Class.js
/**
* r-proto-class.js
* Ruby's semantics
*
* Features:
* - super calls
* - using Object.create for inheritance
* - Class.new is a wrapper over Class.allocate and Class.initialize
*
* See also version w/ class(...) wrapper: https://gist.github.com/1367025
@DmitrySoshnikov
DmitrySoshnikov / class.js
Created November 1, 2011 14:08
Class lib sugar for JS
/**
* class.js
* @author Dmitry A. Soshnikov
*/
function Class(params) {
/**
* Constructor function
* If not specified, use default
@DmitrySoshnikov
DmitrySoshnikov / HelloDartTest.dart
Created October 12, 2011 06:59
Dart Compilation
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Simple test program invoked with an option to eagerly
// compile all code that is loaded in the isolate.
// VMOptions=--compile_all
class HelloDartTest {
static testMain() {
print("Hello, Darter!");
@DmitrySoshnikov
DmitrySoshnikov / isolate-test.dart
Created October 10, 2011 09:58
Dart's isolate test
class Printer extends Isolate {
main() {
port.receive((message, replyTo) {
if (message == null) port.close();
else print(message);
});
}
}
main() {
@DmitrySoshnikov
DmitrySoshnikov / to-explicit-re.js
Created September 26, 2011 14:19
To explicit RegExp
/**
* toExplicitRe
* Converts implicit concatenations of RegExps into explicit ones
* by adding dot "." symbol as the concatenation symbol.
*
* The explicit format of RegExps is used by https://gist.github.com/1239804
*
* Examples:
*
* - abc => a.b.c
@DmitrySoshnikov
DmitrySoshnikov / infix-to-postfix-regexp.js
Created September 24, 2011 20:14
Infix to postfix notation RegExp converter
/**
* Infix to postfix notation RegExp converter
*
* To implement RegExp machine (NFA, DFA) we need
* to transform first RegExp string to postfix notation
* for more convinient work with the stack. This function
* does exactly this.
*
* See: http://swtch.com/~rsc/regexp/regexp1.html
*
@DmitrySoshnikov
DmitrySoshnikov / shunting-yard-algorithm.js
Last active November 20, 2024 01:16
Shunting yard algorithm
/**
* Shunting yard algorithm
* See: http://en.wikipedia.org/wiki/Shunting_yard_algorithm
*
* Converts infix notation to postfix notation
*
* by Dmitry Soshnikov <[email protected]>
* MIT Style License
*
* (C) 2011, updated on 2020
@DmitrySoshnikov
DmitrySoshnikov / postfix-eval.js
Created September 23, 2011 19:54
Simple postfix notation math evaluator
/**
* Postfix notation math evaluator
* See: http://en.wikipedia.org/wiki/Reverse_Polish_notation
*
* See also prefix notation example:
* https://github.com/DmitrySoshnikov/Essentials-of-interpretation/blob/master/src/notes/note-1.js
*
* by Dmitry Soshnikov <[email protected]>
* MIT Style License
*/
@DmitrySoshnikov
DmitrySoshnikov / doc.js
Created September 1, 2011 18:22
Runtime documentation for function declarations
/**
* Simple doc-property generator. Uses JavaDoc style comments.
* Also provides type checking guards.
*
* Dependencies: SpiderMonkey >= 1.7
*
* by Dmitry Soshnikov <[email protected]>
* MIT Style License
*/