Skip to content

Instantly share code, notes, and snippets.

View jacobvanorder's full-sized avatar

Jacob Van Order jacobvanorder

View GitHub Profile
@jacobvanorder
jacobvanorder / RotatingModel3D
Created March 23, 2024 17:20
Model3D Rotation Animation
//
// RotatingModel3D.swift
// VisionProPlacement
//
// Created by Jacob Van Order on 3/23/24.
//
import SwiftUI
import RealityKit
- (void)fetchTrainResponseForLine:(NSString *)lineCode
origin:(NSString *)originCode
destination:(NSString *)destinationCode
andCallback:(SGMetraTrainResponseCallback)trainResponseCallback {
NSURL *metraURL = [NSURL URLWithString:@"http://12.205.200.243/AJAXTrainTracker.svc/GetAcquityTrainData"];
NSMutableURLRequest *metraRequest = [[NSMutableURLRequest alloc] initWithURL:metraURL];
NSData *requestJson = [[NSString stringWithFormat:@"{\"stationRequest\":{\"Corridor\":\"%@\",\"Destination\":\"%@\",\"Origin\":\"%@\",\"timestamp\":\"/Date(%i-0000)/\"}}", lineCode, destinationCode, originCode, (int)[[NSDate date] timeIntervalSince1970]] dataUsingEncoding:NSUTF8StringEncoding];
[metraRequest setHTTPBody:requestJson];
@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
@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 / 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
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"
@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
@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")
@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 {
#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);