Skip to content

Instantly share code, notes, and snippets.


Matthew Stokeley matthewstokeley

Block or report user

Report or block matthewstokeley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
matthewstokeley / preparation.js
Last active Nov 10, 2019
What if javascript had printf
View preparation.js
// @todo wishlist - isomorphic node-style error handling
const traverse = function() {}
const iterate = (arr) => {
const arr = arr;
const pos = 0;
const next = () => {}
matthewstokeley / environment-specific-event-propagation.php
Last active Nov 19, 2019
environment-specific event-propagation array, call, invoke
View environment-specific-event-propagation.php
// implementation detail
define( 'IS_LOCAL_ENV', true );
function call_env_specific_event_prop(
Callable $method,
) {
if ( ! IS_LOCAL_ENV ) {
View gist:d3a9b3fc92f147c4ab9987d6e41f3367
* Mixin Definition
* @version 1.0.0
@mixin sticky
position: fixed

Examples of brittle code

Highly-specific element selectors -

querySelector('.very .nested .element')

Why is this wrong? Changing the document structure forces refactoring in multiple places.

matthewstokeley /
Last active Oct 23, 2019
Prototype mutability wip

Object or Function prototype mutability is unintuitive, like a key that returns a different letter on each keypress. This points to one of the reasons why patterns like virtualization via proxies and reflection, functional programming's eschewal of side effects, and reactive vue-style object mutation events are commonly used, especially in conjunction with composition techniques.

That is, we expect Function.prototype.apply to invoke a function given context and an array of parameters. We can easily change the method - Function.prototype.apply = ( fn ) => { console.log( fn ) } - it is expectations that are difficult to change.


This is one possible example of object-based prototypal inheritance, using hasOwnProperty to break the prototype chain.

    const _createElement = _proto => {
        let _el = Document.createElement()
        for (var prop in _proto) {
            if (Object.hasOwnProperty(prop)) {
                _el[prop] = _proto[prop]
matthewstokeley /
Last active Nov 7, 2019
annotating the '_.invoke' method from underscore.js

Underscore's invoke method

 *  @version 0.0.1
// Invoke a method (with arguments) on every item in a collection.
matthewstokeley /
Last active Nov 19, 2019
Example PWA manifest

<link rel="manifest" href="/manifest.json">

From the google documentation:

  "short_name": "Maps",
  "name": "Google Maps",
  "icons": [
      "src": "/images/icons-192.png",



An object property

  hero {
You can’t perform that action at this time.