Skip to content

Instantly share code, notes, and snippets.

View jnutting's full-sized avatar

Jack Nutting jnutting

View GitHub Profile
@jnutting
jnutting / A_and_B.swift
Created June 11, 2014 08:57
dynamic dispatch in swift
class A {
func foo() -> String {
return "A foo"
}
}
class B: A {
override func foo() -> String {
return "B foo"
}
@jnutting
jnutting / gist:6377458
Created August 29, 2013 12:30
Automatically update the build number every time anyone hits build
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$((0x$buildNumber))
buildNumber=$(($buildNumber + 1))
buildNumber=$(printf "%X" $buildNumber)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
@jnutting
jnutting / gist:974355
Created May 16, 2011 12:27
accelerometer smoothing delegate
/*
* This gives something resembling an average of the last 1/k values. A k-value of 0.5 will
* give the current values equal weight with the previous smooth values, while a k-value of
* 0.9 will let the current values only account for 10% of the new smooth value.
*
* This approach probably consumes a little less memory, and calculates a little faster,
* than actually keeping an array of old values.
*/
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
CGFloat x = acceleration.x;
@jnutting
jnutting / gist:951315
Created May 2, 2011 08:46
accumulating distance
// The Core Location example in Beginning iPhone 4 Development shows how to
// calculate a distance from a starting point, but it doesn't show how far you've
// actually traveled. These changes should let you see an accumulated distance.
// Add this to the interface declaration in WhereAmIViewController.h:
CLLocationDistance totalDistance;
// then replace the last chunk of locationManager:didUpdateToLocation:fromLocation:
// with this: