Skip to content

Instantly share code, notes, and snippets.

View murrayju's full-sized avatar

Justin Murray murrayju

View GitHub Profile

Keybase proof

I hereby claim:

  • I am murrayju on github.
  • I am murrayju (https://keybase.io/murrayju) on keybase.
  • I have a public key ASA6dHkV-wvQ9t6KHMr8D7QVIw6pbNl_cWwWX5KqaZjCgQo

To claim this, I am signing this object:

@murrayju
murrayju / stableSort.coffee
Last active August 29, 2015 14:22
Using Array.prototype.sort to implement a stable sort
define [], () ->
Array.prototype.unstableSort = Array.prototype.sort
Array.prototype.sort = (compareFn) ->
compareFn ?= (a, b) -> a?.toString?()?.localeCompare?(b?.toString?()) || 0
list = ({ pos: i, val: v} for v, i in this)
list.unstableSort (a, b) ->
comp = compareFn(a.val, b.val)
@murrayju
murrayju / xmlDiff.js
Created June 10, 2015 17:53
xmlDiff helper method for Jasmine, using prettydiff
util.xmlDiff = function (orig, diff) {
expect(typeof orig).toEqual('string');
expect(typeof diff).toEqual('string');
var source = prettydiff({
source: orig,
lang: 'markup',
mode: 'minify'
});
var changedDoc = prettydiff({
source: diff,