<ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/
<ProjectName>.xcodeproj/xcshareddata/
| /path/to/1 $ git format-patch sha1^..sha1 | |
| /path/to/1 $ cd /path/to/2 | |
| /path/to/2 $ git am -3 /path/to/1/0001-…-….patch |
| import UIKit | |
| import PlaygroundSupport | |
| extension UIView { | |
| /// Anchor self to `view` center x and y axis. | |
| /// | |
| /// - parameters: | |
| /// - centerX: Center align to the view along the x axis. | |
| /// - centerY: Center align to the view along the y axis. |
| import UIKit | |
| func printTimeElapsedExecuting(title: String, operation: () -> Void) { | |
| let startTime = CFAbsoluteTimeGetCurrent() | |
| operation() | |
| let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime | |
| print("Time elapsed for \(title): \(timeElapsed)s.") | |
| } | |
| func timeElapsedInSecondsExecuting(operation: () -> Void) -> Double { |
| import Foundation | |
| /// Normalise a value to a 0...1 range. | |
| func normalise(value: Double, lower: Double, upper: Double) -> Double { | |
| return max(0.0, min(1.0, (value - lower) / (upper - lower))) | |
| } | |
| normalise(value: 0, lower: 0, upper: 2) // -> 0 | |
| normalise(value: 1, lower: 0, upper: 2) // -> 0.5 | |
| normalise(value: 22, lower: 0, upper: 50) // -> 0.44 |
| git fsck --lost-found |
| defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES |
| import Foundation | |
| extension Dictionary where Key == String { | |
| func valueForInsensitive<T>(key: Key) -> T? { | |
| let key = keys.first { $0.compare(key, options: .caseInsensitive) == .orderedSame } ?? key | |
| return self[key] as? T | |
| } | |
| } |
| import Foundation | |
| enum Debug { | |
| static func print(_ item: @autoclosure () -> Any, separator: String = " ", terminator: String = "\n") { | |
| #if DEBUG | |
| Swift.print(item(), separator: separator, terminator: terminator) | |
| #endif | |
| } | |
| } |