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
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | |
if (self.tabBarController.selectedViewController == self.navigationController) | |
return NO; | |
else | |
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); | |
} |
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
// Create a pinch gesture recognizer instance. | |
self.pinchGestureRecognizer = [[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGesture:)] autorelease]; | |
// And add it to your text view. | |
[self.myTextView addGestureRecognizer:self.pinchGestureRecognizer]; | |
// ... | |
- (void)pinchGesture:(UIPinchGestureRecognizer *)gestureRecognizer | |
{ |
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 <QuartzCore/QuartzCore.h> | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
UIImage *image = [UIImage imageNamed:@"photo.png"]; | |
UIView *photoView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height)]; | |
photoView.center = CGPointMake(self.view.center.x, self.view.center.y - 10); |
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
- ( NSString *) Description | |
{ | |
NSMutableString * String = [ NSMutableString stringWithString : @ "" ]; | |
unsigned int propertyCount; | |
objc_property_t * Properties = class_copyPropertyList ([ Self class ], & propertyCount); | |
for ( unsigned int I = 0 ; I "propertyCount; I + +) | |
{ | |
NSString * Selector = [ NSString stringWithCString : property_getName (Properties [I]) encoding : NSUTF8StringEncoding ]; | |
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
// A normal singleton | |
static AppInfo * sharedAppInfo = nil; | |
+ (AppInfo *) sharedAppInfo | |
{ | |
if ( sharedAppInfo == nil ) | |
{ | |
[[self alloc] init]; | |
} | |
return sharedAppInfo; |
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 START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; | |
#define END_TIMER(msg) NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; LPLog([NSString stringWithFormat:@"%@ Time = %f", msg, stop-start]); | |
// Example usage | |
- (void)loadStockCodeMaster | |
{ | |
START_TIMER; | |
NSURL *url = [NSURL URLWithString:STOCK_CODE_MASTER_URL]; | |
NSString *stringFile = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil]; | |
END_TIMER(@"loadStockCodeMaster"); |
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
// DataManager.h | |
#import <Foundation/Foundation.h> | |
#import <CoreData/CoreData.h> | |
extern NSString * const DataManagerDidSaveNotification; | |
extern NSString * const DataManagerDidSaveFailedNotification; | |
@interface DataManager : NSObject { | |
} |
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 | |
instance_name = ARGV[0] | |
abort "Please specify an instance name" unless instance_name and instance_name.length > 0 | |
instance_info, selected_instance = {}, nil | |
info_keymap = {2 => :ami_id, 3 => :address, 5 => :status, 6 => :keypair_name} | |
instances = `ec2-describe-instances`.split("\n").map{|l| l.split("\t")} | |
instances.each do |line| |