Skip to content

Instantly share code, notes, and snippets.

View tylerhall's full-sized avatar

Tyler Hall tylerhall

View GitHub Profile
curl http://pear.php.net/go-pear > go-pear.php
sudo php -q go-pear.php
LoadModule php5_module libexec/apache2/libphp5.so
/Applications/XAMPP/etc/httpd.conf
/private/etc/hosts
/private/etc/apache2/extra/httpd-vhosts.conf
@tylerhall
tylerhall / gist:792971
Created January 24, 2011 08:26
Inserts your most recent git commit hash into your app's Info.plist
<?PHP
$fn = "{$_ENV['BUILT_PRODUCTS_DIR']}/{$_ENV['WRAPPER_NAME']}/Contents/Info.plist";
$rev = trim(`git rev-parse HEAD`);
$plist = file_get_contents($fn);
$plist = preg_replace('/CFBundleVersion<\/key>.*?<string>(.*?)<\/string>/ms', "CFBundleVersion</key>\n\t<string>$rev</string>", $plist);
file_put_contents($fn, $plist);
Here's the problem I was having...
I have a singleton object which is first instantiated inside my NSDocument's windowControllerDidLoadNib:. It attempts to fetch a password from the user's default keychain using EMKeychain[1]. For over a week, this was working fine.
At some point I noticed that the password fetch would fail with an errSecAuthFailed error. However, it would only fail on every other app launch. Literally. Launch the app, it works. Quit, relaunch (with or without rebuilding) and it fails. Quit, launch again, it works. I reproduced this behavior 20 launches in a row, consistently. Cleaning all and rebuilding didn't change anything. Neither did locking/unlocking the keychain, restarting the Mac, etc.
After going back through numerous revisions, I tracked the problem down to the build where I first added Sparkle. Because this app is currently in beta testing, I have Sparkle configured to check for updates on every launch inside my app delegate like so:
- (void)applicationDidFinishLaunching

Here's the problem I was having...

I have a singleton object which is first instantiated inside my NSDocument's windowControllerDidLoadNib:. It attempts to fetch a password from the user's default keychain using EMKeychain. For over a week, this was working fine.

At some point I noticed that the password fetch would fail with an errSecAuthFailed error. However, it would only fail on every other app launch. Literally. Launch the app, it works. Quit, relaunch (with or without rebuilding) and it fails. Quit, launch again, it works. I reproduced this behavior 20 launches in a row, consistently. Cleaning all and rebuilding didn't change anything. Neither did locking/unlocking the keychain, restarting the Mac, etc.

After going back through numerous revisions, I tracked the problem down to the build where I first added Sparkle. Because this app is currently in beta testing, I have Sparkle configured to check for updates on every launch inside my app delegate like so:

  • (vo
Options +FollowSymLinks
# # Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
defaults write com.clickonideas.web.nottingham SUEnableAutomaticChecks -boolean NO
@tylerhall
tylerhall / gist:1078783
Created July 12, 2011 19:30
Reposition iOS Simulator Window
#!/bin/sh
osascript -e 'tell app "System Events" to set position of window 1 of process "iOS Simulator" to {-864, 134}'
@tylerhall
tylerhall / SFBestGuess.h
Created September 25, 2011 19:21
By inspecting the user's address book and finding the most common city, state, and zip code - we can make an educated guess as to the user's location without using CoreLocation.
#import <Foundation/Foundation.h>
#import <AddressBook/AddressBook.h>
@interface SFBestGuess : NSObject {
NSMutableArray *_cities;
NSMutableArray *_states;
NSMutableArray *_zipCodes;
}
@property (nonatomic, retain) NSMutableArray *cities;