Skip to content

Instantly share code, notes, and snippets.

View jacobvanorder's full-sized avatar

Jacob Van Order jacobvanorder

View GitHub Profile
alias cb='git branch | grep "*" | sed "s/* //" | awk '"'"'{printf $0}'"'"' | pbcopy'
@jacobvanorder
jacobvanorder / ThanksTimCook
Last active November 21, 2016 10:45
Bash Shell Script for Xcode Aggregate Target for new Xcode 6 Framework/Module
#Thanks to http://spin.atomicobject.com/2011/12/13/building-a-universal-framework-for-ios/ for the start
#To get this to work with a Xcode 6 Cocoa Touch Framework, create Framework
#Then create a new Aggregate Target. Throw this script into a Build Script Phrase on the Aggregate
#Tip: if you want the resulting framework to be the same name as your Framework, change the Aggregate's product name
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PRODUCT_NAME}.framework"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PRODUCT_NAME}.framework"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${PRODUCT_NAME}.framework"
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
static UIImage *frameImage(CGSize size, CGFloat radians) {
UIGraphicsBeginImageContextWithOptions(size, YES, 1); {
[[UIColor whiteColor] setFill];
UIRectFill(CGRectInfinite);
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(gc, size.width / 2, size.height / 2);
@jacobvanorder
jacobvanorder / gist:ac8dee5f42de18f4f359
Created March 31, 2015 18:49
Synchronous vs. Asynchronous WatchKit call
func application(application: UIApplication!, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]!, reply: (([NSObject : AnyObject]!) -> Void)!) {
/* Synchronous
let response : (DateTime?, NSError?) = Network.fetchDateTime()
if let checkedDateTime = response.0 {
reply(["response": NSKeyedArchiver.archivedDataWithRootObject(checkedDateTime)])
}
else if let checkedError = response.1 {
reply(["error": NSKeyedArchiver.archivedDataWithRootObject(checkedError)])
}
else {
@jacobvanorder
jacobvanorder / PresentedViewController.m
Created April 21, 2015 20:38
Solution for WKInterface button doesn't change title
/* Catch and use the model object*/
@interface PresentedViewController()
@property (nonatomic, strong) SGYourActionModelObject *actionBlockObject;
@end
- (void)awakeWithContext:(id)context {
NSAssert([context isKindOfClass:[SGYourActionModelObject class]], @"Expected SGYourActionModelObject")
@IBAction func viewDragged(sender: UIPanGestureRecognizer) {
let yTranslation = sender.translationInView(view).y
if (hasExceededVerticalLimit(topViewConstraint.constant)){
totalTranslation += yTranslation
topViewConstraint.constant = logConstraintValueForYPosition(totalTranslation)
if(sender.state == UIGestureRecognizerState.Ended ){
animateViewBackToLimit()
}
} else {
topViewConstraint.constant += yTranslation
if [ "${CONFIGURATION}" = "Release" ]; then
CFBundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}")
CFBundleVersion=$(($CFBundleVersion + 1))
echo $CFBundleVersion
$PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$buildPlist"
$PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "$INFOPLIST_FILE"
$PlistBuddy -c "Set :CFBundleVersion $CFBundleVersion" "${DWARF_DSYM_FOLDER_PATH}/${WRAPPER_NAME}.dSYM/Contents/Info.plist"
@jacobvanorder
jacobvanorder / Info_plist.rb
Created December 8, 2015 15:26
Fastlane Info Plist
fastlane_version "1.46.0"
default_platform :ios
platform :ios do
desc "Get plist values"
lane :plist do
# plist_file_path = "AppProject/Info.plist" #works
# plist_file_path = sh("xcodebuild -project ../AppProject.xcodeproj -showBuildSettings -configuration Release | grep \"INFOPLIST_FILE\" | sed 's/[ ]*INFOPLIST_FILE = //'") #doesn't work
@jacobvanorder
jacobvanorder / compare.sh
Last active January 18, 2016 21:00
A shell for comparison of images
#!/bin/bash
#Must have imagemagick installed…
NUMBER_OF_PIXELS=$(compare -metric ae $1 $2 null: 2>&1)
identify -format "%[fx:$NUMBER_OF_PIXELS*100/(w*h)]" $1
@jacobvanorder
jacobvanorder / AppDelegate.swift
Created October 19, 2016 16:08
iOS Swift Start Up Measurement from main
//
// AppDelegate.swift
//
// Created by Jacob Van Order on 10/19/16.
//
//
import UIKit
//@UIApplicationMain