Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
DmitrySoshnikov / classes.txt
Created May 17, 2011 18:19
Classification of classes
// by Dmitry Soshnikov <[email protected]>
// MIT Style License
*Classification of classes:*
=============================================================================
| Dynamic | Static
-----------------------------------------------------------------------------
| |
| Coffee, Python, Ruby, | SmallTalk, built-in
@DmitrySoshnikov
DmitrySoshnikov / es5-negative-indicies.js
Created May 21, 2011 21:32
Manual negative indicies of arrays in ES5
/**
* Manual negative indicies for arrays in ES5:
* usually we use in such cases only first three
* negative indices, so these are enough (you may
* add -4, -5, etc. if needed).
*
* See also the implementation with proxies:
* https://github.com/DmitrySoshnikov/es-laboratory/blob/master/src/array-negative-indices.js
*
* by Dmitry Soshnikov <[email protected]>
@DmitrySoshnikov
DmitrySoshnikov / primitive-process.html
Created July 25, 2011 08:18
Primitive Actor-processes
<html>
<head>
<title>Process</title>
<style type="text/css">
#p-0 {color: green;}
#p-1 {color: blue;}
.p {
float: left;
width: 300px;
border: 1px solid #CCC;
@DmitrySoshnikov
DmitrySoshnikov / erlang-scheduler.js
Created August 5, 2011 13:24
Simple (cooperative) processes with the Scheduler
/**
* The simplest processes (cooperative tasks) with Scheduler
* (sort of Erlang's processes but without messages yet)
* See also: http://www.dabeaz.com/coroutines/index.html
*
* Deps: JS 1.7 with generators (yield)
*
* by Dmitry Soshnikov <[email protected]>
* MIT Style License
*/
@DmitrySoshnikov
DmitrySoshnikov / processes.js
Created August 7, 2011 07:52
Processes with supporting trampolining
/**
* The simplest processes (cooperative tasks) with Scheduler
* (sort of Erlang's processes but without messages yet)
* See: http://www.dabeaz.com/coroutines/index.html
*
* Deps: JS 1.7 with generators (yield)
*
* This version uses "trampolining" technique to request
* data from other processes in synchronous manner.
* See also: https://gist.github.com/1127536 (without "trampolining")
@DmitrySoshnikov
DmitrySoshnikov / bound-functions.js
Created August 16, 2011 14:14
Features of bound functions
/**
* Features of bound functions.
*
* See: http://dmitrysoshnikov.com/notes/note-1-ecmascript-bound-functions/
*
* by Dmitry Soshnikov <[email protected]>
* MIT Style License
*/
var F = function () {};
@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
*/
@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 / 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 / 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
*