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 bitmapContext = CGBitmapContextCreate(NULL, | |
rect.size.width, | |
rect.size.height, | |
CGImageGetBitsPerComponent(imageRef), | |
CGImageGetBytesPerRow(imageRef), | |
CGImageGetColorSpace(imageRef), | |
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little); |
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
- (void)dealloc { | |
[percentGender release]; | |
[percentHisto release]; | |
[percentPS release]; | |
[percentSmoke release]; | |
[percentGender dealloc]; | |
[percentHisto dealloc]; | |
[percentPS dealloc]; | |
[percentSmoke dealloc]; | |
percentGender = nil; |
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
//! for gesture recognizer support in cocos2d use https://github.com/krzysztofzablocki/CCNode-SFGestureRecognizers | |
- (void)handlePanGesture:(UIPanGestureRecognizer*)gestureRecognizer | |
{ | |
CGPoint location = [[CCDirector sharedDirector] convertToGL:[gestureRecognizer locationInView:gestureRecognizer.view]]; | |
static CGPoint oldLocation; | |
//! this will make sure that oldLocation is initialized | |
if (gestureRecognizer.state != UIGestureRecognizerStateBegan) { | |
//! we need to calculate angle difference between previous position and current one in regards to dial center | |
CGPoint firstDir = ccpSub(oldLocation, dial.position); |
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
// Created by Krzysztof Zabłocki | |
@interface UITableViewCell (representedObject) | |
@property (nonatomic, strong) id representedObject; | |
@end | |
#import "UITableViewCell+representedObject.h" | |
#import <objc/runtime.h> | |
static char RepresentedObjectKey; |
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
+ (UIImage *)decompressedImageWithImage:(UIImage *)image resizeTo:(CGSize)targetSize | |
{ | |
CGImageRef imageRef = image.CGImage; | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef); | |
BOOL sameSize = NO; | |
if (CGSizeEqualToSize(targetSize, CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)))) { | |
targetSize = CGSizeMake(1, 1); | |
sameSize = YES; | |
} |
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
[UIView transitionWithView:cell.imageView duration:0.25f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ | |
cell.imageView.image = decompressedThumbnail; | |
} completion:nil]; |
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
-(float) get_free_memory { | |
mach_port_t host_port; | |
mach_msg_type_number_t host_size; | |
vm_size_t pagesize; | |
host_port = mach_host_self(); | |
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); | |
host_page_size(host_port, &pagesize); | |
vm_statistics_data_t vm_stat; | |
if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) { |
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 SafeCall(arg, methodToCall) (arg !=[NSNull null]) ? [arg methodToCall] : nil | |
int optionalValue = SafeCall([response valueForKey:@"number"], intValue); |
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
expr -- (void)printf("[%s, %s]\n",(char *) object_getClassName(*(long*)($esp+4)), (char *) *(long *)($esp+8) ) |
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
typedef NS_ENUM(NSInteger, kErrorCode) { | |
kErrorCodeInternal = 431432, | |
}; | |
//! generate error and log it. | |
extern NSError *pixle_NSErrorMake(NSString *message, NSUInteger code, NSDictionary *aUserInfo, SEL selector); | |
#define AssertTrueOrReturnBlock(condition, block) do{ NSAssert((condition), @"Invalid condition not satisfying: %s", #condition);\ | |
if(!(condition)) { block(pixle_NSErrorMake([NSString stringWithFormat:@"Invalid condition not satisfying: %s", #condition], kErrorCodeInternal, nil, _cmd)); return;} }while(0) | |
OlderNewer