Skip to content

Instantly share code, notes, and snippets.

Ben McCormick benmccormick

Block or report user

Report or block benmccormick

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

Keybase proof

I hereby claim:

  • I am benmccormick on github.
  • I am ben_mccormick ( on keybase.
  • I have a public key ASA-PhwIqziP2g1Ycexv29-bEBSVn-qNjgtQRZ0ZLDjIbgo

To claim this, I am signing this object:

benmccormick / mobx-codemod.js
Last active Jun 17, 2018
Mobx Codemod Example
View mobx-codemod.js
module.exports = function (file, api) {
const j = api.jscodeshift;
const buildDecoratorPropertiesFromCurrentObject = currentObj => {
let decoratorProps = []; => {
if (prop.value.type === 'CallExpression' && === 'computed') {
prop.kind = 'get';
let fnBody = prop.value.arguments[0];
benmccormick / projects.txt
Created Jun 11, 2018
Github Top 25 Libraries/Frameworks June 10th 2018
View projects.txt
bootstrap -css
tensorflow - python
react -js
vue -js
d3 - js
react-native -js
angular.js - js
animate.css - css
jquery - js
laravel - php
View params.js
/* takes a list of params in the format
key: 'foo'
value: 'bar'
or an object with key-value params
foo: 'bar'
benmccormick / file.js
Created Dec 24, 2015
Array.prototype functional methods
View file.js
let arr = [1, 2, 3];
function log(item) {
//forEach performs an action on each item
//in an array
arr.forEach(log); //logs 1 2 3 in order
benmccormick / file.js
Created Dec 24, 2015
Super Simple async-await example
View file.js
async function showMessageFromServer() {
let data = await fetch('/get/data.json');
let message = data.json().message;
benmccormick / file.js
Created Dec 24, 2015
Promise Examples
View file.js
//Promises take a function that receives callbacks that can be run when an operation completes
let delay5Seconds = new Promise(function(resolve, reject) {
setTimeout(resolve, 5000);
//You can respond to the results of a successfully resolved Promise using the `then` function
delay5Seconds.then(function() {
console.log('This gets logged 5 seconds later')
benmccormick / file.js
Created Dec 24, 2015
Waiting on multiple async operations using Promises
View file.js
//fetch makes an HTTP request and returns a promise that resolves
//when the file is loaded
let p1 = fetch('/data/file1.json');
let p2 = fetch('/data/file2.json');
let p3 = fetch('/data/file3.json');
Promise.all([p1,p2,p3]).then(function(values) {
//values contains the responses from each of the promises
let [response1, response2, response3] = values;
benmccormick / file.js
Created Dec 24, 2015
Converting callbacks to promises
View file.js
//Backbone.Model's save function is a function that takes callbacks
//for successful or failed saves.
//Normal usage
let model = new Backbone.Model();, {
success: function() {
benmccormick / promises.js
Last active Dec 24, 2015
Promises swallow exceptions
View promises.js
try {
fetch('/some/data').then(function() {
throw 'error';
} catch(e) {
//this code won't be executed
console.log('Exception Caught')
You can’t perform that action at this time.