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
#import <Foundation/Foundation.h> | |
typedef BOOL(^NSArrayDiffMatch)(id _Nonnull original, id _Nonnull comparedTo); | |
@interface NSArrayDiff : NSObject | |
+ (instancetype _Nonnull)newWithOriginal:(NSArray * _Nonnull)original | |
diffedAgainst:(NSArray * _Nonnull)compareTo | |
match:(NSArrayDiffMatch _Nonnull)match; |
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
-module(calculator). | |
-export([sum/1, sum/2, factorial/1, factorial/2]). | |
sum(N) when N > 0 -> | |
sum(N, 0). | |
sum(N, Current) when N > 0 -> | |
sum(N-1, Current+N); | |
sum(0, Current) -> |
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
defmodule Standard do | |
def fib(0), do: 0 | |
def fib(1), do: 1 | |
def fib(n), do: fib(n-1) + fib(n-2) | |
end | |
defmodule Optimized do | |
def fib(0), do: 0 | |
def fib(1), do: 1 | |
def fib(1, current, _), do: current |
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)tapCellWithName:(NSString *)name inTableViewWithAccessibilityLabel:(NSString *)accessibilityLabel { | |
[tester runBlock:^KIFTestStepResult(NSError *__autoreleasing *error) { | |
UITableView *tableView = (UITableView *)[tester waitForViewWithAccessibilityLabel:accessibilityLabel]; | |
NSIndexPath *foundIndexPath = nil; | |
for (int section = 0; section < tableView.numberOfSections; section++) { | |
for (int row = 0; row < [tableView numberOfRowsInSection:section]; row++) { | |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; | |
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; | |
if ([cell.textLabel.text isEqualToString:name]) { | |
foundIndexPath = indexPath; |
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
long long ago; /* in a galaxy far far away */ | |
// Replaces with spaces the braces in cases where braces in places cause stasis | |
$str = str_replace(array("\{","\}")," ",$str); | |
#define TRUE FALSE //Happy debugging suckers | |
// sometimes I believe compiler ignores all my comments | |
// I am not sure if we need this, but too scared to delete. |
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)animateConstraints { | |
[self setNeedsUpdateConstraints]; | |
[UIView animateWithDuration:0.4 animations:^{ | |
[self layoutIfNeeded]; | |
}]; | |
} |
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
#import <Foundation/Foundation.h> | |
@interface NSObject (Swizzling) | |
- (void)swizzleMethod:(SEL)originalSelector toMethod:(SEL)newSelector; | |
@end |
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
// Declare this property in your header / private header | |
@property (nonatomic, strong) NSMutableArray *updatingConstraints; | |
- (void)updateConstraints { | |
if (self.updatingConstraints) { | |
[self removeConstraints:self.updatingConstraints]; | |
} | |
self.updatingConstraints = [NSMutableArray array]; | |
// Create and add all of your constraints here |
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
#import <UIKit/UIKit.h> | |
@interface UIStoryboard (LDMain) | |
+ (instancetype)mainStoryboard; | |
@end |