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
View gist:ee755219bc76db05f8e87a4625e6b4bc
* @link
if (called)
called = true;
if (err)
return cb(err)
git filter-branch notes

	- Rewrite git revision history
		- Applicable to `rev-list` branches
		- Only rewritepositive refs
		- Recommitted without any changes, unless filter is specified
		- Honors `.git/info/grafts` and refs in `refs/replace/`
		- Original refs written in `refs/original/`
matthewstokeley / preparation.js
Last active Dec 10, 2019
What if javascript had printf - pdo-style api
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 21, 2019
environment-specific event-propagation would you rather 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.
You can’t perform that action at this time.