Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Matthew Stokeley matthewstokeley

🎯
Focusing
View GitHub Profile
@matthewstokeley
matthewstokeley / data-model.md
Last active Apr 29, 2020
data model writeup
View data-model.md

The data model for data-binding

Data models contain the entirety of application state (from the elm-lang guide - "The point of the model is to capture all the details about your application as data." )

An Object Literal

A model could be as simple as a plain javascript object

View key-lookup-strategies.js
// 0.0.2
type Key: Symbol | String
type KeyClosure: Function( str: String ): Key
// Symbol Strategy
export var symbolKeyHandler = function symbolKeyHandler(
_cache: Function
): KeyClosure {
View basic-publish-subscribe-event-object.js
/**
* ------------------------------------------------------------------------
* events.js
*
* ------------------------------------------------------------------------
* a publish/subscribe events object
*/
( function() {
@matthewstokeley
matthewstokeley / single-threaded-processing-in-5-seconds.md
Last active Apr 16, 2020
Single-threaded-processing-in-5-seconds.md
View single-threaded-processing-in-5-seconds.md
// the thread of a processor is like a queue
- - - - -
// processes take various amounts of time to execute
--- -- - ------- -
@matthewstokeley
matthewstokeley / javascript-modules-in-5-seconds.md
Last active Apr 16, 2020
javascript-modules-in-5-seconds.md
View javascript-modules-in-5-seconds.md

wip needs editing

// Google Closure Library
google.require()
// ES6 Modules
import {export} from 'module'
// all
@matthewstokeley
matthewstokeley / javascript-native-array-methods-in-5.md
Last active Apr 16, 2020
javascript-native-array-methods-in-5.md
View javascript-native-array-methods-in-5.md

wip needs editing

// native array methods are functions attached to the prototype of the variadic constructor or object literal, and are inherited via prototypal inheritance
Array.prototype[METHOD].call, [].prototype[METHOD].call, let arr_ = [1,2,3]; arr[METHOD].call
// the common argument pattern for methods is VIA: value, index, array
[].forEach((value, index, array) => value++)
@matthewstokeley
matthewstokeley / inversion-of-control-poc.js
Last active Apr 15, 2020
inversion of control pattern for object-oriented javascript
View inversion-of-control-poc.js
// the simplest possible example of inversion of control
class IOC
{
/*
* @type {string}
*/
classProperty: 'hello world'
constructor(/** Function */ fn) {
@matthewstokeley
matthewstokeley / object-oriented-prototypal-javascript-in-5-seconds.md
Last active Apr 15, 2020
object-oriented-prototypal-javascript-in-5-seconds
View object-oriented-prototypal-javascript-in-5-seconds.md

Prototypal Javascript

// this is like a constructor
const Oopj = function() {}
// inherits or implements a built-in prototype object
console.log(Oopj.prototype);
@matthewstokeley
matthewstokeley / google-list.md
Last active Apr 14, 2020
google prep bookmarks
View google-list.md
@matthewstokeley
matthewstokeley / hasAttr.js
Last active Apr 13, 2020
does an element have an attribute
View hasAttr.js
// has
const hasAttr = ( _el, attr ) => {
if ( ! 'children' in _el || _el.children[ 0 ] ) {
return false;
}
if ( _el.nodeType !== 1) {
return false;
You can’t perform that action at this time.