Skip to content

Instantly share code, notes, and snippets.

```swift
public class AccountViewModel: ObservableObject {
// swiftlint:disable:next line_length
public typealias Services = MilestonesAccountSectionViewModel.Services & ProfileAccountSectionViewModel.Services & ReservationsAccountSectionViewModel.Services & ContactUsAccountSectionViewModel.Services & FooterAccountSectionViewModel.Services & AboutUsAccountSectionViewModel.Services
public typealias Context = ProfileAccountSectionViewModel.Context & ReservationsAccountSectionViewModel.Context & FooterAccountSectionViewModel.Context
enum Route: Equatable {
case milestones(MilestonesAccountSectionViewModel.Route)
case profile(ProfileAccountSectionViewModel.Route)
case reservations(ReservationsAccountSectionViewModel.Route)
@cabeca
cabeca / AnyAsyncStream.swift
Last active August 4, 2021 08:23
AnyAsyncStream
#if swift(>=5.5)
@available(iOS 15.0, *)
struct AnyAsyncIterator<Element>: AsyncIteratorProtocol {
private let wrappedNext: () async throws -> Element?
init<I: AsyncIteratorProtocol>(_ asyncIterator: I) where I.Element == Element {
var asyncIterator = asyncIterator
wrappedNext = { try await asyncIterator.next() }
}
@cabeca
cabeca / simulator_populator_xcode7
Last active April 16, 2020 09:18
This script removes and recreates all simulators in Xcode 7.
#!/usr/bin/env ruby
require 'JSON'
device_types = JSON.parse `xcrun simctl list -j devicetypes`
runtimes = JSON.parse `xcrun simctl list -j runtimes`
devices = JSON.parse `xcrun simctl list -j devices`
devices['devices'].each do |runtime, runtime_devices|
runtime_devices.each do |device|
@cabeca
cabeca / simulator_populator
Created September 23, 2014 21:30
This script removes and recreates all simulators in Xcode 6.
#!/usr/bin/env ruby
device_types_output = `xcrun simctl list devicetypes`
device_types = device_types_output.scan /(.*) \((.*)\)/
runtimes_output = `xcrun simctl list runtimes`
runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/
devices_output = `xcrun simctl list devices`
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/