This file contains hidden or 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
#include <CoreFoundation/CoreFoundation.h> | |
void notificationCallback (CFNotificationCenterRef center, | |
void * observer, | |
CFStringRef name, | |
const void * object, | |
CFDictionaryRef userInfo) | |
{ | |
CFShow(CFSTR("Received notification (dictionary):")); | |
// print out user info |
This file contains hidden or 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 "A.h" | |
#import <objc/runtime.h> | |
@implementation A (EatApple) | |
- (void)printAppleOverride | |
{ | |
[self printAppleOverride]; | |
NSLog(@"Eat that Apple"); | |
} |
This file contains hidden or 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
rm -rf `ls /tmp | grep something` |
This file contains hidden or 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
find . -type f -print | xargs grep "some test ..." |
This file contains hidden or 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 Singleton | |
static id _sharedManager; | |
+ (instancetype)sharedManager | |
{ | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
_sharedManager = [[self alloc] init]; | |
}); |
This file contains hidden or 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)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
NSMutableArray *resources = [[NSMutableArray alloc] init]; | |
NSURL *URL = [NSURL URLWithString:@"http://localhost:8080"]; | |
AFHTTPClient *manager = [[AFHTTPClient alloc] initWithBaseURL:URL]; | |
[manager GET:@"/messages" parameters:nil success:^(NSHTTPURLResponse *response, id responseObject) { | |
[resources addObjectsFromArray:responseObject[@"resources"]]; | |
This file contains hidden or 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
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1]; | |
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"]; | |
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]]; | |
Class callerClass = NSClassFromString([array objectAtIndex:3]); |
This file contains hidden or 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
// Set non ARC flag (-fno-objc-arc) for the execution file | |
// http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project | |
// | |
// | |
NSMutableArray *mutableArrayOrginal = [NSMutableArray arrayWithObjects:@"asdasd", nil]; | |
NSLog(@"mutableArrayOrginal address is: %p", mutableArrayOrginal); | |
NSMutableArray *mutableArrayCopy = [mutableArrayOrginal copy]; | |
NSLog(@"mutableArrayCopy address is: %p", mutableArrayCopy); | |
if ([mutableArrayOrginal isEqual:mutableArrayCopy]) { |
This file contains hidden or 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)copyItems:(id)sender { | |
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; | |
NSMutableArray *items = [NSMutableArray arrayWithCapacity:_selectionView.selection.count]; | |
for (TTShapeModelObject *shp in _selectionView.selection) { | |
[item setObject:[NSKeyedArchiver archivedDataWithRootObject:shp] forKey:@"TTShapeModelObject"]; | |
[items addObject:item]; | |
} | |
pasteboard.items = items; |
This file contains hidden or 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 Offer < ActiveRecord::Base | |
belongs_to :offer_type | |
belongs_to :offer_rate | |
belongs_to :city | |
belongs_to :location | |
... | |
end | |