Here is a checklist to follow if you want maximum battery life -- for instance if you're about to get on a long plane flight.
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
LoadModule dav_svn_module /opt/subversion/lib/svn-apache/mod_dav_svn.so | |
LoadModule authz_svn_module /opt/subversion/lib/svn-apache/mod_authz_svn.so | |
<Location "/svn"> | |
DAV svn | |
SVNParentPath /usr/local/svnroot | |
AuthType Basic | |
AuthName "Subversion Repository" | |
AuthUserFile /etc/apache2/other/htpasswd | |
Require valid-user | |
</Location> |
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/sh | |
# OBJC_HELP=1 causes the Objective-C runtime to spit out help to stderr | |
# Pulling in osx/cocoa causes the runtime to be loaded via RubyCocoa | |
# Redirect sterr to stdout so we can pipe the results through pager | |
OBJC_HELP=1 /usr/bin/ruby -rosx/cocoa -e '' 2>&1 |
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
static NSString* prettyFloat(CGFloat f) { | |
if (f == 0) { | |
return @"0"; | |
} else if (f == 1) { | |
return @"1"; | |
} else { | |
return [NSString stringWithFormat:@"%.3f", f]; | |
} | |
} |
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
// | |
// TransitionController.h | |
// | |
// Created by XJones on 11/25/11. | |
// | |
#import <UIKit/UIKit.h> | |
@interface TransitionController : UIViewController |
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
// ARC is compatible with iOS 4.0 upwards, but you need at least Xcode 4.2 with Clang LLVM 3.0 to compile it. | |
#if !defined(__clang__) || __clang_major__ < 3 || !__has_feature(objc_arc) | |
#error This project must be compiled with ARC (Xcode 4.2+ with LLVM 3.0 and above) | |
#endif |
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
// The basics: | |
// - Write your own NSURLProtocol subclass and register it. | |
// - Override the 5 required methods | |
// - Kick off download or cache fetch during |startLoading| | |
// - Update self.client with progress/completion/failure notifications. | |
// UIWebView will download requests concurrently via NSURLProtocol. | |
// If you use the typical NSURLCache hook to download content, you're | |
// stuck with serial downloads. |
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 <objc/runtime.h> | |
@implementation NSObject (ARCZombie) | |
+ (void) load | |
{ | |
const char *NSZombieEnabled = getenv("NSZombieEnabled"); | |
if (NSZombieEnabled && tolower(NSZombieEnabled[0]) == 'y') | |
{ | |
Method dealloc = class_getInstanceMethod(self, @selector(dealloc)); |
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 (KBAdditions) | |
- (CGFloat)fontSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size minimumFontSize:(CGFloat)minimumFontSize; | |
@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
# Fix an iOS-converted PNG | |
fixpng () { | |
if [ -z "$1" ]; then | |
echo "Usage: fixpng <inputFile> [outputFile]" | |
return -1 | |
else | |
inputFile=$1 | |
# Only "png" and "PNG" are allowed | |
pngRegex='.*.(png|PNG)$' |