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 | |
# Measure time | |
# Usage: stopwatch [start|stop|print] | |
function stopwatch { | |
case "$1" in | |
start) | |
# start new stopwatch | |
STOPWATCH+=($(date -u +%s)) | |
;; |
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 CryptoKit | |
import Dependencies | |
import Foundation | |
import XCTestDynamicOverlay | |
public struct GravatarJSON: Equatable, Sendable, Codable { | |
public init(entry: [Entry]) { | |
self.entry = entry | |
} |
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 Logging | |
extension _ReducerPrinter { | |
/// Logs info about received actions and state changes to swift-log's Logger with provided label. | |
/// | |
/// Example usage: | |
/// ``` | |
/// let store = Store(initialState: AppFeature.State()) { | |
/// AppFeature()._printChanges(.swiftLog(label: "tca")) |
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 SwiftUI | |
struct Parent: Reducer { | |
struct State: Equatable { | |
@PresentationState var child: Child.State? | |
} | |
enum Action: Equatable { | |
case presentChildButtonTapped |
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
/// MIT License | |
/// | |
/// Copyright (c) 2023 Dariusz Rybicki Darrarski | |
/// | |
/// Permission is hereby granted, free of charge, to any person obtaining a copy | |
/// of this software and associated documentation files (the "Software"), to deal | |
/// in the Software without restriction, including without limitation the rights | |
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
/// copies of the Software, and to permit persons to whom the Software is | |
/// furnished to do so, subject to the following conditions: |
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 | |
@dynamicMemberLookup | |
public actor CurrentValueAsyncSequence<Value>: AsyncSequence where Value: Sendable { | |
public typealias Element = Value | |
public init(_ value: Value) { | |
self.value = value | |
} |
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 | |
struct EmojiPickerView: UIViewRepresentable { | |
@Binding var isFirstResponder: Bool | |
var onPick: (String) -> Void | |
var onDelete: () -> Void | |
func makeUIView(context: Context) -> UIViewType { | |
UIViewType(view: self) | |
} |
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 XCTestDynamicOverlay | |
{% for func in functions %} | |
public struct {% for text in func.name|split:"(" %}{% if forloop.first %}{{ text|upperFirstLetter }}{% endif %}{% endfor %} { | |
public var run: ({% for param in func.parameters %}{{ param.typeName }}{% ifnot forloop.last %}, {% endif %}{% endfor %}){% if func.throws %} throws{% endif %} -> {{ func.returnTypeName }} | |
public func callAsFunction({% if func.parameters.count > 0 %} | |
{% for param in func.parameters %} | |
{{ param.asSource }}{% ifnot forloop.last %},{% endif %} | |
{% endfor %} |
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 | |
struct ExampleView: View { | |
var body: some View { | |
Color.blue | |
.gesture( | |
TapGesture(count: 1) | |
.simultaneously(with: DragGesture(minimumDistance: 0)) | |
.onEnded { value in | |
if value.first != nil, let location = value.second?.startLocation { |
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 | |
struct InterfaceOrientationObservingViewModifier: ViewModifier { | |
let onChange: (UIInterfaceOrientation) -> Void | |
func body(content: Content) -> some View { | |
content.background(InterfaceOrientationObservingView(onChange: onChange)) | |
} | |
} |
NewerOlder