Skip to content

Instantly share code, notes, and snippets.

View darcher-'s full-sized avatar
💭
Much foo... Such bar.

Dylan Archer darcher-

💭
Much foo... Such bar.
View GitHub Profile
<link rel="dns-prefetch" href="//www.google-analytics.com/">
<zscript>
/*! Google Analytics */
// Instructs analytics.js to use the name `zga`
window.GoogleAnalyticsObject = 'zga';
// Creates an initial analytics() function
// The queued commands will be executed once analytics.js loads
window.zga = window.zga || function() {
(zga.q = zga.q || []).push(arguments)
};
var getURL = function (url, success, error) {
if (!window.XMLHttpRequest) return;
var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState === 4) {
if (request.status !== 200) {
if (error && typeof error === 'function') {
error(request.responseText, request);
}
return;
@darcher-
darcher- / zIncludes.js
Last active February 13, 2018 14:16
Panel and Landing page javascript includes
/* classList Polyfill: https://gist.github.com/k-gun/c2ea7c49edf7b757fe9561ba37cb19ca */ ;
(function() {
var trim = function(s) {
return s.replace(/^\s+|\s+$/g, '');
},
regExp = function(name) {
return new RegExp('(^|\\s+)' + name + '(\\s+|$)');
},
forEach = function(list, fn, scope) {
@darcher-
darcher- / index
Last active April 1, 2018 23:36
Buttons - just some clean minimal buttons - https://jsfiddle.net/t6vpykbp/152/
<div class="btn-group">
<button class="cta-primary" title="Primary"><span>Primary</span><svg class="right-arrow"><use xlink:href="#right-arrow"></use></svg></button><br>
<button class="cta-secondary" title="Secondary"><span>Secondary</span><svg class="right-arrow"><use xlink:href="#right-arrow"></use></svg></button><br>
<a href="#" class="cta-tertiary" title="Tertiary"><span>Tertiary</span><svg class="right-arrow"><use xlink:href="#right-arrow"></use></svg></a>
</div>
<svg xmlns="//www.w3.org/2000/svg" width="0" height="0" display="none"><symbol id="right-arrow" viewBox="0 0 188.88 175.79"><path class="right-arrow" d="M72.9,5.4c7.1-7.1,18.9-7.1,26.2,0l69.4,69.4c7.1,7.3,7.1,19,0,26.2l-69.4,69.4c-7.3,7.3-19,7.3-26.2,0 c-9.4-9.9,11.1-37.6,20.8-62.4H12.2C5.5,108,0,102.4,0,95.8l0-18.7c0-6.8,5.5-12.3,12.2-12.3h80.5C82.6,41.4,64.3,16.4,72.9,5.4z" /></symbol></svg>
@darcher-
darcher- / pick-reduce.js
Last active April 14, 2018 14:46
Pick/Reduce dataObj
console.clear()
const pick = (obj, keys) => keys.map(key => key in obj ? {[key]: obj[key]} : {}).reduce((res, prop) => Object.assign(res, prop), {})
const row = {
'accounts.id': 1,
'client.name': 'John Doe',
'bank.code': 'MDAKW213'
};
@darcher-
darcher- / func.js
Last active September 15, 2018 14:54
Various approaches
console.clear();
/* Block Scope */
{
const blockScope = `Block Scope`;
console.log(blockScope);
}
/* ES5 */
var elements = document.querySelectorAll('div');
callback = (el) => { console.log(el); };
// Spread operator
elements[Symbol.iterator]();
elements.forEach(callback) //[...elements].forEach(callback);
// Array.from()
Array.from(elements, callback) //Array.from(elements).forEach(callback);
console.clear();
// Public
public = function dataset(id, key) {
this.id = id;
this.key = key;
}
//a
getPublic = new public('abc', '123');
/** Looping Arrays */
/* iteration reduction Loops */
var iterations = items.length % 8;
i = items.length - 1;
while (iterations) {
fn(items[i--]);
iterations--;
}
@darcher-
darcher- / es6To5.js
Created October 3, 2018 02:13
es6 > es5 methods
// add support of es6 methods to browsers that support es5
if (!Array.from)
Array.from = function (selector) {
return [].slice.call(selector)
};
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach;