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


A possible implementation of a traversal


  • returning an object instead of the index is idiosyncratic.
  • currently accepts a string
  • strict equality doesn't compare deeply nested properties with objects
  • need to use prototypal inheritance to utilize the hasOwnProperty method in order to properly implement an object equality comparator

Javascipt Context Binding

.bind() is a powerful method for changing or preserving the context and therefore the scope available to an expression.

It can be used to preserve contexts for callbacks that will be invoked and executed in different block scopes, for instance in this closure

const fn = function(fn, ...args) {
  return, ...args)
matthewstokeley / chaining-method.js
Last active May 5, 2019
chain a sequence of functions
View chaining-method.js
const chain = (array, arg) => {
let res = arg
? arg
: ''
for (let i = 0; i < array.length; ++i) {
res = array[i].call(this, res);
return res;
matthewstokeley / gist:182876c47f0b8e40ae61fc2f33080635
Last active Apr 28, 2019
resolvers, discriminators and comparators in php
View gist:182876c47f0b8e40ae61fc2f33080635


Resolvers, Comparators and Discrimimators

These are three 'callables' that are often used as arguments in methods that are built to accept callbacks, like array_filter, usort, or call_user_func_array (similiar to javascript's apply array method, fyi).

It's a really interesting set of functions for many reasons - for one, like map and reduce, the semantics of the methods provide for a discrete and specific role, which makes thinking about code clearer, even though this kind of specificity probably falls under the semantically-shifted category of 'pre-mature optimization'. In any case, let's review.


View gist:1a91a7acabeee07eb98c4cdb43559b16
# create dot files and directories
touch .aliases
echo "alias g=git" >> .aliases
echo "alias c=php composer.phar" >> .aliases
echo "alias p=phpunit" >> .aliases
touch .editorconfig
matthewstokeley / gist:dabac25242713a112f7d9053f7c596c0
Last active Apr 27, 2019
language level features in php for multi-dimensional array sorts
View gist:dabac25242713a112f7d9053f7c596c0
// two methods
// 1. usort
// pros: flexible
// cons: overly specific
function comparator() {
View sorting-utility.php
$arr = [
"key" => "value",
"id" => 1
], [
"key" => "value",
"id" => 0
matthewstokeley / route-loader.js
Created Apr 14, 2019
a barebones, hacky async route loader
View route-loader.js
// barebones and hacky async route loader
window.addEventListener('load', () => {
events.register('click', route);
const route = function(event) {
let module =;
if (module === undefined) module = 'index'
matthewstokeley /
Last active Apr 12, 2019
Three different methods for handling constructors


I've been working on a data mapper for syncing / mutating / preparing data.

The objective is to have a simple api to prepare formdata objects for the persistance layer for use in progressive web applications: formdata -> localstorage -> remote database

ht @vue.js for their style and the vue3.0 object virtualization mutator pattern.

You can’t perform that action at this time.