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 (Backtrace) | |
+ (NSString *)appBacktraceOfDepth:(int)depth fromStackSymbols:(NSArray *)frames; | |
+ (NSString *)backtraceOfDepth:(int)depth fromStackSymbols:(NSArray *)frames; | |
+ (NSString *)backtraceOfDepth:(int)depth fromStackSymbols:(NSArray *)frames matching:(NSString *)from; | |
@end | |
#define BACKTRACE_DEPTH(DEPTH) ([[NSThread class] respondsToSelector:@selector(callStackSymbols)] ? [NSObject appBacktraceOfDepth:DEPTH fromStackSymbols:[NSThread callStackSymbols]] : @"") | |
#define CALLSTACK_DEPTH(DEPTH) BACKTRACE_DEPTH(DEPTH) |
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 AsyncOperation : NSOperation | |
@property (nonatomic, assign) BOOL isExecuting; // yes, explicity not '.. getter=isExecuting) BOOL executing' | |
@property (nonatomic, assign) BOOL isFinished; // the KVC keys must be isExecuting & isFinished, with the 'is' | |
typedef void (^FinishBlock)(void); | |
+ (instancetype)asyncOperationWithBlock:(void (^)(FinishBlock finishBlock))block; |
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
@implementation NSDictionary (MapDictKeysContainingPeriods) | |
- (NSDictionary *)dictionaryWithPeriodsInKeysMappedTo:(NSString *)replacement | |
{ | |
NSMutableDictionary *updatedDictionary = [self mutableCopy]; | |
NSAssert1(updatedDictionary != self, @"mutableCopy returned same object pointer: %@", updatedDictionary); // i don't think this ever happens | |
BOOL changed = NO; | |
for (NSString *key in updatedDictionary.allKeys) | |
{ | |
id value = [updatedDictionary objectForKey:key]; |
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://api.login.yahoo.com/oauth/v2/get_request_token?oauth_callback=http%3A%2F%2Flocalhost&oauth_consumer_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx--&oauth_nonce=9D342B75-2A27-4A88-93E5-53DD4AE292F8&oauth_signature=sC0HZuTJySrxLCASwkvzbOwl1J4%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1425086133&oauth_version=1.0 | |
signature is generated from putting these parameters into the base string, in correct sorted order: | |
oauth_callback=http%3A%2F%2Flocalhost& | |
oauth_consumer_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx--& | |
oauth_nonce=53DBBE7A-9A1F-4113-BFD3-26B31547CEA7& | |
oauth_signature_method=HMAC-SHA1& | |
oauth_timestamp=1425324801& | |
oauth_version=1.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
** Generating signature for https://api.login.yahoo.com/oauth/v2/get_request_token | |
** Parameters for base signature string: | |
oauth_callback=http%3A%2F%2Flocalhost& | |
oauth_consumer_key=dj0yJmk9Q1BTWWoxZVd0QlBGJmQ9WVdrOWVGcEVWbWxTTldrbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1hMQ--& | |
oauth_nonce=48FD2DE7-0380-40AA-BF8C-3C61341ACCCE& | |
oauth_signature_method=HMAC-SHA1& | |
oauth_timestamp=1425329590& | |
oauth_version=1.0 | |
** Base signature string: |
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
Verifying I am +jpmhouston on my passcard. https://onename.com/jpmhouston |
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 MixedPOSTHTTPSessionManager : AFHTTPSessionManager | |
- (NSURLSessionDataTask *)POST:(NSString *)URLString | |
parameters:(id)parameters | |
JSONParameters:(NSDictionary *)jsonParameters | |
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success | |
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; | |
@end | |
@implementation MixedPOSTHTTPSessionManager |
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
// call from a view controller's -viewDidLayoutSubviews or -viewWillAppear: | |
// pass it a text field, etc, assign result to that text field's attributedPlaceholder property | |
// note that the maxKerning parameter must be a negative value (a "maximally negative" kerning value) | |
// pro tip: i've sometimes found that a text field still has incorrect bounds in -viewDidLayoutSubviews | |
// and needs to forcibly have its layout done: | |
//- (void)viewDidLayoutSubviews { | |
// [self.field layoutIfNeeded]; | |
// self.field.attributedPlaceholder = [self resizedPlaceholderForField:self.field withPadding:4.0 maxKerningReduction:0.3]; | |
//} |
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
extension Array { | |
func element(at index: Int) -> Element? { | |
return index >= 0 && index < count ? self[index] : nil | |
} | |
} |
OlderNewer