This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| func mergeArrays<T: Comparable>(left: [T], _ right: [T]) -> [T] { | |
| var leftIndex = 0 | |
| var rightIndex = 0 | |
| var orderedArray = [T]() | |
| while leftIndex < left.count && rightIndex < right.count { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public protocol A { | |
| func methodName() | |
| } | |
| extension A { | |
| func methodName(differentParam: Any) {} | |
| } | |
| class Test: A {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let someRanges = [1..<4, 1..<8, 1..<16, 1..<32, 1..<64, 1..<128, 1..<256, 1..<512, 1..<1024] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CustomLayerView<T: CALayer>: UIView { | |
| var customLayer: T { | |
| get { | |
| return self.layer as! T | |
| } | |
| } | |
| override class func layerClass() -> AnyClass { | |
| return T.self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -Xfrontend -debug-time-function-bodies | |
| Found somewhere: | |
| pbpaste | egrep '\.[0-9]ms' | sort -t "." -k 1 -n | tail -20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import UIKit | |
| import Nimble | |
| func scroll(_ axis: UILayoutConstraintAxis) -> ScrollMatcher { | |
| return ScrollMatcher(axis: axis) | |
| } | |
| struct ScrollMatcher: Matcher { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import UIKit | |
| /// A `UIScrollView` subclass that adapts its `intrinsicContentSize` to its `contentSize` | |
| final class IntrinsicSizeAwareScrollView: UIScrollView { | |
| private let keyPath = NSStringFromSelector(#selector(getter: contentSize)) | |
| override init(frame: CGRect) { | |
| super.init(frame: frame) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| /// Creates a Test dummy of the needed type! | |
| /// Works with any value type or class (?) | |
| func dummy<T>() -> T { | |
| let size = MemoryLayout<T>.size | |
| let alignment = MemoryLayout<T>.alignment | |
| let p = UnsafeMutableRawPointer.allocate(bytes: size, alignedTo: alignment) | |
| return p.bindMemory(to: T.self, capacity: 1).pointee |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // CallRecordMatcher.swift | |
| // Verse | |
| // | |
| // Created by Alex Manzella on 13/01/17. | |
| // Copyright © 2017 Verse Technologies, Inc. All rights reserved. | |
| // | |
| import Foundation | |
| import Nimble |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //: Playground - noun: a place where people can play | |
| import Foundation | |
| public struct ConstraintPriority : ExpressibleByFloatLiteral, Equatable, Strideable { | |
| public typealias FloatLiteralType = Float | |
| public typealias Stride = Float | |
| public let value: Float |