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() { | |
var pre = document.createElement('pre'); | |
document.body.appendChild(pre); | |
console = { | |
log: function() { | |
pre.innerHTML += Array.prototype.slice.call(arguments).map(function(s) { if (s === undefined) return 'undefined'; return s }).join(" ") + "\n"; | |
} | |
} | |
})() |
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
// ES6 exports | |
export var foo = 1 | |
export var bar = true | |
// CJS analog | |
module.exports = { | |
foo: 1, | |
bar: true |
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
// Type definitions for React 0.13.0 | |
// Project: http://facebook.github.io/react/ | |
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com> | |
// Definitions: https://github.com/borisyankov/DefinitelyTyped | |
declare module React { | |
// | |
// React Elements | |
// ---------------------------------------------------------------------- | |
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 typescript = require('typescript') | |
var path = require('path') | |
var compilerOptions = { | |
target: typescript.ScriptTarget.ES5 | |
} | |
var files = {}; | |
var servicesHost = { | |
getScriptFileNames: function () { return Object.keys(files) }, |
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 file is SUPER RAW. Debugging and test code abound! | |
// This is a pure JS PNG encoder which skips zlib compression. Good enough for small dynamic data URIs though | |
var testData = [[25, 0, 151, 255, 25, 0, 151, 255, 25, 0, 151, 255], [25, 0, 151, 255, 25, 0, 151, 255, 25, 0, 151, 255], [25, 0, 151, 255, 25, 0, 151, 255, 25, 0, 151, 128]]; | |
var preFilteredPngImage = [[0x19, 0, 0x97, 0xff, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x81]]; | |
var preFilteredPngData = [1, 0x19, 0, 0x97, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x81]; | |
var encodePng = function(data) { |
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 i = 0; | |
var func = function() { i++; }; | |
func(); | |
print(i); // 0 or 1? (answer: 1) |
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 hasOwnProperty = Object.prototype.hasOwnProperty; | |
var equivalent = function(actual, expected) { | |
if (actual === expected) { | |
return true; | |
} | |
else if (expected instanceof Date) { | |
if (actual instanceof Date && actual.getTime() == expected.getTime()) { | |
return true; | |
} |
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 namespace = function(str) { | |
var parts = str.split('.'); | |
var nsLevel = window; | |
for (var i = 0, n = parts.length; i < n; i++) { | |
nsLevel = nsLevel[parts[i]] = nsLevel[parts[i]] || {}; | |
} | |
}; | |
namespace('myNamespace.subNamespace'); |
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 format = function(str) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
var replaceFunc = function(matchedStr) { | |
var index = parseInt(matchedStr.substring(1, matchedStr.length-1), 10); | |
return args[index] != null ? args[index] : ''; | |
}; | |
return str.replace(/\{[0-9]+\}/g, replaceFunc); | |
}; | |
format("Hello {0}", "world"); |
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
// usage: | |
// var diff = new customdiff(); | |
// data1 = data1.split('\n'); | |
// data2 = data2.split('\n'); | |
// var diffs = diff._diff(data1, data2); | |
var customdiff = function() { | |