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)viewWillAppear:(BOOL)animated | |
{ | |
[UIView animateWithDuration:animated ? 0.25f : 0.0f animations:^ | |
{ | |
// Some manipulation | |
} completion:^ | |
{ | |
// Some completion action | |
}] | |
} |
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)bindLifetimeToObject:(id)object | |
{ | |
objc_setAssociatedObject(object, (__bridge void *)self, self, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | |
} | |
- (void)releaseLifetimeFromObject:(id)object | |
{ | |
objc_setAssociatedObject(object, (__bridge void *)self, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | |
} |
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
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'openssl' | |
# Track public available information of a twitter user like follower, follower | |
# and tweet count by scraping the user profile page. | |
# Config | |
# ------ | |
twitter_username = ENV['TWITTER_USERNAME'] || 'foobugs' |
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
# For training rest 5 min on compounds, 3-5 minutes on smaller ones | |
# Training A (first set to failure, second set -10% weight + 1 rep): | |
# Deadlift - 2x4-5 | |
# Overhead Press - 1x6-8 | |
# Weighted Chinup - 2x4-6 | |
# Chest-Supported Rows - 2x6-8 | |
# Close-grip chinup - 1x6-10 | |
# Training B (first set to failure, second set -10% weight + 1 rep): |
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 A : NSObject | |
- (void)doThingWithObject:(id)o completion:(void(^)(void))completionHandler; | |
@end | |
@implementation A | |
- (void)doThingWithObject:(id)o completion:(void(^)(void))completionHandler | |
{ | |
NSLog(@"object: %@", o); |
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
Wrong: | |
__weak id obj; | |
dispatch_async(queue, ^() { | |
[obj doSomething]; | |
[obj doSomethingElse]; <- can turn to nil at any point, should store in strong at beggining of block | |
[obj doSomethingElse2]; | |
}); | |
Ok: |
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
With 10.8 SDK, `#define OBJC_OLD_DISPATCH_PROTOTYPES 0` at the top of your file or PCH to get errors if you use objc_msgSend without a cast. |
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, kErrorCode) { | |
kErrorCodeInternal = 431432, | |
}; | |
//! generate error and log it. | |
extern NSError *pixle_NSErrorMake(NSString *message, NSUInteger code, NSDictionary *aUserInfo, SEL selector); | |
#define AssertTrueOrReturnBlock(condition, block) do{ NSAssert((condition), @"Invalid condition not satisfying: %s", #condition);\ | |
if(!(condition)) { block(pixle_NSErrorMake([NSString stringWithFormat:@"Invalid condition not satisfying: %s", #condition], kErrorCodeInternal, nil, _cmd)); return;} }while(0) | |
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
expr -- (void)printf("[%s, %s]\n",(char *) object_getClassName(*(long*)($esp+4)), (char *) *(long *)($esp+8) ) |
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 SafeCall(arg, methodToCall) (arg !=[NSNull null]) ? [arg methodToCall] : nil | |
int optionalValue = SafeCall([response valueForKey:@"number"], intValue); |