Skip to content

Instantly share code, notes, and snippets.

Morgan Roderick mroderick

Block or report user

Report or block mroderick

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
mroderick /
Last active Jul 18, 2018
Firefox debugger bug

Firefox debugger bug

When using the debugger and re-using an argument name in a chain of promises, the debugger displays the second argument as undefined().

Try running the examples in Firefox and compare what the debugger displays about the argument to the second callback.

mroderick / sinon-array-test.js
Created Aug 9, 2017
A sample which shows that you cannot stub the `Array.prototype.filter` method. All works fine for ``.
View sinon-array-test.js
'use strict';
const sinon = require( 'sinon' );
const expect = require( 'chai' ).expect;
describe( 'Array.prototype', () => {
describe( 'map()', () => {
it( 'uses native map', () => {
const callback = sinon.spy();
const stub = sinon.stub( Array.prototype, 'map' ).returns( [ 2, 4 ] );

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone<hash>.git # with https
    git clone<hash>.git     # or with ssh
mroderick / test-with-error.js
Last active Feb 24, 2016
How can I get mocha to fail on exceptions?
View test-with-error.js
describe('this should cause tests to fail', function(){
// this will cause an exception
// causing mocha to ignore this whole file
var hello = JSON.parse('{"hello":}');
it('should something', function(){
// magic
assert.equal(true, true);
mroderick /
Last active Feb 3, 2017
My current git pre-commit hook script for linting staged changes with ESLint
# if there are no staged changes, we can exit immediately
# this is fast and prevents issues when popping a stash we didn't create
STAGED_CHANGES=`git diff-index --cached HEAD --name-only --diff-filter ACMR`
if [ -z "$STAGED_CHANGES" ]; then
exit 0
mroderick /
Last active Oct 27, 2017
Frontend Curriculum
mroderick /
Created Aug 26, 2015
A list of recommendations for Copenhagen, Denmark

Things to do in Copenhagen

I get asked for recommendations for Copenhagen often enough, that this little document is now a thing.

Please give back by contributing to it.


  • Visit Copenhagen
  • CopenhagenCard - this seems like a good deal. Put it on smartphone, and have it ready on * arrival... there's a list of attractions included
  • Arken - Museum of modern art
mroderick /
Last active Aug 29, 2015
I was asked for favourite food blogs, networks, etc.
mroderick / stringify-tip.js
Created Apr 15, 2015
Readable output from JSON.stringify
View stringify-tip.js
var o = {hello:'world', greetings: ['one', 'two', 'three']};
// regular, difficult to read for large objects
// presto!
JSON.stringify(o, '', ' ');
mroderick /
Last active Jul 12, 2019
A small script to find stale branches
# This is a very naive script, it doesn't do grouping and returns all branches
# I only really care about branches that have not seen commits in two months
# I am hoping to find some time to write a tool that can output these reports for me
# In the meantime, I am using this
echo "Merged branches"
for branch in `git branch -r --merged | grep -v HEAD`;do echo -e `git log --no-merges -n 1 --format="%ci, %cr, %an, %ae, " $branch | head -n 1` \\t$branch; done | sort -r
You can’t perform that action at this time.