This file contains 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
Array.prototype.forSome = function(callback, thisValue) { | |
if (typeof thisValue !== 'object') { | |
thisValue = null; | |
} | |
try { | |
for (var i = 0; i < this.length; i++) { | |
if (this.hasOwnProperty(i)) { | |
var returnValue = callback.call(thisValue, this[i], i, this); | |
if (typeof returnValue !== 'undefined') { | |
return returnValue; |
This file contains 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 unescapeJSString(string) { | |
var named = {b: "\b", f: "\f", n: "\n", r: "\r", t: "\t", v: "\v"}; | |
return string.replace(/\\(?:([bfnrtv])|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|([0-3][0-7]{0,2}|[0-7]{1,2})|([^]))/g, function(seq, name, hex4, hex2, oct, char) { | |
var hex; | |
if (name) { // e.g. \n | |
return named[name]; | |
} else if (char) { // e.g. \" | |
return char; | |
} else if (hex = hex4 || hex2) { // e.g. \u0022 or \x22 | |
return String.fromCharCode(parseInt(hex, 16)); |
This file contains 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 Map = (function Map(method) { | |
if (typeof method === "function") { | |
Map.prototype[method.name] = method; | |
return Map; | |
} | |
if (!(this instanceof Map)) { | |
return new Map(); | |
} | |
this.data = {}; | |
})(function has(key) { |
This file contains 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 splitAt(string, index1, index2, etc) { | |
var parts = Array.prototype.slice.call(arguments); | |
parts[0] = 0; | |
for (var i = 0, l = parts.length; i < l; i++) { | |
parts[i] = string.substring(parts[i], parts[i + 1]); | |
} | |
return parts; | |
} |
This file contains 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 splitAt(string /* indexes... */) { | |
var i = 0, len = arguments.length, index = 0, parts = []; | |
while (i < len) { | |
parts[i] = string.substring(index, index = arguments[++i]); | |
} | |
return parts; | |
} |
This file contains 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
find . -iname "*.htm" -exec bash -c "iconv -f WINDOWS-1252 -t UTF-8 \"{}\" | html2text -utf8 -nometa -style pretty > \"`basename \"{}\" .htm`\".txt" \; |
This file contains 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 createRandomGIF(width, height, colors) { | |
return { | |
width: width, | |
height: height, | |
resolution: 7, | |
colorTable: { | |
sorted: false, | |
colors: random(colors, 0x000000, 0xFFFFFF) | |
}, | |
background: 0, |
This file contains 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 | |
sum | |
( | |
) | |
{ | |
for | |
( | |
var | |
i | |
= |
This file contains 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 behaviours = { | |
select: { | |
onstart: function(p) { | |
var viewer = this.workspace.viewer; | |
this.from = { | |
x: p.x - (p.x % viewer.gridSize), | |
y: p.y - (p.y % viewer.gridSize) | |
}; | |
viewer.unselect(); | |
}, |
This file contains 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 behaviours = { | |
select: { | |
onstart: function(p) { | |
this.from = alignPos(this, p); | |
this.workspace.viewer.unselect(); | |
}, | |
onresume: function(p) { | |
if (this.from) { | |
this.mousemoved = true; | |
updateSelection(this, p); |
OlderNewer