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
@matthewstokeley
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
matthewstokeley / environment-specific-event-propagation.php
Last active Nov 19, 2019
environment-specific event-propagation 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.
@matthewstokeley
matthewstokeley / manifest.json.md
Last active Nov 19, 2019
Example PWA manifest
View manifest.json.md

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

From the google documentation:

{
  "short_name": "Maps",
  "name": "Google Maps",
  "icons": [
    {
      "src": "/images/icons-192.png",
View graphql-api.md

Queries

Fields

An object property

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