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
/** | |
* This method gets between a bracket and returns what's between the brackets only | |
* after it's been balanced. This can be done with a regex however is microsecond | |
* optimizations aren't too important then this becomes a more versatile solution which | |
* can accept a multitude of brackets and braces. | |
* @param {String} ob The opening bracket or brace | |
* @param {String} cb The closing bracket or brace | |
* @param {String} str The string containing the brackets | |
* @param {Integer} start The starting index from where to start searching | |
* @example getBetweenBrackets('(',')', 'all_of_this(but((I_want_this)))') |
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 Fraction = { | |
convert: function( value, opts ) { | |
var frac; | |
if( value === 0 ) { | |
frac = [ 0, 1]; | |
} | |
else { | |
if( value < 1e-6 || value > 1e20) { | |
var qc = this.quickConversion( Number( value ) ); | |
if( qc[1] <= 1e20 ) { |
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
/** | |
* Removes the minus sign from the beginning of the string | |
* | |
* @param str | |
* @returns an array with the first item as true if a minus | |
* was found and the string minus the minus sign. | |
*/ | |
function stripSign(str) { | |
// Check if it has a minus sign | |
let hasMinus = str.charAt(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
nerdamer.register({ | |
parent: 'Helper', | |
name: 'withsteps', | |
visible: false, | |
build: function() { | |
var core = this; | |
var operationLog = []; | |
//write a function which would perform the log | |
var log = function(operator, symbol1, symbol2, result, is_first) { | |
if(!is_first) operationLog.pop(); |
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
/** | |
* This function searches an array and its sub-arrays. A condition function can be used | |
* to limit the results | |
* @param {Array} arr | |
* @param {Function} condfn A function with extra conditions | |
* @param {String} prop A hashable property to identify the object when found | |
* @param {Object} c A collector object defined by the function | |
* @returns {Object} An object containing the found objects | |
*/ | |
function countFrequency(arr, condfn, prop, c) { |
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 factors(num, unique) { | |
var l = num, i=1, factors = [], | |
epsilon = 2.2204460492503130808472633361816E-16; | |
while(i<l) { | |
var quotient = num/i; | |
var whole = Math.floor(quotient); | |
var remainder = quotient-whole; | |
if(remainder <= epsilon) { | |
unique && i === whole ? factors.push(i) : factors.push(i, whole); | |
l = whole; |
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($) { | |
$.fn.circularMeter = function() { | |
var defaults = { | |
dimension: 25, | |
'border-width': 25, | |
color: '#ABABAB', | |
'text-color': '#000', | |
'z-index': 99 | |
}; | |
var userOptions = typeof arguments[0] === 'object' ? [].shift.apply(arguments) : defaults; |
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 toNumberPlace = function(n) { | |
var number = String(n), | |
l = number.length, | |
zeroes = l-1, | |
places = []; | |
for(var i=0; i<l; i++) { | |
var digit = Number(number.charAt(i)); | |
places.push(digit * Math.pow(10, zeroes--)); | |
} | |
return places; |
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
/** | |
* Inserts an object into an array at a given index or recursively adds items if an array is given. | |
* When inserting another array, passing in false for unpackArray will result in the array being inserted | |
* rather than its items. | |
* @param {Array} arr - The target array | |
* @param {Array} item - The item being inserted | |
* @param {Number} index - Where to place the item | |
* @param {boolean} unpackArray - Will insert the array instead of adding its items | |
*/ | |
insertArray = Utils.insertArray = function( arr, item, index, unpackArray ) { |
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 min(arr) { | |
var l, a, b; | |
while(true) { | |
l = arr.length; | |
if(l < 2) return arr[0]; | |
a = arr.pop(); | |
b = arr[l-2]; | |
if(a < b) { | |
arr.pop(); | |
arr.push(a); |
OlderNewer