Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Matthew Stokeley matthewstokeley

🎯
Focusing
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 https://github.com/nodejs/node/blob/master/lib/_http_agent.js
*/
if (called)
return;
called = true;
if (err)
return cb(err)
View filter-branch-notes.md
git filter-branch notes

Summary
	- 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
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
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
<?php
// implementation detail
define( 'IS_LOCAL_ENV', true );
function call_env_specific_event_prop(
Callable $method,
$arg
) {
if ( ! IS_LOCAL_ENV ) {
View gist:d3a9b3fc92f147c4ab9987d6e41f3367
```
/**
*
* Mixin Definition
* @version 1.0.0
*/
@mixin sticky
position: fixed
View brittle-code.md

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
matthewstokeley / prototype-mutability.md
Last active Oct 23, 2019
Prototype mutability wip
View prototype-mutability.md

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.

View prototypal-inheritance.md

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
matthewstokeley / invoke_annotations.md
Last active Nov 7, 2019
annotating the '_.invoke' method from underscore.js
View invoke_annotations.md

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.