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
// NSURLConnection wrapper | |
// like NSURLConnection, requires a runloop, callbacks happen in runloop that set up load | |
@interface LDURLLoader : NSObject { | |
NSURLConnection* _connection; | |
NSTimeInterval _timeout; | |
NSTimer* _timeoutTimer; | |
NSURLResponse* _response; | |
long long _responseLengthEstimate; | |
NSMutableData* _accumulatedData; | |
void (^_timeoutHandler)(void); |
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
#if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) | |
if (&QCPlugInAttributeCategoriesKey != NULL) { | |
NSArray* categories = [NSArray arrayWithObjects:@"Utility", nil]; | |
[attributes setObject:categories forKey:QCPlugInAttributeCategoriesKey]; | |
} | |
if (&QCPlugInAttributeExamplesKey != NULL) { | |
NSArray* examples = [NSArray arrayWithObjects: | |
[[NSBundle bundleForClass:[self class]] URLForResource:TTExampleCompositionName withExtension:@"qtz"], 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
function _equalRects(left, right) { | |
return left.origin.x === right.origin.x && left.origin.y === right.origin.y && left.size.width === right.size.width && left.size.height === right.size.height; | |
} | |
function _drawImage(context, image, sourceFrame, destinationFrame) { | |
// WORKAROUND - iOS 4.3 bug with the slicing variant of drawImage when scaling | |
if (!_equalRects(sourceFrame, destinationFrame)) { | |
context.save(); | |
// clip |
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
// yoinked and recrafted from Gavin Eadie's ios-ntp http://code.google.com/p/ios-ntp/ | |
// NB - not perfectly symmetrical, this evaluates to NO: | |
// NSDate* now = [NSDate date]; [now isEqualToDate:[NSDate dateWithNTPTimestamp:[now NTPTimestamp]]; | |
struct NTPTimestamp { | |
uint32_t seconds; | |
uint32_t fractionalSeconds; | |
}; | |
typedef struct NTPTimestamp NTPTimestamp; |
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
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { | |
// set default preferences from Settings.bundle | |
NSURL* plistURL = [[[NSBundle mainBundle] URLForResource:@"Settings" withExtension:@"bundle"] URLByAppendingPathComponent:@"Root.plist"]; | |
if (!plistURL) { | |
NSLog(@"ERROR - failed to find 'Settings.bundle/Root.plist' within main bundle"); | |
} else { | |
NSArray* specifiers = [NSDictionary dictionaryWithContentsOfURL:plistURL][@"PreferenceSpecifiers"]; | |
NSDictionary* defaults = [specifiers mtl_foldLeftWithValue:[NSMutableDictionary dictionary] usingBlock:^id(NSMutableDictionary* left, NSDictionary* right) { | |
if (right[@"Key"] && right[@"DefaultValue"]) { | |
left[right[@"Key"]] = right[@"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
// GRITTY - force Facebook SDK 3.1+ to use in-app modal UIWebView for user authentication | |
@implementation FBSession (CLUAdditions) | |
- (void)HACKEDauthorizeWithPermissions:(NSArray*)permissions behavior:(FBSessionLoginBehavior)behavior defaultAudience:(FBSessionDefaultAudience)audience isReauthorize:(BOOL)isReauthorize { | |
objc_msgSend(self, @selector(authorizeWithPermissions:defaultAudience:integratedAuth:FBAppAuth:safariAuth:fallback:isReauthorize:), permissions, audience, NO, NO, NO, YES, isReauthorize); | |
} | |
+ (void)load { | |
method_exchangeImplementations(class_getInstanceMethod(self, @selector(authorizeWithPermissions:behavior:defaultAudience:isReauthorize:)), class_getInstanceMethod(self, @selector(HACKEDauthorizeWithPermissions:behavior:defaultAudience:isReauthorize:))); | |
} | |
@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
@interface NSString (CLUEmailAdditions) | |
- (BOOL)isValidEmailAddress; | |
@end | |
@implementation NSString (CLUEmailAdditions) | |
static NSString* CLUEmailAddressPattern = @"^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"; | |
// NB - mostly yoinked from https://github.com/jPaolantonio/JPValidation/blob/master/JPValidators/JPValidatorEmail.m | |
- (BOOL)isValidEmailAddress { |
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 NSString (CLUTwitterAdditions) | |
- (BOOL)isValidTwitterUsername; | |
@end | |
@implementation NSString (CLUTwitterAdditions) | |
static NSString* CLUTwitterUsernamePattern = @"^([0-9a-zA-Z_]{1,15})$"; | |
// NB - largely yoinked from http://stackoverflow.com/questions/4424179/twitter-username-regex-validation/4424288#4424288 | |
- (BOOL)isValidTwitterUsername { |
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
diff --git a/Project.xcconfig b/Project.xcconfig | |
index c90f7b1..6f6232a 100644 | |
--- a/Project.xcconfig | |
+++ b/Project.xcconfig | |
@@ -13,5 +13,5 @@ ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ | |
//IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: | |
//ICON_FILE_PATH = bin/data/ | |
-OTHER_LDFLAGS = $(OF_CORE_LIBS) | |
+OTHER_LDFLAGS = $(OF_CORE_LIBS) -framework GLUT |
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 "shadyApp.h" | |
void shadyApp::setup() { | |
ofSetBackgroundColor(ofColor::gray); | |
ofSetFrameRate(60); | |
image.loadImage("checkerboard.jpg"); // 1024x768 | |
string passthroughVertex, passthroughFragment; | |
#ifdef TARGET_OPENGLES |
OlderNewer