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
import UIKit | |
import CoreGraphics | |
// our Cell class | |
class Cell : UITableViewCell | |
{ | |
// cell reuse identifier for table view | |
static let Identifier = "Cell" | |
// the object the cell represents/displays. Could be anything you like |
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
import CoreMotion | |
public class Main | |
{ | |
var motionManager:CMMotionActivityManager! | |
let motionHandler:CMMotionActivityHandler! = { (activity:CMMotionActivity?) -> Void in | |
let desc = activity?.debugDescription ?? "no activity" | |
println("activity is \(desc)") | |
} |
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
// NWGKeyValueObserving.h | |
// by nielsbot ( nielsbot@nielsbot.com) | |
typedef void (^KeyValueObserverBlock)( NSDictionary * change ) ; | |
@interface NWGKeyValueObserver : NSObject | |
@property ( nonatomic, readonly, copy ) NSString * keyPath ; | |
@property ( nonatomic, readonly ) id target ; | |
@property ( nonatomic, readonly ) NSKeyValueObservingOptions options ; |
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
// when setting the position of a layer, use this: | |
// layer.position = [ layer pixelAlignedPostionForPoint:<originalPoint> ] ; | |
@implementation CALayer (SetPositionPixelAligned) | |
-(CGPoint)pixelAlignedPositionForPoint:(CGPoint)p | |
{ | |
CGSize size = self.bounds.size ; | |
CGPoint anchorPoint = self.anchorPoint ; | |
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
#import "FileChangeObserver.h" | |
#undef Assert | |
#define Assert(COND) { if (!(COND)) { raise( SIGINT ) ; } } | |
@interface FileChangeObserver () | |
@property ( nonatomic, readonly ) int kqueue ; | |
@property ( nonatomic ) enum FileChangeNotificationType typeMask ; | |
@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
static CGColorRef CGColorCreateWithCSSColor( NSString * string ) | |
{ | |
union { | |
struct { | |
#if LITTLE_ENDIAN | |
uint8 alpha ; | |
uint8 blue ; | |
uint8 green ; | |
uint8 red ; | |
#else |
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 NSNull (IfNullThenNil) | |
-(id)ifNullThenNil { return nil ; } | |
@end | |
@implementation NSObject (IfNullThenNil) | |
-(id)ifNullThenNil { return self ; } | |
@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
#import <Foundation/Foundation.h> | |
#import <CoreGraphics/CoreGraphics.h> | |
@interface MemoryMappedDataConsumer : NSObject | |
@property ( nonatomic, readonly ) size_t size ; | |
@property ( nonatomic, readonly ) size_t capacity ; | |
@property ( nonatomic, readonly ) CGDataConsumerRef CGDataConsumer ; | |
@property ( nonatomic, readonly, copy ) NSURL * url ; |
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
CGPathRef CGPathCreateRoundRect( const CGRect r, const CGFloat cornerRadius ) | |
{ | |
CGMutablePathRef p = CGPathCreateMutable() ; | |
CGPathMoveToPoint( p, NULL, r.origin.x + cornerRadius, r.origin.y ) ; | |
CGFloat maxX = CGRectGetMaxX( r ) ; | |
CGFloat maxY = CGRectGetMaxY( r ) ; | |
CGPathAddArcToPoint( p, NULL, maxX, r.origin.y, maxX, r.origin.y + cornerRadius, cornerRadius ) ; |
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
#import <libproc.h> | |
#import <stdlib.h> | |
#import <stdio.h> | |
int main( int argc, const char * argv[]) | |
{ | |
pid_t * pids = calloc(0x4000, 1); | |
int count = proc_listallpids(pids, 0x4000); | |
printf("count=%u\n", count) ; |
NewerOlder