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 SwiftUI | |
@Observable @MainActor | |
final class ViewModel { | |
var name: String { "Foo" } | |
} | |
class ObservableFoo: ObservableObject {} | |
struct ContentView: View { |
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
/// Add a noop action into your main reducer, don't do anything in that action, just return .none | |
/// __run the app in RELEASE to get all optimizations enabled __ | |
/// Add this code at the end of your app finish launching delegate call (or onAppear on main view if not using delegate) | |
// The Interquartile Range (IQR) method is a robust technique used in statistics to measure the spread of data and identify outliers. It is less sensitive to extreme values compared to other methods like standard deviation | |
func removeOutliers(from array: [Double]) -> [Double] { | |
func quartiles(of array: [Double]) -> (Double, Double) { | |
let sortedArray = array.sorted() | |
let count = sortedArray.count |
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
#!/usr/bin/env bash | |
<% for type in types.classes { -%> | |
<%_ if type.modifiers.map{ $0.name }.contains("final") || type.modifiers.map{ $0.name }.contains("open") || types.based[type.name].isEmpty == false { continue } -%> | |
<%_ _%>git grep -lz 'class <%= type.name %>' | xargs -0 perl -i'' -pE "s/class <%= type.name %>(?=\s|:)/final class <%= type.name %>/g" | |
<% } %> | |
// Run with Sourcery on your codebase and then execute generated code via bash :) |
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 ComposableArchitecture | |
import Difference | |
import Foundation | |
/// A container for storing action filters. | |
/// | |
/// The logic behind having this rather than a normal closure is that it allows us to namespace and gather action filters together in a consistent manner. | |
/// - Note: You should be adding extensions in your modules and exposing common filters you might want to use to focus your debugging work, e.g. | |
/// ```swift | |
/// extension ActionFilter where Action == AppAction { |
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 Combine | |
import Foundation | |
/// This protocols allows you to declare your type as having a distinct network | |
/// representation. | |
/// | |
/// Rather than writing and maintaining a custom `Decodable` implementation for | |
/// your type, declare a brand new struct that exactly matches the expected | |
/// network response, and then write an initializer for your actual type that | |
/// accepts a `NetworkResponse`. |
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 | |
public protocol VersionType: CaseIterable, Codable, Comparable, RawRepresentable {} | |
public extension VersionType where RawValue: Comparable { | |
static func < (a: Self, b: Self) -> Bool { | |
return a.rawValue < b.rawValue | |
} | |
} |
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 CloudKit | |
import Combine | |
/// Fetches the user's CloudKit Account status. | |
/// | |
/// - Parameter container: The container to check the status in. | |
/// | |
/// - Returns: A deferred future that resolves to the user's CloudKit Account status. | |
func getAccountStatus(for container: CKContainer) -> AnyPublisher<CKAccountStatus, Error> { | |
Deferred { |
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
@main | |
struct ListBugApp: App { | |
var body: some Scene { | |
WindowGroup { | |
NavigationView { // comment out navigation view and list works | |
ContentView() | |
Text("Detail") | |
} | |
} | |
} |
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
#!/bin/zsh | |
cd "$(dirname "$0")/.." | |
if [[ -n "$CI" ]] || [[ $1 == "--fail-on-errors" ]] ; then | |
FAIL_ON_ERRORS=true | |
echo "Running in --fail-on-errors mode" | |
ERROR_START="" | |
COLOR_END="" | |
INFO_START="" |
NewerOlder