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
// Put strings from the input array | |
// which can be rotated to match each other | |
// into groups. | |
// | |
// input: ['Hello', 'World', 'lohEl', 'orld'] | |
// output: [['Hello', 'lohEl'], ['World'], ['orld']] | |
function groupRotations(strings, transform) { | |
if (typeof transform !== 'function') { | |
transform = string => string.toLowerCase(); |
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
Events.eventify = eventify; | |
Events.onify = onify; | |
Events.prototype.observe = observe; | |
Events.prototype.unobserve = unobserve; | |
Events.prototype.handle = handle; | |
Events.prototype.unhandle = unhandle; | |
Events.prototype.handleEvent = handleEvent; | |
Events.prototype.on = on; | |
Events.prototype.off = off; | |
Events.prototype.fire = fire; |
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); |
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
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
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
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 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
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
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) { |
NewerOlder