Skip to content

Instantly share code, notes, and snippets.

View MarcoSantarossa's full-sized avatar

Marco Santarossa MarcoSantarossa

View GitHub Profile
import XCTest
@testable import SampleApp
final class SampleAppTests: XCTestCase {
func testExample() {
expect("myValue").not().toBeNil()
expect(5).toBe(5)
import UIKit
typealias EmptyClosure = () -> Void
final class MyEW {
let onDo: EmptyClosure
init(onDo: @escaping EmptyClosure) {
self.onDo = onDo
}
protocol Localizable {
associatedtype LocalizableKey
static var tableName: String? { get }
static func localize(key: LocalizableKey, localizer: LocalizerType) -> String
}
extension Localizable where LocalizableKey: RawRepresentable {
static var tableName: String? {
final class CacheLRU<Key: Hashable, Value> {
private struct CachePayload {
let key: Key
let value: Value
}
private let capacity: Int
private let list = DoublyLinkedList<CachePayload>()
private var nodesDict = [Key: DoublyLinkedListNode<CachePayload>]()
@MarcoSantarossa
MarcoSantarossa / AsyncOperation.swift
Last active August 2, 2023 13:23
How to write and use an asynchronous operation
import Foundation
class AsyncOperation: Operation {
enum State: String {
case isReady, isExecuting, isFinished
}
override var isAsynchronous: Bool {
return true
}