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 -framework Foundation -fobjc-arc -O3 test.m | |
#import <Foundation/Foundation.h> | |
@interface Slice : NSObject | |
@property NSInteger start; | |
@property NSInteger length; | |
@end | |
@implementation Slice |
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
/* | |
This crashes (usually after the first log, but not 100% reliable) on at least iOS 4.3, 5.0 and 5.1 | |
(lldb) bt | |
* thread #1: tid = 0x1c03, 0x36d60e58 CoreFoundation`CFRetain + 20, stop reason = EXC_BAD_ACCESS (code=1, address=0xe0000000) | |
frame #0: 0x36d60e58 CoreFoundation`CFRetain + 20 | |
frame #1: 0x33927248 CFNetwork`__CFURLCache::CopyResponseForRequest(_CFURLRequest const*, bool) + 116 | |
frame #2: 0x339271cc CFNetwork`_ZL34__CFURLCacheCopyResponseForRequestPK11_CFURLCachePK13_CFURLRequestb + 48 | |
frame #3: 0x33927e5c CFNetwork`CFURLCacheCopyResponseForRequest + 24 | |
frame #4: 0x32a7487e Foundation`-[NSURLCache cachedResponseForRequest:] + 66 | |
frame #5: 0x0006963c NSURLCacheCrash`main + 504 at main.m:28 |
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
@interface NSObject (Cast) | |
+ (instancetype)cast:(id)from; | |
@end | |
@implementation NSObject (Cast) | |
+ (instancetype)cast:(id)from { | |
if ([from isKindOfClass:self]) { | |
return from; | |
} | |
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
#!/bin/bash | |
git diff --cached -SNSLog --quiet | |
if [ $? -eq 1 ]; then | |
echo "NSLog call detected, indicating debug code is staged. Please unstage your debug code." | |
exit 1 | |
fi | |
exit 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
{ | |
"available_levels": 1021, | |
"environment": 3, | |
"udid": "FC9C22DC-0301-4421-A26A-2DB95985B962", | |
"enabled_for": 5, | |
"created_at": "Thu Jan 03 17:25:48 +0000 2013", | |
"display": 7, | |
"lang": null, | |
"id": 1736398994, | |
"token": "buWWQDx46io1\/1jFRphV4gH9YjrqnhUmWehQ5gF267I=", |
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
[[NSNotificationCenter defaultCenter] addObserverForName:nil object:nil queue:nil usingBlock:^(NSNotification *note) { | |
NSLog(@"%@: %@", note.name, note.userInfo); | |
}]; |
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> | |
#include <stdlib.h> | |
#include <objc/runtime.h> | |
@interface A : NSObject | |
@property (assign) int meaning; | |
@end | |
@implementation 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
#!/usr/bin/perl | |
# | |
# Check if we're running for 5.1 deployment and any .xib view has autolayout on. | |
# | |
use File::Find qw(find); | |
my $deployment = $ENV{'IPHONEOS_DEPLOYMENT_TARGET'}; | |
my $project_dir = $ENV{'PROJECT_DIR'}; | |
print "Deploy to $deployment\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
// hello clever programmers, would you like to play a game? | |
// where's the bug? | |
// by 0xabad1dea :) | |
#include <stdio.h> | |
#include <string.h> | |
int main() { | |
char input[16] = "stringstring!!!"; | |
char output[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
var foo = 1; | |
func bar() { | |
if (!foo) { | |
var foo = 10; | |
} | |
console.log(foo); | |
} | |
bar(); |