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
THIN_EXES := $(patsubst %,build/%/$(APP),$(ARCHS)) | |
build/%/$(APP): $(SOURCES) Makefile Arch.mk | |
./choosesdk.rb --arch=$* --min-os=10.6 --run="$(MAKE) -f Arch.mk $@ ARCH=$*" | |
$(EXE): $(THIN_EXES) Makefile | |
mkdir -p $(@D) | |
lipo $(THIN_EXES) -create -output $@ |
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 EWWordLayout | |
- (CGSize)preferredSizeOfLayer:(CALayer *)layer | |
{ | |
size_t layerCount = [[layer sublayers] count]; | |
CGFloat totalWidth = layerCount * TILE_WIDTH + (layerCount - 1) * INTERTILE_GAP; | |
return CGSizeMake(totalWidth, TILE_HEIGHT); | |
} | |
- (void)invalidateLayoutOfLayer:(CALayer *)layer |
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
OneSadMBP13:Desktop keith$ cat > test.c | |
#include <stdio.h> | |
typedef struct { short a; } S; | |
typedef struct { char a[2]; } T; | |
main(){ | |
printf("short: %zu bytes; aligned to %zu\n", sizeof(S), __alignof__(S)); | |
printf("char[2]: %zu bytes; aligned to %zu\n", sizeof(T), __alignof__(T)); | |
return 0; | |
} | |
OneSadMBP13:Desktop keith$ gcc test.c |
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)setSeekTime:(int)inSeconds frame:(int)inFrame { | |
if (self.videoTrack) { | |
float fps = [self.videoTrack nominalFrameRate]; | |
[self.playerItem seekToTime:CMTimeMake(inSeconds + inFrame / fps, 1)]; | |
// or: [self.playerItem seekToTime:CMTimeMake(inSeconds * fps + inFrame, fps)]; | |
} else { | |
[self.playerItem seekToTime:CMTimeMakeWithSeconds(inSeconds, 1)]; | |
} | |
} |
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)encodeWithCoder:(NSCoder *)aCoder | |
{ | |
[super encodeWithCoder:aCoder]; | |
[aCoder encodeObject:_vValue forKey:@"vValue"]; | |
} | |
- (id)initWithCoder:(NSCoder *)aDecoder | |
{ | |
self = [super initWithCoder:aDecoder]; | |
if (!self) return 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
void foo() | |
{ | |
printf("foo\n"); | |
#if !defined(COMBINE_FOO_AND_BAR) | |
} | |
void bar() | |
{ | |
#endif | |
printf("bar\n"); |
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 cat(x, y) x##y | |
#define A B | |
#define C(Foo) cat(Foo, Bar) | |
C(A) |
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)check:(NSEvent *)event onCard:(void (^)(SMCardID, CGPoint))cardHandler onPile:(void (^)(SMPile, CGPoint))pileHandler | |
{ | |
CGPoint where = [event locationInWindow]; | |
[[self openGLContext] makeCurrentContext]; | |
glBindBuffer(GL_PIXEL_PACK_BUFFER, _pbo); | |
uint32_t const *pickData = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); | |
uint32_t pixel = pickData[(size_t)where.x + 1024 * (size_t)where.y]; | |
glUnmapBuffer(GL_PIXEL_PACK_BUFFER); | |
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); |
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
clang -fobjc-arc -O2 -c -arch x86_64 test.m | |
otool -toV test.o | mate |
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
$ clang -fobjc-arc -O2 -arch x86_64 test.m -framework Foundation | |
$ ./a.out b: 0x104011710 | |
Segmentation fault: 11 |