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 Unimplemented | |
| @Unimplemented | |
| protocol Logger { | |
| func log(message: String) | |
| } | |
| // Generated: | |
| // struct UnimplementedLogger: Logger { | |
| // init() {} |
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
| protocol Overrideable {} | |
| extension Overrideable { | |
| mutating func `override`<Input: Equatable, Output>( | |
| method: WritableKeyPath<Self, @Sendable (Input) async throws -> Output>, | |
| expectedInput: Input, | |
| returning value: Output, | |
| name: String | |
| ) { | |
| let expectation = expectation(description: name) |
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 | |
| class CounterSortaActor { | |
| let queue = DispatchQueue(label: "CounterQueue") | |
| private var _count = 0 | |
| var count: Int { | |
| get { | |
| queue.sync { _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
| import PlaygroundSupport | |
| import SwiftUI | |
| import UIKit | |
| final class LabelledImage: UIView { | |
| let label = UILabel() | |
| let image = UIImageView() | |
| 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
| @dynamicMemberLookup | |
| class Observable<T> { } | |
| extension Observable { | |
| func map<Result>(_ transform: @escaping (T) -> Result) -> Observable<Result> { | |
| // Apply transform function here | |
| fatalError() | |
| } | |
| subscript<Property>(dynamicMember keyPath: KeyPath<T, Property>) -> Observable<Property> { |
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 PlaygroundSupport | |
| import SwiftUI | |
| struct Pokemon { | |
| let dexNum: Int | |
| let species: String | |
| } | |
| extension Pokemon: Identifiable { | |
| var id: Int { return dexNum } |
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 requests | |
| import functools | |
| url = 'https://petition.parliament.uk/petitions/241584.json' | |
| json = requests.get(url).json() | |
| signatures = json['data']['attributes']['signatures_by_country'] | |
| get_signature_count = lambda country: country['signature_count'] | |
| get_uk = lambda x: x['name'] == 'United Kingdom' |
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 CreateMLUI | |
| let builder = MLImageClassifierBuilder() | |
| builder.showInLiveView() |
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
| func daysInMonth(year: Int, month: Int) -> Int { | |
| switch (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0), month) { | |
| case (true, 2): | |
| return 29 | |
| case (false, 2): | |
| return 28 | |
| case (_, 1), (_, 3), (_, 5), (_, 7), (_, 8), (_, 10), (_, 12): | |
| return 31 | |
| default: | |
| return 30 |
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
| //: HashMap data structure | |
| public struct HashMap<Key: Hashable, Value> { | |
| typealias Element = (key: Key, value: Value) | |
| var arraySize: Int | |
| var numberInserted = 0 | |
| var array: [Element?] | |
| var loadFactor: Double { | |
| return Double(numberInserted) / Double(arraySize) | |
| } |
NewerOlder