Skip to content

Instantly share code, notes, and snippets.

View kishikawakatsumi's full-sized avatar
🏠
Working from home

Kishikawa Katsumi kishikawakatsumi

🏠
Working from home
View GitHub Profile
@interface UIColor (HexEncoding)
+ (UIColor*)colorFromString:(NSString*)string;
- (NSString*)encodeToString;
@end
@implementation UIColor (HexEncoding)
+ (UIColor*)
colorFromString:(NSString*)string
{
NSFileManager * theFM = [NSFileManager defaultManager];
NSDictionary * fileProperties = [theFM fileSystemAttributesAtPath:[[NSBundle mainBundle] bundlePath]];
NSInteger freeSpace = [[fileProperties objectForKey:NSFileSystemFreeSize] integerValue];
NSLog(@"We have %d free",freeSpace);
@class UIAnimation;
@interface UIAnimator : NSObject {}
+ (id)sharedAnimator;
+ (void)disableAnimation;
+ (void)enableAnimation;
- (void)addAnimation:(UIAnimation *)animation withDuration:(double)duration start:(BOOL)start;
- (void)addAnimations:(NSArray *)animations withDuration:(double)duration start:(BOOL)start;
- (void)removeAnimationsForTarget:(id)target;
- (void)removeAnimationsForTarget:(id)target ofKind:(Class)classOfTarget;
#import <mach/mach.h>
#import <mach/mach_host.h>
static void print_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);
#import "UIViewTouch.h"
#import <MapKit/MapKit.h>
@implementation UIViewTouch
@synthesize viewTouched;
//The basic idea here is to intercept the view which is sent back as the firstresponder in hitTest.
//We keep it preciously in the property viewTouched and we return our view as the firstresponder.
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
NSLog(@"Hit Test");
#import <UIKit/UIKit.h>
@class UIView;
@interface UIViewTouch : UIView {
UIView *viewTouched;
}
@property (nonatomic, retain) UIView * viewTouched;
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
static void addRoundedRectToPath(CGContextRef context,
CGRect rect,
float ovalWidth,
float ovalHeight,
int i
{
float fw, fh;
if (ovalWidth == 0 || ovalHeight == 0) {
CGContextAddRect(context, rect);
return;
NSString *htmlBody = @"you probably want something HTML-y here";
// First escape the body using a CF call
NSString *escapedBody = [(NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)htmlBody, NULL, CFSTR("?=&+"), kCFStringEncodingUTF8) autorelease];
// Then escape the prefix using the NSString method
NSString *mailtoPrefix = [@"mailto:?subject=Some Subject&body=" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// Finally, combine to create the fully escaped URL string
NSString *mailtoStr = [mailtoPrefix stringByAppendingString:escapedBody];
#import <UIKit/UIKit.h>
#import <UIKit/UIApplication.h>
#include <dlfcn.h>
#include <stdio.h>
// Framework Paths
#define SBSERVPATH "/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices"
#define UIKITPATH "/System/Library/Framework/UIKit.framework/UIKit"
int main(int argc, char **argv)