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/UIKit.h> | |
@interface PrivacyScreen : UIViewController | |
@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
void Graphics::resize(int screenWidth, int screenHeight) | |
{ | |
glViewport(0, 0, screenWidth, screenHeight); | |
const float widthRatio = screenWidth/(float)kViewWidth; | |
const float heightRatio = screenHeight/(float)kViewHeight; | |
const float scale = 1.0f/std::max(widthRatio, heightRatio); | |
const float finalWidth = screenWidth*scale; | |
const float finalHeight = screenHeight*scale; | |
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
#pragma once | |
#include <map> | |
template <typename K, typename V, typename F> | |
V FindWithDefault(std::map <K,V> & map, const std::string & key, const F& getDefault) { | |
typename std::map<K, V>::const_iterator it = map.find( key ); | |
if ( it == map.end() ) { | |
V defaultValue = getDefault(); | |
map.insert( std::pair<K,V>(key, defaultValue) ); |
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") | |
} |