Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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-current-class.js
Created November 15, 2011 17:27
R-Proto-Class-Current-Class.js
// https://mail.mozilla.org/pipermail/es-discuss/2011-November/018440.html
// see original lib here:
// https://gist.github.com/1366953
// https://gist.github.com/1330574
var Class = {
/**
*allocate
@DmitrySoshnikov
DmitrySoshnikov / no-such-method-analysis.js
Created December 15, 2011 13:01
Analysis of current noSuchMethod situation
// by Dmitry Soshnikov <[email protected]>
// on "noSuchMethod" hook via proxies
// written on December 15, 2011
// Below is tl;dr
// but if you want really never-ending tl;dr, try this
// original old thread from 2010 on es-discuss:
// https://mail.mozilla.org/pipermail/es-discuss/2010-October/011929.html
// Small disclaimer and note:
/**
* Mark and Sweep Garbage Collection technique.
* MIT Style License
* by Dmitry Soshnikov
*/
// This diff describes the simplest version of mark and sweep
// GC in order to understand the basic idea. In real practice the
// implementation can be much tricker and optimized.
@DmitrySoshnikov
DmitrySoshnikov / reference-counting-gc.js
Last active December 11, 2015 17:09
Automatic Reference Counting (ARC) Garbage Collector
/**
* Automatic Reference Counting (ARC) Garbage Collection technique.
*
* This diff describes Reference counting GC technique.
* See also previous lesson on Mark and Sweep GC:
* https://gist.github.com/4391763
*
* Covered topics:
*
* 1. Reference value in ECMAScript (JS specific)