This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef NS_ENUM(NSInteger, JODateComparisonResult) {JODateBefore = -1L, JODateSame, JODateAfter}; | |
typedef NS_ENUM(NSInteger, JONumericalComparisonResult) {JONumericallySmaller = -1L, JONumericallyEqual, JONumericallyGreater}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.mixin({ | |
findKey: function(obj, predicate, context) { | |
var result = null; | |
_.some(obj, function(value, index, list) { | |
if (predicate.call(context, value, index, list)) { | |
result = index; | |
return true; | |
} | |
}); | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define JOAssertEqualsString(a1, a2, description, ...) \ | |
do { \ | |
@try {\ | |
if (![a1 isKindOfClass:[NSString class]] || ![a2 isKindOfClass:[NSString class]]) { \ | |
[self failWithException:([NSException failureInFile:[NSString stringWithUTF8String:__FILE__] \ | |
atLine:__LINE__ \ | |
withDescription:@"%@", [@"Type mismatch -- " stringByAppendingString:STComposeString(description, ##__VA_ARGS__)]])]; \ | |
} \ | |
else { \ | |
if (![a1 isEqualToString:a2]) { \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatPlural(val, singular, plural) { | |
if (val == 1) return val + '' + singular; | |
return val + '' + plural; | |
} | |
function minToStr(time) { | |
if (time >= (60 * 24 * 7)) { | |
var weeks = Math.floor(time / (60 * 24 * 7)); | |
var remaining = Math.floor(time % (60 * 24 * 7)); | |
return formatPlural(weeks, ' week', ' weeks') + ((remaining > 0) ? (', ' + minToStr(remaining)) : ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatPlural(val, singular, plural) { | |
if (val == 1) return val + singular; | |
return val + plural; | |
} | |
function secondsToString(seconds) { | |
var time = Math.round(seconds / 60); | |
if (time >= (60 * 24)) { | |
var days = Math.floor(time / (24 * 60)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array_merge() { | |
// https://github.com/kvz/phpjs/blob/master/functions/array/array_merge.js | |
var args = Array.prototype.slice.call(arguments); | |
var argl = args.length; | |
var arg; | |
var retObj = {}; | |
var k = ''; | |
var argil = 0; | |
var j = 0; | |
var i = 0; |