Skip to content

Instantly share code, notes, and snippets.

@staxmanade
staxmanade / merge-wrapper.js
Last active December 1, 2018 02:45
JS & SH merge wrappers
#!/usr/bin/env node
'use strict';
/*
#!/bin/bash
#
# Wrapper script for git mergetool
# This requires ~/.gitconfig file to have
# the following (adjusting for paths):
#
# [merge]
@staxmanade
staxmanade / forEach.js
Last active August 29, 2015 14:12
forEach implementation on the JavaScript Object
Object.prototype.forEach = function(callback) {
var key = 0;
for (key in this) {
if (this.hasOwnProperty(key)) {
if (callback.call(this, key, this[key]) === false) {
break;
}
}
}
return this;
@staxmanade
staxmanade / UIImage+FailFast.h
Created February 12, 2015 17:01
Fail Fast and assert when [UIImage imageNamed:name] cannot load an image
//
// UIImage+FailFast.h
//
// Created by Jason Jarrett on 2/11/15.
// Copyright (c) 2015 Jason Jarrett. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIImage (FailFast)
var recursivelyOrderKeys = function(unordered) {
// If it's an array - recursively order any
// dictionary items within the array
if (Array.isArray(unordered)) {
unordered.forEach(function (item, index) {
unordered[index] = recursivelyOrderKeys(item);
});
return unordered;
}