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
// oh dear god... | |
if ([[[[_actionSheet superview] superview] nextResponder] respondsToSelector:@selector(setPassthroughViews:)]) { | |
[[[[_actionSheet superview] superview] nextResponder] performSelector:@selector(setPassthroughViews:) withObject: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
#import <Foundation/Foundation.h> | |
#import <stdio.h> | |
@interface Test : NSObject | |
@end | |
@implementation Test | |
+ (NSArray*)arrayWithoutDuplicates:(NSArray*)a { | |
NSMutableSet* s = [NSMutableSet set]; |
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 <stdio.h> | |
@class Node; | |
@interface Node : NSObject | |
@property (strong) Node* next; | |
@property (assign) NSString* val; | |
@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
#include "Platform.h" | |
bool Platform::mapFile(const char* filename, uint8_t** bytes, long* length) { | |
FILE* fin = fopen(Platform::pathForFile(filename).c_str(), "rb"); | |
if (!fin) { | |
dbgLog("error opening file '%s'", filename); | |
return false; | |
} | |
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
// jacob schwartz | @isoiphone | |
// solves N queens problem in swift | |
// for N=8 there should be 92 possible solutions | |
// each solution is a list of numbers, these indicate the row to place queen for given column | |
// for example 0,4,7,5,2,6,1,3 maps to: | |
// Q------- | |
// ------Q- | |
// ----Q--- | |
// -------Q | |
// -Q------ |
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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
void reverse(char *s) { | |
for (char *front = s, *back=s+strlen(s)-1; front < back; *front ^= *back, *back ^= *front, *front ^= *back, ++front, --back) {} | |
} | |
void test(const char* s) { | |
char* tmp = strdup(s); |
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
// no longer compiles in swift 1.2 | |
func someFunc(block: () -> (), functionName: String = __FUNCTION__) { | |
println("NEAT!") | |
block() | |
} | |
someFunc { | |
println("oh") | |
} |
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 is the first call to defaultRealm() (ie: it lives in application:didFinishLaunchingWithOptions) | |
// see: SwiftTryCatch https://github.com/williamFalcon/SwiftTryCatch for a wrapper around ObjectiveC exceptions. | |
SwiftTryCatch.try({ | |
RLMRealm.defaultRealm() | |
}, catch: { exception in | |
log.error("realm exception: \(exception.description). Will remove local database.") | |
NSFileManager.defaultManager().removeItemAtPath(RLMRealm.defaultRealmPath()!, error: 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
extension RLMRealm { | |
static var threadInstance: RLMRealm! { | |
let threadDictionary = NSThread.currentThread().threadDictionary | |
if let inst = threadDictionary["SharedRealmInst"] as! RLMRealm? { | |
return inst | |
} else { | |
let inst = defaultRealmWithErrorHandling() | |
threadDictionary["SharedRealmInst"] = inst | |
return inst | |
} |
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 qp = 0.0 | |
for var n=0.0; ;++n { | |
qp += (1-(n%2)*2)/(2*n+1) | |
println("\(qp*4)") | |
} |
OlderNewer