Skip to content

Instantly share code, notes, and snippets.

View jnutting's full-sized avatar

Jack Nutting jnutting

View GitHub Profile
@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:
@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: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 / 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:8113856d0ba0f249e27f
Created November 5, 2014 21:36
All About That Spec (Lyrics)
All about that Spec
Yeah, it's pretty clear / I've made an app or two
And I can TDD it / Like I'm supposed to do
I do that red-green / Refactor most days
All the right tests / In all the right places
I see them old-timers / Working that FORTRAN shop
We know that shit ain't real / C'mon now make it stop
If you've got agile methods / Just raise em up
@jnutting
jnutting / .gitignore
Created November 1, 2015 22:27
Unity stuff worthy of ignoring
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
ExportedObj/
# Autogenerated VS/MD solution and project files
*.csproj
*.unityproj
*.sln
@jnutting
jnutting / WhiteSpace.txt
Created November 6, 2015 06:23
White Space (a parody of Taylor Swift’s “Blank Space”)
White Space
(sung to the tune of Taylor Swift’s “Blank Space”)
[Verse 1:]
Nice to meet you
where you been?
I can show you incredible things
Cocoa, ruby, ember, vim
Saw you there and I thought,
oh my god look at that noob,
@jnutting
jnutting / git rebase workflow
Created January 27, 2017 10:13
Short version of the git rebase workflow I usually use.
# Mostly from http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html
# See also https://github.com/thoughtbot/guides/blob/master/protocol/git/README.md
# Make a branch called feature_name
git checkout -b feature_name
# Assuming we are working in a branch called "feature_name”.
# Rebase against master frequently (maybe daily, or whenever you're at
# a good stopping point), to avoid conflicts at the end:
#!/bin/sh
#
# A post-build script for running in Xcode, to overlay app icons with some build info.
# Requires ImageMagick to be installed before use.
commit=`git rev-parse --short HEAD`
branch=`git rev-parse --abbrev-ref HEAD`
version=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"`
function processIcon() {
#!/bin/sh
#
# Run this as an Xcode build phase in order to always set the build number
# of a freshly-built app equal to the number of commits in the master branch.
# This gives you an always-increasing build number, automatically.
#
# This sets the build number only in the build product, not in the source
# directory itself, so it doesn't dirty the repository. You can leave the
# build number in the Xcode project to "1" forever.