This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { | |
// no easing, no acceleration | |
linear: function (t) { return t }, | |
// accelerating from zero velocity | |
easeInQuad: function (t) { return t*t }, | |
// decelerating to zero velocity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(global) { | |
var DummyServer = function() { | |
var states = { | |
UNSENT: 0, | |
OPENED: 1, | |
HEADERS_RECEIVED: 2, | |
LOADING: 3, | |
DONE: 4 | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a quick demonstration of "function inheritance" as described in | |
// this paper from Daniel Brown and William Cook. | |
// http://www.cs.utexas.edu/users/wcook/Drafts/2009/sblp09-memo-mixins.pdf | |
// Expressed in TypeScript (and without the monads). | |
// Syntax note: When you write function types in TypeScript, you need to name | |
// each parameter. But the names don't actually matter, so I just use _. You | |
// can read `(_:A) => B` as `a -> b` in ML or Haskell syntax. | |
// In Brown and Cook's Haskell, `type Gen a = a -> a` is a "generator." The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; --- Skip lots of stuf --- | |
;;; <@19,#13> compare-numeric-and-branch | |
0x49252d6f 47 83f800 cmp eax,0x0 | |
0x49252d72 50 0f843e000000 jz 118 (0x49252db6) | |
;;; <@20,#17> -------------------- B2 (unreachable/replaced) -------------------- | |
;;; <@24,#24> -------------------- B3 -------------------- | |
;;; <@27,#26> compare-numeric-and-branch | |
0x49252d78 56 83f802 cmp eax,0x2 ;; debug: position 81 | |
0x49252d7b 59 0f842a000000 jz 107 (0x49252dab) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var above = function(limit){ | |
return function(value){ | |
return value > limit; | |
}; | |
}; | |
var isAbove10 = above(10); | |
console.log(isAbove10(5)); // false | |
console.log(isAbove10(8)); // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple Time travel machine to the future. | |
* | |
* A theoretical time-traveling to the future | |
* (a very-very-very simplified explanation/application | |
* of the General relativity). | |
* | |
* .allgemeine Relativitätstheorie | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "Fetch, decode, eval!" | |
// A simple Register-based VM, Assembler, and Disassembler. | |
// by Dmitry Soshnikov <[email protected]> | |
// This virtual machine (VM) consists of registers (data storage), | |
// and operations (instructions) which operate on the registers. | |
// -------------------------------------------------------------- | |
// Registers. | |
// -------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(expr). | |
-export([ | |
parse/1, | |
test/0 | |
]). | |
% ------------------------------------------------------ | |
% | |
% Simple math-expressions parser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// by Dmitry Soshnikov <[email protected]> | |
// MIT Style License. | |
// Short URL for this example to run online is: http://cpp.sh/333 | |
#include <iostream> | |
#include <vector> | |
#include <ctype.h> | |
#include <cstring> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using bin/typescript.js from TypeScript 0.9.7 | |
function compile(source) { | |
var parseErrors = []; | |
var logger = new TypeScript.NullLogger(); | |
var compilationSettings = TypeScript.ImmutableCompilationSettings.defaultSettings(); | |
var compiler = new TypeScript.TypeScriptCompiler(logger, compilationSettings); | |
var snapshot = TypeScript.ScriptSnapshot.fromString(source); |
NewerOlder