This file contains 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
extension Array { | |
func after(item: T) -> T? { | |
if let index = find(self, item) where index + 1 < count { | |
return self[index + 1] | |
} | |
return nil | |
} | |
} |
This file contains 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
@interface CLKTextProvider (NNNCompoundTextProviding) | |
+ (nonnull CLKTextProvider *)nnn_textProviderByJoiningProvider:(nonnull CLKTextProvider *)provider1 andProvider:(nonnull CLKTextProvider *)provider2 withString:(nullable NSString *)joinString; | |
@end |
This file contains 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 | |
func randomNumbers(_ count: Int, totalling sum: Int) -> [Int] { | |
let randomOffsets = (0 ..< count - 1).map { _ in Int.random(in: 1 ..< sum) } | |
let range = ([0] + randomOffsets + [sum]).sorted() | |
var values: [Int] = [] | |
for i in 0 ... count - 1 { |
This file contains 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
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
@_functionBuilder | |
struct UIViewBuilder { | |
static func buildBlock(_ views: UIView...) -> [UIView] { | |
return views | |
} |
This file contains 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 | |
let cast = ["🚶♂️🚶🏻♂️🚶🏼♂️🚶🏽♂️🚶🏾♂️🚶🏿♂️🚶♀️🚶🏻♀️🚶🏼♀️🚶🏽♀️🚶🏾♀️🚶🏿♀️"] | |
var string = "Virtual #WWDC20 queue:\n" | |
while string.count <= 280 { | |
string.append(cast.randomElement()!) | |
} |
This file contains 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 ObjectiveC | |
private var subclassCounts: [String: Int] = [:] | |
func GenerateDynamicSubclass<T: NSObject>(of class: T.Type) -> T.Type! { | |
let oldClassName = NSStringFromClass(`class`) as String | |
var subclassCount = subclassCounts[oldClassName] ?? 0 | |
let className = "\(oldClassName)_DynamicSubclass_\(subclassCount)" | |
This file contains 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 MapKit | |
extension Locale { | |
var usesMilesForDistanceFormatting: Bool { | |
guard usesMetricSystem else { return true } | |
let miles = Measurement(value: 42, unit: UnitLength.miles) | |
let kilometers = miles.converted(to: .kilometers) |
This file contains 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
// | |
// FetchPublisher.swift | |
// [REDACTED] | |
// | |
// Created by Jeff Kelley on 6/20/19. | |
// Copyright © 2019 Jeff Kelley. All rights reserved. | |
// | |
import CoreData | |
import Combine |
This file contains 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
#!/bin/bash | |
# Builds all targets and places IPAs in build/ | |
# Constants | |
SIGNING_IDENTITY="iPhone Distribution: Detroit Labs, LLC" | |
# Get a list of all schemes, then build each. | |
xcodebuild -project PROJECT.xcodeproj -list | \ | |
sed -n '/Schemes/,/^$/p' | \ |
This file contains 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 | |
func paddedZip<T, U, Sequence1, Sequence2>( | |
_ sequence1: Sequence1, | |
_ sequence2: Sequence2 | |
) -> Zip2Sequence<[T?], [U?]> where | |
Sequence1 : Sequence, Sequence1.Element == T, | |
Sequence2 : Sequence, Sequence2.Element == U { | |
var array1: [T?] = [] | |
var array2: [U?] = [] |
NewerOlder