Skip to content

Instantly share code, notes, and snippets.

View wooster's full-sized avatar

Andrew Wooster wooster

View GitHub Profile
#!/usr/bin/env python
# Created by Andrew Wooster on 2009-11-04.
# Copyright Planetary Scale LLC 2009.
# Released under the MIT License.
import sys
"""
Takes iPhone app revenue data and combines sales from all apps into daily combined
values.
Steps to use:
@wooster
wooster / mobileprovision_reader.py
Created January 14, 2011 23:34
plist from .mobileprovision file
import plistlib
from StringIO import StringIO
def plist_from_mobileprovision(provision_path):
f = open(provision_path)
f.seek(62)
string = ""
lookfor = "</plist>"
found = False
while True:
@wooster
wooster / gist:894962
Created March 30, 2011 18:34
Build phase for copying a bundle into an app
#!/bin/sh
if [ -d "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME/foo.bundle" ]; then
rm -rf "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME/foo.bundle"
fi
if [ -d "$BUILT_PRODUCTS_DIR/foo.bundle" ]; then
mv "$BUILT_PRODUCTS_DIR/foo.bundle" "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME/"
fi
@wooster
wooster / gist:1359532
Created November 11, 2011 22:34
Miscellaneous iOS Notes

Debugging

No Exception Backtraces in iOS 5

There's a bug in the iOS 5 SDK where symbols aren't showing up in the debugger for exception backtraces.

To work around it, go into the breakpoint navigator in Xcode 4, then down at the bottom left, click on the + button and choose "Add Exception Breakpoint…". Set it to break "On Throw", and you should get a breakpoint where the exception is thrown.

Entitlements

@wooster
wooster / gist:1406821
Created November 29, 2011 22:15
Decoding mobileprovision DER encoded ASN.1
from pyasn1.codec.der import decoder as der_decoder
s = open("Example.mobileprovision").read()
der_decoder.decode(s)
@wooster
wooster / coverage.md
Last active December 10, 2015 06:18
Code coverage in Xcode projects

In Xcode 4.5 with LLVM, to enable code coverage on a project:

  • Set "Instrument Program Flow" and "Generate Test Coverage Files" to Yes in the Build Settings.
  • You'll want to have the program properly exit in order to generate the files. A simple way is:
- (void)applicationDidEnterBackground:(UIApplication *)application {
    exit(0);
}
@wooster
wooster / coloring_executed_lines.diff
Created December 29, 2012 02:21
Patch for CoverStory to optionally color executed lines in the file scroller. This is useful for running through a scenario where you're seeing a bug, then checking which lines executed in your app so you can narrow down the problem space. Normally, you'd have red lines in the scrollbar for each un-executed line. This is fine for looking at test…
Index: CoverStoryDocument.m
===================================================================
--- CoverStoryDocument.m (revision 175)
+++ CoverStoryDocument.m (working copy)
@@ -557,30 +557,31 @@
// run gcov (it writes to current directory, so we cd into our dir first)
// we use xargs to batch up the files into as few of runs of gcov as
// possible. (we could use -P [num_cpus] to do things in parallell)
+ //
+ // GTMScriptRunner deadlocks if stderr is too long. since we want stderr,
- (IBAction)snapshot:(id)sender {
UIButton *button = sender;
UIView *v = button.superview;
CGRect allTheViews = CGRectUnion(v.bounds, button.frame);
UIGraphicsBeginImageContext(allTheViews.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, -allTheViews.origin.x, -allTheViews.origin.y);
[v.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@wooster
wooster / oclint_xcode.sh
Last active August 29, 2015 13:59
Xcode Run Script Phase for OCLint
source ~/.bash_profile
OCLINT_HOME="/Users/andrew/Downloads/oclint-0.9.dev.6a4451b"
PATH=$OCLINT_HOME/bin:$PATH
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
@wooster
wooster / CGPDFBoolean.m
Last active August 29, 2015 14:01
Strange CGPDFBoolean Stuff
// Simple object, not an array or dictionary.
- (void)pushObject:(NSObject *)object withKey:(NSString *)key {
NSObject *last = [stack lastObject];
if ([last isKindOfClass:[NSMutableDictionary class]]) {
NSMutableDictionary *dictionary = (NSMutableDictionary *)last;
// Exception raised here.
// *** setObjectForKey: object cannot be nil (key: BaseFont)
[dictionary setObject:object forKey:key];
} else if ([last isKindOfClass:[NSMutableArray class]]) {
NSMutableArray *array = (NSMutableArray *)last;