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 | |
struct SomeType<T> { | |
let property: T | |
} | |
extension Sequence { | |
func doMagic<T>() -> [T] where Element == SomeType<T> { | |
return self.map { $0.property } |
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 UIKit | |
open class NiblessViewController: UIViewController { | |
public init() { | |
super.init(nibName: nil, bundle: nil) | |
} | |
@available(*, unavailable, | |
message: "Loading this view controller from a nib is unsupported in favor of initializer dependency injection." |
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 UIKit | |
open class NiblessView: UIView { | |
public override init(frame: CGRect) { | |
super.init(frame: frame) | |
} | |
@available(*, unavailable, | |
message: "Loading this view from a nib is unsupported in favor of initializer dependency injection." |
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
== Device Types == | |
iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s) | |
iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5) | |
iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s) | |
iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6) | |
iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus) | |
iPhone 6s (com.apple.CoreSimulator.SimDeviceType.iPhone-6s) | |
iPhone 6s Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus) | |
iPhone 7 (com.apple.CoreSimulator.SimDeviceType.iPhone-7) | |
iPhone 7 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus) |
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
private val externalStoragePath: String? | |
@RequiresApi(Build.VERSION_CODES.O) | |
get() { | |
val externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null) | |
if (externalFilesDirs.size == 1 && Environment.isExternalStorageEmulated()) { return null } | |
return externalFilesDirs.filterNotNull().firstOrNull { file -> | |
Environment.MEDIA_MOUNTED == EnvironmentCompat.getStorageState(file) && | |
!file.path.contains(Environment.getExternalStorageDirectory().path) | |
}?.path.also { logger.debug("External memory path $it") } | |
} |
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
database.execSQL("DROP TABLE ${AudioItemEntity.TABLE_NAME}") | |
database.execSQL("CREATE TABLE IF NOT EXISTS ${AudioItemEntity.TABLE_NAME} (`audioItemId` INTEGER PRIMARY KEY NOT NULL, `audioChannelId` INTEGER NOT NULL, `audioId` TEXT NOT NULL, `audioDescription` TEXT NOT NULL, `duration` INTEGER NOT NULL, `volume` INTEGER NOT NULL, `fileName` TEXT NOT NULL, `index` INTEGER NOT NULL)") |
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 | |
class Closureception { | |
deinit { | |
print("⚠️ Deallocated") | |
} | |
// MARK: - Cases |
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 Publisher { | |
public func on(_ f: @escaping (Self.Output) -> Void) -> AnyPublisher<Self.Output, Self.Failure> { | |
self.map { | |
f($0) | |
return $0 | |
}.eraseToAnyPublisher() | |
} | |
} |
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
class Result<Success, Error extends Exception> { | |
final Success? successIfAny; | |
final Error? errorIfAny; | |
const Result.success(this.successIfAny) : errorIfAny = null; | |
const Result.error(this.errorIfAny) : successIfAny = null; | |
Result<Success, Error> onSuccess(Function(Success) handler) { | |
if (successIfAny == null) return this; | |
handler(successIfAny as Success); |