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
| @_spi(Internals) import ComposableArchitecture | |
| struct Bound<R: Reducer, S, V:View> { | |
| init(store: StoreOf<R>, _ s: KeyPath<R.State, S>, _ a: @escaping (S) -> R.Action, @ViewBuilder _ vb: @escaping (Binding<S>) -> V) { | |
| _state = Binding<S>{store.state.value[keyPath: s] } set:{ store.send(a($0)) } | |
| self.vb = vb | |
| } | |
| @Binding var state: S | |
| @ViewBuilder var vb: (Binding<S>) -> V |
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
| /* | |
| This source file is part of the Swift.org open source project | |
| Copyright (c) 2021 Apple Inc. and the Swift project authors | |
| Licensed under Apache License v2.0 with Runtime Library Exception | |
| See https://swift.org/LICENSE.txt for license information | |
| See https://swift.org/CONTRIBUTORS.txt for Swift project authors | |
| */ | |
| // Source: https://github.com/apple/swift-docc/blob/ddf8f0a64f4f477259ae166b84d5f064ab2887c5/bin/output-diff.swift |
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 SwiftUI | |
| extension View { | |
| public func withState<Value, V: View>(_ state: Value, @ViewBuilder content: @escaping (_ state: Binding<Value>) -> V) -> some View { | |
| modifier(WithStateModifier(state, content: content)) | |
| } | |
| } | |
| public struct WithState<Value, V: View>: View { | |
| public init(_ value: Value, @ViewBuilder content builder: @escaping (_ state: Binding<Value>) -> V) { |
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
| public enum Condition { | |
| case new | |
| case safe | |
| } | |
| public enum Transacting<T> { | |
| case known(T) | |
| case changing(known: T, tentative: T) | |
| public mutating func stage(_ value: T) { | |
| switch self { |
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
| public enum Tup { | |
| public struct A<A> { | |
| var a: A | |
| } | |
| public struct B<A, B> { | |
| var a: A | |
| var b: B | |
| } | |
| public struct C<A, B, C> { | |
| var a: A |
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
| #!/usr/bin/env bash | |
| sqlite3 "${HOME}/Library/Application Support/dev.warp.Warp-Stable/warp.sqlite" -readonly -cmd 'select cwd from terminal_panes order by id desc limit 1' '.exit' |
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
| # this relies on photos from google takeouts each being exported along with a paired json file | |
| # (photo.jpg.json <-> photo.jpg) and that this json file has a timestamp | |
| fd .jpg$ -x bash -c "exiftool -AllDates=\`cat {}.json | jq '.creationTime.timestamp' | xargs -I{} date -r {} -u +%Y-%m-%dT%H:%M:%SZ\` {}" |
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
| #!/usr/bin/env bash | |
| sanitize_node() { | |
| shopt -s extglob | |
| filename=$(basename "$1") | |
| directory=$(dirname "$1") | |
| if [ -f "$1" ]; then | |
| extension=".${filename##*.}" | |
| else |
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 { useState, useEffect } from "react"; | |
| const makeObservable = (target) => { | |
| let listeners = []; | |
| let value = target; | |
| const getter = () => { | |
| return value; | |
| }; |
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 { useEffect, useState } from "react"; | |
| const usePolling = (interval = null, pollingFunction, deps = []) => { | |
| const [subscription, setSubscription] = useState(null); | |
| useEffect(() => { | |
| if (!!interval) { | |
| const id = setInterval(pollingFunction, interval); | |
| setSubscription(id); | |
| } | |
| return () => { |