Input:
var someDynamicParam = 9812894732432;
$location.search('myParams', someDynamicParam).path('/request');
Output:
/** | |
* @name xhr | |
* @desc Dynamic $http/$q | |
* @param {String} [type] HTTP method | |
* @param {Array} config Array of config to be called with .apply() | |
* @private | |
* @returns {Object} deferred.promise | |
*/ | |
var xhr = function (type, config) { | |
if (!config && angular.isArray(type)) { |
function $(a,b){return(b||document)['querySelector'+(b=/\:first$/,b.test(a)?'':'All')](a.replace(b,''))} |
var query = function (endpoint) { | |
var deferred = $q.defer(); | |
$http.get(endpoint) | |
.success(function (data) { | |
deferred.resolve(data); | |
}) | |
.error(function (data) { | |
deferred.reject(data); | |
}); | |
return deferred.promise; |
Input:
var someDynamicParam = 9812894732432;
$location.search('myParams', someDynamicParam).path('/request');
Output:
var input = document.querySelector('input[type=password]'); | |
var britishGasPasteHandler = function () { | |
if (window.certificate) { | |
certificate.revoke(); | |
} | |
}; | |
input.addEventListener('paste', britishGasPasteHandler, false); |
<div class="module"> | |
<div class="module__thing"> | |
<h1 class="module__thing-title">Hi</h1> | |
</div> | |
<div class="module__content"> | |
<p class="module__content-text">Oh, hello.</p> | |
</div> | |
</div> |
Function.prototype.bind = Function.prototype.bind || function (target) { | |
var self = this; | |
return function (args) { | |
if (!(args instanceof Array)) { | |
args = [args]; | |
} | |
self.apply(target, args); | |
}; | |
}; |
/^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/ |
window.console.loge = function (msg) { | |
var gifs = ['wink','shake-space','peepers','prizza','hat','gradient','fat','rainbow','sunglasses','derp','shake'], | |
wow = ['', 'wow! ', 'amaze! ', 'dazzle! '], | |
adjs = ['so', 'such', 'many', 'much', 'very'], | |
randomizr = function (a) { return a[Math.floor(Math.random() * a.length)];}, | |
message = '%c ' + randomizr(wow) + randomizr(adjs) + ' ' + typeof msg + ': ', | |
css = 'background: url(http://d1e3ezyatlol8u.cloudfront.net/img/212/doge-' + randomizr(gifs) + '-212.gif) no-repeat 0 0; background-size: 80px 80px; font-family: \'Comic Sans MS\', cursive; text-shadow: 0 1px 1px rgba(0,0,0,1); font-size: 14px; padding: 25px; line-height: 70px; color: #fff; font-weight: 100;'; | |
console.log.apply(console, typeof msg === 'object' ? [message, css, msg] : [message += msg, css]); | |
}; |
var isArray = function (obj) { | |
return Object.prototype.toString.call(obj) === '[object Array]'; | |
}; |