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 NSString (Additions) | |
- (NSString*)stringByRemovingWhitespace; | |
@property (readonly) NSString *MD5; | |
@end | |
@implementation NSString (Additions) | |
- (NSString*)stringByRemovingWhitespace | |
{ | |
NSCharacterSet *whitespaces = [NSCharacterSet whitespaceCharacterSet]; |
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
CGContextRef ctx = UIGraphicsGetCurrentContext(); // your drawing context | |
CGRect colorRect = CGRectMake(0, 0, 100, 100); // the rect to draw the color overlay into | |
// Set the blend mode to "Normal" | |
// This is the default blend mode setting so this line is not required, shown here for demonstration | |
CGContextSetBlendMode(ctx, kCGBlendModeNormal); | |
// Set the opacity of the drawing context (once again, not required) | |
CGContextSetAlpha(ctx, 1.0); | |
// Create the red color | |
CGColorRef redColor = CGColorCreateGenericRGB(0.908, 0.149, 0.145, 1.000); | |
// Set the fill color of the context and fill the rect |
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 NSView (SNRAdditions) | |
- (void)scrollPointAnimated:(NSPoint)point | |
{ | |
NSScrollView *scrollView = [self enclosingScrollView]; | |
NSClipView *clipView = [scrollView contentView]; | |
NSPoint constrainedPoint = [clipView constrainScrollPoint:point]; | |
[NSAnimationContext beginGrouping]; | |
[[NSAnimationContext currentContext] setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; | |
[[clipView animator] setBoundsOrigin:constrainedPoint]; | |
[NSAnimationContext endGrouping]; |
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)parse | |
{ | |
NSLog(@"Began parsing"); | |
[inputStream open]; | |
/* Read 4 bytes initially to create the push parser context and begin parsing */ | |
NSStreamStatus status = [inputStream streamStatus]; | |
uint8_t buf[4]; | |
NSInteger bytesRead; | |
while (status != NSStreamStatusAtEnd) { | |
if (status == NSStreamStatusError) { |
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)parse | |
{ | |
NSArray *libraryDatabases = [[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.iApps"] objectForKey:@"iTunesRecentDatabases"]; | |
NSURL *libraryURL = (([libraryDatabases count])) ? [NSURL URLWithString:[libraryDatabases objectAtIndex:0]] : nil; | |
assert(libraryURL); | |
const char *libPath = [libraryURL.path UTF8String]; | |
const int min = 4; | |
FILE *fp = fopen(libPath, "r"); | |
assert(fp); | |
char buffer[min]; |
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
static NSString* const kAWSAccessKey = @"__ACCESS__KEY__"; // From AWS Developer portal | |
static NSString* const kAWSSecretKey = @"__SECRET__KEY__"; // From AWS Developer portal | |
static NSString* const kAWSAssociateTag = @"examp-99"; // Can be a bogus tag in the format xxxxx-XX (x being a letter and X being a number) | |
/* NSString category for HMAC and URL string encoding */ | |
@interface NSString (AWSAdditions) | |
- (NSString*)URLEncodedStringForCharacters:(NSString*)characters; | |
+ (NSData*)HMACSHA256EncodedDataWithKey:(NSString*)key data:(NSString*)data; | |
@end |
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 AppDelegate : NSObject | |
@property (nonatomic, assign) NSInteger badgeCount; | |
@end | |
@implementation AppDelegate | |
@synthesize badgeCount; | |
// Override the badgeCount setter to update the dock tile whenever the count is set | |
- (void)setBadgeCount:(NSInteger)count | |
{ |
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 UIView (Autoscroll) | |
- (void)autoscroll:(UITouch*)touch; | |
@end | |
@implementation UIView (Autoscroll) | |
- (void)autoscroll:(UITouch*)touch | |
{ | |
// Pass the autoscroll messages onto the superview until it reaches a view that handles the message | |
// If you want to pass the messages through the responder chain then this category would need to be | |
// implemented on UIResponder instead of UIView and you would call [self.nextResponder autoscroll:touch] |
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 NSWindow (Fullscreen) | |
- (BOOL)isFullscreen; | |
@end | |
@implementation NSWindow (Fullscreen) | |
- (BOOL)isFullscreen | |
{ | |
return ([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask; | |
} | |
@end |
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 NSWindow (Fade) | |
- (IBAction)fadeIn:(id)sender; | |
- (IBAction)fadeOut:(id)sender; | |
@end |
OlderNewer