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
/* | |
example: | |
// [1,2,3,4,5,6,7,8] (must be a power of 2 length) | |
var arr = new Foldable([1, 2, 3, 4, 5, 6, 7, 8]); | |
arr.fold( [ "l", "r", "l" ] ); // left, right, left | |
// left |
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 augment = function (base, extra, context) { | |
return (function () { | |
return function () { | |
base.apply(context || this, arguments); | |
extra.apply(context || this, arguments); | |
}; | |
})(); | |
}; | |
// usage |
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
augment = (base, extra, context) -> | |
(-> | |
-> | |
base.apply context or this, arguments_ | |
extra.apply context or this, arguments_ | |
)() |
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
// !!!!! IMPORTANT !!!!!! | |
// this is no longer needed since a helper users/csv generator was added by @psychobunny | |
// commit: https://github.com/designcreateplay/NodeBB/commit/cfa4256df5c2e7d9f0c1969a8098ef8472d2fa93 | |
// in order for this to work | |
// - this JS file needs to be located in: [NodeBB_PATH]/node_modules/_nodebb_get_users_emails | |
// - you must have a working NodeBB installation, with config.json and a running database | |
// USE IT THEN DELETE IT |
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 definitions for demo-gist only | |
// there is also a mock util object below | |
var Meta = {}; | |
var Meta.configs = { | |
// .. other Meta.configs functions, such as set, get, getFields etc... | |
// obviously the function names aren't the best, but I didn't want to override existing ones | |
// sets a config field in the DB, as a stringified JSON if it's an Object or an Array, |
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
// for detailed comments and demo, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381 | |
/* a helper to execute an IF statement with any expression | |
USAGE: | |
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes | |
-- to access any global function or property you should use window.functionName() instead of just functionName() | |
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later | |
<p> | |
{{#xif " name == 'Sam' && age === '12' " }} | |
BOOM |
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 fs = require('fs'); | |
var getModuleShortName = function(giturlORname) { | |
if (giturlORname.indexOf('git://github.com') > -1) { | |
return giturlORname.split('/').pop().split('#')[0]; | |
} | |
return giturlORname.split('@')[0]; | |
}; | |
var searchModulesCache = function(moduleName, callback) { |
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 npm = require('npm'); | |
var fs = require('fs'); | |
var path = require('path'); | |
module.constructor.new_packageMainCache = {}; // own cache | |
// copied from node src | |
function statPath(path) { | |
try { |
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 isNumber = function(n) { | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
}; | |
var getStorage = function(key) { | |
var data = localStorage.getItem(key), | |
ttl = localStorage.getItem(key + '-ttl'), | |
expired = ttl == null ? false : ttl < (new Date()).getTime(); |
OlderNewer