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 result = []; | |
(function dfs(set, len, stack) { | |
if(len === 0) | |
return result.push(Array.prototype.map.call('metadata', function(x, i) { | |
return i%2 ? stack[i>>1] : x; | |
}).join('')); | |
for(var i = 0; i < set.length; dfs(set, len-1, (stack || []).concat(set[i++]))); | |
}(['a', 'e', 'i', 'o', 'u', 'y'], 4)) |
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
#!/bin/sh | |
if [ "$#" -ne 3 ] || ! [ -f "$1" ]; then | |
# usage | |
echo "$(basename $0) [file] [offset] [bytes]" | |
exit 1 | |
fi | |
bytes=$(printf "$3" | xxd -p) | |
printf $bytes | xxd -r -p | dd of="$1" seek=$(( $2 )) count=$(( ${#bytes} / 2 )) bs=1 conv=notrunc &> /dev/null |
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
/** | |
* Creates an array in which each value stored in the array represets the value's index (zero-based). | |
* @param {number} len - Length of array to produce. | |
* @returns {array} The resulting array. | |
*/ | |
function arrayOfNumbers(len) { | |
/* | |
* You could replace Number with eval and save 2 additional bytes, | |
* however that is less secure and probalby not worth the 2 bytes. | |
* |
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
define( | |
'EventEmitter', | |
function() { | |
'use strict'; | |
/** | |
* Parse event types into topic and filters. | |
*/ | |
function parseEvent(event) { | |
event = event.split('.'); |
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
define( | |
'Observer', | |
[ | |
'EventEmitter' | |
], | |
function(EventEmitter) { | |
'use strict'; | |
function copyValue(value) { | |
if (typeof value === 'object') { |
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
define( | |
'observer', | |
[ | |
'EventEmitter' | |
], | |
function(EventEmitter) { | |
'use strict'; | |
var OBSERVER_KEY = '_isObserver', | |
isStandardDefineProperties = 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
(function() { | |
var moduleList = [] | |
module, | |
key; | |
if (typeof requirejs !== 'undefined') { | |
console.groupCollapsed('%cRequire.js v%s module list', 'color: #0080ff; font: 1.4em Menlo, monospace', requirejs.version); | |
for (key in requirejs.s.contexts._.defined) { | |
module = requirejs.s.contexts._.defined[key]; | |
moduleList.push({ |
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
/** | |
* Factory to take some of the boilerplate out of creating constructors | |
* which instantiate objects even without the new keyword. | |
* @param {function} fn - Input function to create constructor from. | |
* @returns The updated constructor. | |
*/ | |
function constructorFactory(fn) { | |
if (typeof fn !== 'function') { | |
throw new TypeError('Expected function!'); | |
} |
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
/** | |
* Calculate the annual contributions required to reach a desired future value. | |
* @param {number} P - Current principle value. | |
* @param {number} FV - Desired future value. | |
* @param {number} r - Rate of return. | |
* @param {number} Y - Years of growth. | |
* @returns {number} Annual contribution. | |
*/ | |
function annualContributions(P, FV, r, Y) { | |
var z = 1 + r; |
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
/** | |
* Creates a string using indexed format string | |
* @param {string} Format of string | |
* @param {...string} One or more strings to be using in the format | |
*/ | |
function formatString(/* ... */) { | |
var args = Array.apply(0, arguments); | |
return args.shift().replace(/\{(\d+)\}/g, function(match, index) { | |
return index < args.length | |
? args[index] |
OlderNewer