Skip to content

Instantly share code, notes, and snippets.

View mroderick's full-sized avatar

Morgan Roderick mroderick

View GitHub Profile
@mroderick
mroderick / keybase.md
Created August 5, 2014 07:38
keybase.md

Keybase proof

I hereby claim:

  • I am mroderick on github.
  • I am mrgnrdrck (https://keybase.io/mrgnrdrck) on keybase.
  • I have a public key whose fingerprint is 3ABC 8817 CF95 2AF1 78E1 0115 19F2 57E0 CF18 1A69

To claim this, I am signing this object:

Using named constructors

The general usage of a Backbone class is to use the .extend method providing an .initialize method.

var MyView = Backbone.View.extend({
  initialize: function () {
    // Setup object.
 }
@mroderick
mroderick / find-old-branches.sh
Last active June 11, 2024 12:15
A small script to find stale branches
#!/bin/bash
# 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
@mroderick
mroderick / stringify-tip.js
Created April 15, 2015 10:20
Readable output from JSON.stringify
var o = {hello:'world', greetings: ['one', 'two', 'three']};
undefined
// regular, difficult to read for large objects
JSON.stringify(o);
"{"hello":"world","greetings":["one","two","three"]}"
// presto!
JSON.stringify(o, '', ' ');
"{
@mroderick
mroderick / favourite-food-blogs.md
Last active August 29, 2015 14:27
I was asked for favourite food blogs, networks, etc.
@mroderick
mroderick / copenhagen-recommendations.md
Created August 26, 2015 05:34
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.

General

  • 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
mroderick / frontend-curriculum.md
Last active October 27, 2017 10:38
Frontend Curriculum
@mroderick
mroderick / eslint-pre-commit.sh
Last active April 28, 2021 14:27
My current git pre-commit hook script for linting staged changes with ESLint
#!/bin/bash
# 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
fi
@mroderick
mroderick / test-with-error.js
Last active February 24, 2016 09:23
How can I get mocha to fail on exceptions?
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);
})
});

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 https://gist.github.com/<hash>.git # with https
    git clone [email protected]:<hash>.git     # or with ssh