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
const _ = require('lodash') | |
/** | |
* Deep diff between two object, using lodash | |
* @param {Object} object Object compared | |
* @param {Object} base Object to compare with | |
* @return {Object} Return a new object who represent the diff | |
*/ | |
function difference(object, base) { | |
function changes(object, base) { |
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
https://docs.google.com/presentation/d/19AiyALt7-t5MZLBgTubaJ66njM2GLTO54oOiMG1KAog/edit#slide=id.g13a6caa795_0_7 | |
#define BMTDollarReader(fieldName) \ | |
- (double)fieldName ## Value { \ | |
return BMTCentsToDollars(self.fieldName ## CentsValue); \ | |
} \ | |
\ | |
- (NSNumber *)fieldName { \ | |
return self.fieldName ## Cents ? @(self.fieldName ## Value) : nil; \ | |
} \ |
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
// PLRK_SEL_STRING is for specifying selector (usually property) names to KVC | |
// or KVO methods. | |
// In debug it will generate warnings for undeclared selectors if | |
// -Wunknown-selector is turned on. | |
// In release it will have no runtime overhead. | |
#ifndef PLRK_SEL_STRING | |
#ifdef Debug | |
#define PLRK_SEL_STRING(selName) NSStringFromSelector(@selector(selName)) | |
#else | |
#define PLRK_SEL_STRING(selName) @#selName |
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
+ (Class)viewModelClassForModel:(Class)modelClass { | |
NSString *modelClassString = NSStringFromClass(modelClass); | |
NSInteger suffixLength = [@"Model" length]; | |
NSString *viewModelClassString; | |
NSRange range = NSMakeRange(modelClassString.length - suffixLength, suffixLength); | |
viewModelClassString = [modelClassString stringByReplacingCharactersInRange:range | |
withString:@"ViewModel"]; | |
Class viewModelClass = NSClassFromString(viewModelClassString); | |
if (!viewModelClass) { | |
NSLog(@"Internal Name convention broken."); |
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
// | |
// Signal+Extensions.swift | |
// Khan Academy | |
// | |
// Created by Nacho Soto on 10/1/15. | |
// Copyright © 2015 Khan Academy. All rights reserved. | |
// | |
import ReactiveCocoa | |
import 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
return RACSignal.createSignal({ | |
(subscriber: RACSubscriber!) -> RACDisposable! in | |
return nil | |
}) |
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
@interface UIView (FrameObserver) | |
@end | |
@implementation UIView (FrameObserver) | |
- (void)observerFrame { | |
[self addObserver:self forKeyPath:@"frame" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"bounds" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"transform" options:0 context:NULL]; | |
[self.layer addObserver:self forKeyPath:@"position" options:0 context:NULL]; |
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
- (void)registerKeyboardNotifications { | |
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter]; | |
[dnc addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; | |
[dnc addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; | |
[dnc addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; | |
[dnc addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil]; | |
} | |
- (void)unregisterKeyboardNotifications { |
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
@interface NSObject (category) | |
@property (nonatomic, copy, setter = setObjectInfo:) id objectInfo; | |
@end | |
#import <objc/runtime.h> | |
static char kObjectInfoDictionaryKey; | |
@implementation NSObject (category) |
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
- (void)modifyView:(UIView *)view animated:(BOOL)animated { | |
void (^block)() = ^{ | |
//modify view animation progress | |
}; | |
void (^completion)(BOOL) = ^(BOOL finished){ | |
//modify view completion | |
}; | |
if (animated) { |
NewerOlder