Skip to content

Instantly share code, notes, and snippets.

👋
Available for hire

Jamie Mason JamieMason

👋
Available for hire
Block or report user

Report or block JamieMason

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
@JamieMason
JamieMason / tree-walk-deep-traverse-generator.md
Last active Jan 13, 2020
JavaScript Generator function to deeply traverse JSON-Encodable data
View tree-walk-deep-traverse-generator.md

JavaScript Generator function to deeply traverse JSON-Encodable data

Helpers

const isArray = value => Array.isArray(value);
const isObject = value => Object.prototype.toString.call(value) === '[object Object]';

walkTree

@JamieMason
JamieMason / proxy-dom.md
Last active Dec 24, 2019
Use JavaScript Proxy to log DOM APIs
View proxy-dom.md

Use JavaScript Proxy to log DOM APIs

Find out which DOM APIs your code is using with Proxy and Webpack.

Files

src/components/App.js

View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@JamieMason
JamieMason / generators-and-async-generators.js
Created Oct 23, 2019
JavaScript Generators and Async JavaScript Generators
View generators-and-async-generators.js
const sleep = secs => new Promise(done => setTimeout(done, secs * 1000));
function* myGenerator() {
const array = [1, 2];
while (array.length) {
yield array.shift();
}
}
View sleep.js
const sleep = secs => new Promise(done => setTimeout(done, secs * 1000));
View is-async-function.js
const isAsyncFunction = fn => typeof fn === 'function' && fn.constructor.name === 'AsyncFunction';
View is-promise-like-js
const isPromiseLike = obj =>
obj !== null &&
(typeof obj === 'object' || typeof obj === 'function') &&
typeof obj.then === 'function';
@JamieMason
JamieMason / to-oxford-comma.md
Created Sep 26, 2019
Format JavaScript Array of Strings to Oxford Comma.
View to-oxford-comma.md

Format JavaScript Array of Strings to Oxford Comma

const toOxfordComma = array =>
  array.length > 2
    ? array
        .slice(0, array.length - 1)
        .concat(`and ${array.slice(-1)}`)
        .join(', ')
    : array.join(', ');
@JamieMason
JamieMason / USAGE.md
Created Sep 9, 2019
Get Paths To Files In A Git Repository
View USAGE.md

Get Paths To Files In A Git Repository

Commands

added_in_branch

Files added (not modified or deleted) in our branch.

added_in_git_stage

Files added (not modified or deleted) in git add.

in_git_stage

Files in git add.

@JamieMason
JamieMason / GET_ALL_CHANGES_FROM_GIT_FOR_THE_CURRENT_USER.md
Last active Aug 29, 2019
Get all changes from Git for the current User/Developer/Author/Committer
View GET_ALL_CHANGES_FROM_GIT_FOR_THE_CURRENT_USER.md

Get all changes from Git for the current Author

  1. Get the Email of the current User/Developer/Author/Committer.
  2. Resolve the Email through the Git Mailmap.
  3. Get all files they have ever created or modified.
  4. Get all files modified in the current branch compared to master.
  5. Some files they've modified could have since been deleted by someone else, so filter out files which no longer exist.

Use Case

You can’t perform that action at this time.