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
| console.log ('Input some code:'); | |
| process.stdin.resume(); | |
| process.stdin.setEncoding('utf8'); | |
| process.stdin.once('data', function (someCode) { | |
| process.stdin.pause(); | |
| console.log ('Code: ' + someCode); | |
| }); |
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
| // Trim them | |
| for (UIView* v in self.view.subviews) { | |
| if ([v isKindOfClass:[UITextField class]]) { | |
| UITextField* tf = (id)v; | |
| tf.text = [tf.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; | |
| } | |
| } |
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
| // BabyTapGesture.h | |
| // Created by Chris ([email protected]) on 21/06/11. | |
| #import <Foundation/Foundation.h> | |
| #import <UIKit/UIGestureRecognizerSubclass.h> | |
| @interface BabyTapGesture : UIGestureRecognizer | |
| @end | |
| ---- |
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
| // WeakReferenceSet.h | |
| // Created by [email protected] on 21/06/11. | |
| #import <Foundation/Foundation.h> | |
| @interface WeakReferenceSet : NSObject | |
| + (WeakReferenceSet*)set; | |
| - (void)addObject:(id)object; | |
| - (void)removeObject:(id)object; |
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
| typedef unsigned char byte; | |
| #define Clamp255(a) (a>255 ? 255 : a) | |
| + (UIImage*) fromImage:(UIImage*)source toColourR:(int)colR g:(int)colG b:(int)colB { | |
| // Thanks: http://brandontreb.com/image-manipulation-retrieving-and-updating-pixel-values-for-a-uiimage/ | |
| CGContextRef ctx; | |
| CGImageRef imageRef = [source CGImage]; | |
| NSUInteger width = CGImageGetWidth(imageRef); | |
| NSUInteger height = CGImageGetHeight(imageRef); |
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
| #if TARGET_IPHONE_SIMULATOR | |
| #import <objc/objc-class.h> | |
| // http://cocoawithlove.com/2008/02/imp-of-current-method.html | |
| IMP impOfCallingMethod(id lookupObject, SEL selector) | |
| { | |
| NSUInteger returnAddress = (NSUInteger)__builtin_return_address(0); | |
| NSUInteger closest = 0; | |
| // Iterate over the class and all superclasses |
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
| // For detecting taps outside of the alert view | |
| -(void)tapOut:(UIGestureRecognizer *)gestureRecognizer { | |
| CGPoint p = [gestureRecognizer locationInView:self]; | |
| if (p.y < 0) { // They tapped outside | |
| [self dismissWithClickedButtonIndex:0 animated:YES]; | |
| } | |
| } | |
| -(void) showFromTabBar:(UITabBar *)view { | |
| [super showFromTabBar:view]; |
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
| - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | |
| // Firstly, we want to figure out who is the currently visible view controller. | |
| // There are 4 possibilities here: | |
| // 1- They could be a non-nav controller, with a visible tab (ie not under the 'more' tab) | |
| // Simple: self.selectedViewController | |
| // 2- They could be a nav controller, with a visible tab (ie not under the 'more' tab) | |
| // Get it's visible view: self.selectedViewController.visibleViewController | |
| // 3- They could be a non-nav controller, under the 'more' tab | |
| // Simple: self.selectedViewController | |
| // 4- They could be a nav controller, under the 'more' tab |