Skip to content

Instantly share code, notes, and snippets.

View jverkoey's full-sized avatar

Jeff Verkoeyen jverkoey

View GitHub Profile
@jverkoey
jverkoey / ios7springs.m
Created April 9, 2014 13:59
iOS 7 spring damping and stiffness calculation
@interface NSObject ()
- (void)generateSpringPropertiesForDuration:(float)arg1 damping:(float)arg2 velocity:(float)arg3;
- (id)_defaultAnimationForKey:(id)arg1;
@end
// This object calculates the damping and stiffness coefficients, given a damping value (0...1], a velocity, and a duration.
id obj = [[NSClassFromString(@"UIViewSpringAnimationState") alloc] init];
[obj generateSpringPropertiesForDuration:10 damping:0.5 velocity:10];
@jverkoey
jverkoey / ios7coefficients
Created April 9, 2014 14:21
Dump of generated coefficients from UIViewSpringAnimationState
t d v damping stiffness
0.010000 0.100000 -100.000000 2.303480 7.000000
0.010000 0.100000 -99.000000 2.301880 7.000000
0.010000 0.100000 -98.000000 2.300280 7.000000
0.010000 0.100000 -97.000000 2.298670 7.000000
0.010000 0.100000 -96.000000 2.297060 7.000000
0.010000 0.100000 -95.000000 2.295450 7.000000
0.010000 0.100000 -94.000000 2.293840 7.000000
0.010000 0.100000 -93.000000 2.292220 7.000000
0.010000 0.100000 -92.000000 2.290600 7.000000
@jverkoey
jverkoey / NSManagedObjectContext+DebugSwizzling.m
Created April 14, 2014 11:52
Core Data Managed Object Context Debugging
// NSManagedObjectContext+DebugSwizzling.h
#import <CoreData/CoreData.h>
#if DEBUG
/**
* Toggles debugging of Core Data managed object contexts.
*
* When enabled, will fire NSLogs in the following cases:
// One-off random number with seed.
srand48(seedObject.hash);
lrand48()
@jverkoey
jverkoey / NimbusKit-Model.swift
Last active August 29, 2015 14:08
A port of NimbusKit's NIModel object to Swift.
/*
Copyright (c) 2011-present, NimbusKit. All rights reserved.
This source code is licensed under the BSD-style license found at http://nimbuskit.info/license
*/
// This is ported from NimbusKit 2.0's Delegates-and-Datasources (DaDS) feature, which
// is based upon https://github.com/jverkoey/nimbus/blob/master/src/models/src/NITableViewModel.m
protocol ModelObjectInterface {
@jverkoey
jverkoey / NSNotificationCenterExtensions.swift
Last active January 24, 2016 22:19
NSNotificationCenter extension for safe Swift instance method support
/*
Copyright (c) 2011-present, NimbusKit. All rights reserved.
This source code is licensed under the BSD-style license found at http://nimbuskit.info/license
Extracted from NimbusKit: Swift Edition at https://github.com/nimbuskit/swift
*/
extension NSNotificationCenter {
/**
@jverkoey
jverkoey / LICENSE
Last active August 29, 2015 14:11
iOS rubber-banding from NimbusKit
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@jverkoey
jverkoey / NIVector.h
Created December 29, 2014 22:40
CGVector helper methods
CGVector NIVectorMakeWithPoints(CGPoint fromPoint, CGPoint toPoint);
CGVector NIVectorMakeWithPoint(CGPoint point);
CGPoint NIPointMakeWithVector(CGVector vector);
NSString* NIStringFromVector(CGVector vector);
CGFloat NIVectorLength(CGVector vector);
CGFloat NIRadiansFromReferenceVectorToVector(CGVector vector);
CGFloat NIVectorDotProduct(CGVector vector1, CGVector vector2);
extern const CGVector NIReferenceVector;
@jverkoey
jverkoey / CoreAnimationLeak.m
Last active November 14, 2015 09:27
Core Animation leak
// Radar: http://openradar.appspot.com/radar?id=6067475636551680
@interface View : UIView
@end
@implementation View
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
}
@jverkoey
jverkoey / DTSendSignalFlag
Created July 10, 2015 20:51
DTSendSignalFlag
// As seen here http://www.freelancemadscience.com/fmslabs_blog/2012/9/18/advanced-profiling-with-the-dtperformancesession-framework.html
// and here: http://stackoverflow.com/questions/20269630/xcode-instruments-trace-comparison
// This was sadly broken in iOS 7 and flags no longer show up in Instruments. Any ideas?
#define DT_KEY_USERID "DT_KEY_USERID"
#define DT_KEY_SOURCE "DT_KEY_SOURCE"
#define DT_KEY_BACKTRACE "DT_KEY_BACKTRACE"
#define DT_KEY_TIMESEC "DT_KEY_TIMESEC"
#define DT_KEY_TIMENSEC "DT_KEY_TIMENSEC"