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
/** | |
* Expose Angular Methods | |
* @desc Exposes | |
* @private | |
* @param {string} namespace - Namespace to append to window.ng (ex: ng.WidgetComponent) | |
* @param {...string[]} member | |
* @example | |
* //////////////// | |
* // Usage Example | |
* //////////////// |
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
// Pure JavaScript | |
function selectToCollection(selector, asJson) { | |
var options = Array.from(document.querySelector(selector).querySelectorAll('option')); | |
var collection = options.reduce((prev, curr) => { | |
return [...prev, { label: curr.label, value: curr.value}]; | |
}, []); | |
return (asJson === true) ? JSON.stringify(collection) : collection; | |
} | |
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
// FIND REGEX | |
(\s+)\w+ (\w+)\(.*\).*{ | |
// REPLACE | |
$0\n$1 console.log('METHOD:: $2 Invoked'); |
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
/** | |
* Domain Model: Boilerplate Example for Angular | |
* @description Class Model through Composition (looser coupling, higher cohesion) | |
* @note $cacheFactory mimics proper inheritance through uniquely indexed references | |
* @author Timothy A. Perez <tim.adam.perez@gmail.com> | |
*/ | |
'use strict'; | |
(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
/** | |
* Lodash Mixin Util: isSet | |
* @description Returns flag whether value is - undefined null, empty string, empty array, or empty object | |
* @param {*} val - Value to Check | |
* @author Timothy A. Perez <tim.adam.perez@gmail.com> | |
*/ | |
(function () { | |
function isSet(val) { | |
return (! ((_.isUndefined(val) || val === null) || (_.isArray(val) && val.length === 0) || (_.isObject(val) && _.isEmpty(val)) || (_.isString(val) && val === '')) ); | |
} |
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
/** | |
* Predictable Random - Is Random Truly Random? | |
* @description - Not the cleanest code, but more of a proof of concept quick flesh out. | |
* @author Timothy A. Perez <tim.adam.perez@gmail.com> | |
*/ | |
/////////////////////////////////////////////////// | |
var sampleTest = (function a(limit, last, r, i, repeatLog) { | |
if (!limit) { | |
console.log('Result: ', repeatLog); | |
repeatLog = null; |
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
/////////////////// | |
// INITIAL SETUP | |
/////////////////// | |
/* | |
// On VF page, pass Session_ID to Client | |
var SESSION_ID = '{!$Api.Session_ID}'; | |
*/ | |
/////////////////// | |
// Angular Module |
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
/** | |
* Adds a {@code getInstance} static method that always return the same instance | |
* object. | |
* @param {!Function} ctor The constructor for the class to add the static | |
* method to. | |
*/ | |
function addSingletonGetter(ctor) { | |
ctor.getInstance = function() { | |
if (ctor.instance_) { | |
return ctor.instance_; |
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 x = 'b'; | |
var y = 'd'; | |
var caseHandlers = { | |
'a': caseHandlerMethod1, | |
'b': caseHandlerMethod2, | |
'c': caseHandlerMethod3, | |
'default': defaultHandlerMethod | |
}; | |
switch2(caseHandlers,x); |
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 JS_LIB = { | |
ANGULAR: 'https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js', | |
JQUERY: 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', | |
LODASH: 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.js' | |
} | |
// Inject jQuery & Lodash | |
function injectAndRun(lib, callback) { | |
(function(d, script) { | |
script = d.createElement('script'); |
NewerOlder