Skip to content

Instantly share code, notes, and snippets.

📱
Swifting

Julian Caicedo juliancadi

📱
Swifting
Block or report user

Report or block juliancadi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Combine+Ext.swift
extension Publisher {
public func on(_ f: @escaping (Self.Output) -> Void) -> AnyPublisher<Self.Output, Self.Failure> {
self.map {
f($0)
return $0
}.eraseToAnyPublisher()
}
}
@juliancadi
juliancadi / nested.swift
Last active Nov 15, 2019
Nested closures
View nested.swift
import Foundation
class Closureception {
deinit {
print("⚠️ Deallocated")
}
// MARK: - Cases
View MIGRATION_03_04.kt
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)")
View StorageStatusRepository.kt
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") }
}
@juliancadi
juliancadi / list.output
Last active Jan 8, 2019
'xcrun simctl list' && 'xcrun simctl —version' output
View list.output
== 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)
@juliancadi
juliancadi / NiblessView.swift
Last active Dec 4, 2018
Nibless UIView in favor of initializer dependency injection.
View NiblessView.swift
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."
@juliancadi
juliancadi / NiblessViewController.swift
Last active Dec 4, 2018
Nibless UIViewController in favor of initializer dependency injection.
View NiblessViewController.swift
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."
@juliancadi
juliancadi / SomeType.swift
Last active Sep 7, 2018
Sequence extension with class having generic types
View SomeType.swift
import Foundation
struct SomeType<T> {
let property: T
}
extension Sequence {
func doMagic<T>() -> [T] where Element == SomeType<T> {
return self.map { $0.property }
You can’t perform that action at this time.