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 _ = require('underscore'); | |
function sortByWeight (arr, weightMap) { | |
arr.sort(function (e1, e2) { | |
var w1 = weightMap[e1]; | |
var w2 = weightMap[e2]; | |
if (_.isNumber(w1) && _.isNumber(w2)) { | |
return w1 - w2; | |
} else { | |
return 0; |
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() { | |
this.tmpl3 = function tmpl(str, data) { | |
var value = "var out = ''; out+=" + "'" + | |
str.replace(/[\r\t\n]/g, " ") | |
.replace(/'(?=[^%]*%>)/g,"\t") | |
.split("'").join("\\'") | |
.split("\t").join("'") | |
.replace(/<%=(.+?)%>/g, "'; out += $1; out += '") | |
.split("<%").join("';") |
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
'use strict' | |
_ = require 'underscore' | |
# CombinationGenerator ported from Java. | |
# The algorithm is described by Kenneth H. Rosen, Discrete Mathematics and | |
# Its Applications, 2nd edition (NY: McGraw-Hill, 1991), pp. 284-286. | |
# | |
# Simple usage: | |
# combinations(["a", "b", "c", "d", "e"], 3) |
NewerOlder