Skip to content

Instantly share code, notes, and snippets.

View RandyMcMillan's full-sized avatar
🛰️
Those who know - do not speak of it.

@RandyMcMillan RandyMcMillan

🛰️
Those who know - do not speak of it.
View GitHub Profile
@RandyMcMillan
RandyMcMillan / gist:2381583
Created April 14, 2012 02:13
iOS3 / iOS4 / iOS5 threshold switch
NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
BOOL isGreaterThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedDescending);
BOOL isLessThaniOS5 = ([systemVersion compare:@"5.0" options:NSNumericSearch] == NSOrderedAscending);
BOOL isGreaterThaniOS5 = ([systemVersion compare:@"5.0" options:NSNumericSearch] == NSOrderedDescending);
if (isLessThaniOS4 && isLessThaniOS5)
{
//NSLog(@"isLessThaniOS4 && isLessThaniOS5 = %@",whatever);
}
@RandyMcMillan
RandyMcMillan / PhoneGap.gitignore
Created April 17, 2012 18:30
PhoneGap.gitignore
# ANDROID / ECLIPSE
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
@RandyMcMillan
RandyMcMillan / gist:2409856
Created April 17, 2012 23:26
.gitignore everything but .gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore
@RandyMcMillan
RandyMcMillan / CordovaBotIcon.html
Created April 28, 2012 07:32
Cordova Bot Icon ASCII Art
<html>
<head>
<meta charset="utf-8">
<style>
*{margin:0;padding:0;}
body {
font:13.34px helvetica,arial,freesans,clean,sans-serif;
color:black;
line-height:1.4em;
background-color: #F8F8F8;
@RandyMcMillan
RandyMcMillan / gist:2562430
Created April 30, 2012 20:30
Detect iOS systemVersion and Retina Display
+ (NSString*) resolveImageResource:(NSString*)resource
{
NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
// the iPad image (nor retina) differentiation code was not in 3.x, and we have to explicitly set the path
if (isLessThaniOS4)
{
return [NSString stringWithFormat:@"%@.png", resource];
@RandyMcMillan
RandyMcMillan / openInSafari.m
Created May 20, 2012 16:18
MainViewController.m (openInSafari) switch
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
{
NSURL *requestURL =[ [ request URL ] retain ];
if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ] || [ [ requestURL scheme ] isEqualToString: @"mailto" ])
&& ( /*navigationType == UIWebViewNavigationTypeLinkClicked ||*/ navigationType == UIWebViewNavigationTypeOther ) ) {
return ![ [ UIApplication sharedApplication ] openURL: [ requestURL autorelease ] ];
}
[ requestURL release ];
return YES;
}
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
/*
if (IS_IPAD) {}
else
if (!IS_IPAD) {}
else {}
*/
@RandyMcMillan
RandyMcMillan / shouldAutorotateToInterfaceOrientation.m
Created June 10, 2012 01:08
iOS shouldAutorotateToInterfaceOrientation
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
// Return YES for supported orientations
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){
return YES;
}
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
return YES;
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
//NSLog(@"RECIEVED MEM WARNING WHY?");
[self report_memory];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}
-(void) report_memory {
//#import "mach/mach.h" ///Add to headers
@RandyMcMillan
RandyMcMillan / IS_IPAD_with_statusBarOrientation.m
Created June 30, 2012 15:04
IS_IPAD and statusBarOrientation support
//#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
if ([[UIApplication sharedApplication] statusBarOrientation] < 3) {//portrait
if (IS_IPAD) {
} else {