- Project boilerplate that has all the basics set up including
- Set up CI - or at least provide instructions to make it as painless as possible
- Watch task for linter
- Watch task for unit tests
- Integration test
- Using headless Chrome to do screenshot diffing for CSS regressions
- Precommit hooks and/or CI hooks for prettier
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 clickPromise(el) { | |
// Create pointers for proimse chain methods | |
let _resolve = null | |
let _reject = null | |
const p = new Promise((resolve, reject) => { | |
// Cache the promise chain methods for future use | |
_resolve = resolve | |
_reject = reject |
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
data:text/html, | |
<!-- See https://gist.github.com/svincent/699c0a9027bb6bc8298b076e638718f1/edit --> | |
<a id="link" title="Drag this link onto your bookmark bar to save!">save scratchpad</a> | |
<div id="editor" contenteditable>Type something here!<div>To save, drag the link in the top right onto your bookmark bar.</div></div> | |
<style> | |
:root { | |
--line-height: 1.5em; | |
} | |
* { |
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
export default var Silver = Object.create(Reflect, { | |
// ownEntries has a similar API to Object.entries, but it uses the same | |
// enumeration logic as Reflect.keys | |
ownEntries: { | |
writable: true, | |
enumerable: false, | |
configurable: true, | |
value: function(obj) { | |
return Reflect.ownKeys(obj).map(key => [key, obj[key]]); | |
} |
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
/* | |
I was just reading through Eric Elliott's ["10 Tips for Better Redux Architecture"](https://medium.com/javascript-scene/10-tips-for-better-redux-architecture-69250425af44) and found myself a little thrown by some of his sample code. Rather than justshrug it off, I took a few minutes to break down the pros/cons of his appoach and a couple other implimentations I was kicking around. | |
*/ | |
// Eric's original implimentation | |
const createChat_v1 = ({ | |
id = 0, | |
msg = '', | |
user = 'Anonymous', | |
timeStamp = 1472322852680 |
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
// Generate a random hex string of the specified length | |
var randomHashReadable = function(length = 32) { | |
const hashLength = Math.ceil(length / 2); | |
const buffer = crypto.getRandomValues(new Uint8Array(hashLength)); | |
const hex = [].slice.call(buffer).map(val => val.toString(16).padStart(2, '0')); | |
return hex.join('').substring(0, length); | |
}; | |
var randomHash = (length = 32) => { | |
return hex = [].slice.call(crypto.getRandomValues(new Uint8Array(Math.ceil(length / 2)))).map(val => val.toString(16).padStart(2, '0')).join('').substring(0, length); |
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
const VOID = Symbol('VOID'); | |
class LinkedItem { | |
constructor(value) { | |
this.value = value; | |
this.next = null; | |
} | |
} | |
class LinkedList { |
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
// Open http://reactivex.io/rxjs/manual/overview.html to run this code | |
var timer = new Rx.Observable((obs) => { | |
var counter = 0; | |
var int = setInterval(() => obs.next(++counter), 1000); | |
return () => { | |
clearInterval(int); | |
obs.complete(); | |
} | |
}); |
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
// TODO: I was going through various alternative forms when I realized I was spending too much time on this. | |
let data = { | |
"a": "alpha", | |
"b": "beta,", | |
"c": "gamma", | |
"d": "delta", | |
"e": "epsilon", | |
"g": "eta", | |
"h": "theta", |
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
// PCENChar comes from the Custom Element spec | |
// PCEN = Potential Custom Element Name | |
// https://www.w3.org/TR/custom-elements/#custom-elements-core-concepts | |
const PCEN_CHAR = /[-a-z._0-9\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u10000-\uEFFFF]/ | |
const VALID_PCEN = new RegExp(`^[a-z]${PCEN_CHAR.source}*-${PCEN_CHAR.source}*$`) | |
const CAPS = /([A-Z])/g | |
const INNER_CAPS = /((?!^|[a-z]))([A-Z])/g | |
function classNameToElementName(Class) { |