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
@norio-nomura
norio-nomura / gist:3937593
Created October 23, 2012 08:15
superに任意のメッセージを送る方法
#import <objc/objc-runtime.h>
// [super description];
struct objc_super s = {self, [self superclass]};
objc_msgSendSuper(&s, @selector(description));
@rpetrich
rpetrich / UIScale.h
Created March 9, 2012 00:37
Convenience functions for getting the screen scale and rounding metrics relative to it.
#import <UIKit/UIKit.h>
#define UI_MAIN_SCREEN_SCALE() ([UIScreen instancesRespondToSelector:@selector(scale)] ? [UIScreen mainScreen].scale : 1.0f)
static inline CGFloat CGFloatRoundToScale(CGFloat value, CGFloat scale)
{
return roundf(value * scale) / scale;
}
static inline CGFloat CGFloatRoundToMainScreen(CGFloat value)
@kishikawakatsumi
kishikawakatsumi / ImageUpload.m
Created November 23, 2011 15:13
Upload image to Twitter with OAuth
#define DATA(str) [(NSString*)(str) dataUsingEncoding:NSUTF8StringEncoding]
- (NSData *)generateFormData:(NSDictionary *)dictionary boundary:(NSString *)boundary {
NSMutableData *data = [[NSMutableData alloc] init];
id key;
NSEnumerator *enumerator = [dictionary keyEnumerator];
while (key = [enumerator nextObject]) {
id value = [dictionary valueForKey:key];
[data appendData:DATA(([NSString stringWithFormat:@"--%@\r\n", boundary]))];