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
**Please read:** This is a project in progress. Thus, every bug, suggestion, improvement or whatever you want to do to it will be welcome. Once the project is in a decent state, it'll be ported to an independent gem. | |
Description | |
--- | |
AB Tester makes Front End AB Test generation simpler than ever! | |
It allows the developer to create a copy of the Front End of the project based on default assets or on a previously generated test. | |
What AB Tester does is making a copy of the layout file the application is using to load the one-page app (generally, `application.html.haml`) along with the respective css and js manifests, renaming them to the name of the test. |
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 balancedPars(str) { | |
var result = 0; | |
if(typeof(str) !== 'string') return false; | |
if(str) { | |
result = str.split('') | |
.map(function(elem){ | |
return elem === '(' ? 1 : (elem === ')' ? -1 : 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
// LinkedListNode Class (Module pattern with cached functions) | |
!function(){ | |
LinkedListNode = function LinkedListNode(data) { | |
this.node = [data, null]; | |
} | |
LinkedListNode.prototype.getNext = getNext; | |
LinkedListNode.prototype.getData = getData; | |
LinkedListNode.prototype.setNext = setNext; | |
LinkedListNode.prototype.setData = setData; |
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
// Catalan Numbers to mathematically verify number of combinations | |
// E.g, the number of possible combinations of parentheses | |
// http://en.wikipedia.org/wiki/Catalan_number | |
function catalanNumber(numParens) { | |
var total = 1; | |
for(var i = 2; i <= numParens; i++) { | |
total *= (numParens + i) / 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 findAllCombinations(numParens) { | |
var totalCombs = 0; | |
if(numParens > 0) { | |
totalCombs = attachParen('', numParens, numParens, totalCombs); | |
} | |
return totalCombs; | |
} | |
function attachParen(str, open, close, total) { | |
if(open > 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
function bubbleSort (arr) { | |
var l = arr.length, | |
tmp = null, | |
j = l - 1, | |
i; | |
if(l < 2) return arr; | |
for(; j >= 0; j--) { | |
for(i = 0; i < j; 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 mergeSort (arr, st, end) { | |
var res; | |
st = st || 0; | |
end = end || arr.length; | |
if(end - st > 1) { | |
var mid = st + Math.round((end - st)/2); | |
var a1 = mergeSort(arr, st, mid); | |
var a2 = mergeSort(arr, mid, end); | |
res = merge(a1, a2); |
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 quickSort (arr) { | |
if(arr.length <= 1) { | |
return arr; | |
} | |
var pivot = choosePivot(arr); | |
var divider = divide(arr, pivot); | |
var a1 = quickSort(arr.slice(0, divider)); | |
var a2 = quickSort(arr.slice(divider + 1, arr.length)); | |
a1.push(arr[divider]); |
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
// closure | |
(function() { | |
function funcA() {} | |
var funcB = function() {}; | |
funcC = function() {}; | |
})() | |
console.log(typeof funcA); // undefined | |
console.log(typeof funcB); // undefined | |
console.log(typeof funcC); // function |
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
// Class generator | |
var Class = function(parentCls) { | |
var Klass = function() { | |
this.init.apply(this, arguments); | |
}; | |
if(parentCls){ | |
var subClass = function(){}; | |
subClass.prototype = parentCls.prototype; | |
Klass.prototype = new subClass; |
OlderNewer