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 | |
| struct ContentView: View { | |
| @State var show = false | |
| @State var height: CGFloat = 250 | |
| var body: some View { | |
| List { | |
| Button("Pop Sheet") { | |
| height = 250 | |
| show.toggle() |
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 | |
| @available(macOS 14, iOS 17, tvOS 17, watchOS 10, *) | |
| /// Allows you to use an existing Predicate as a ``StandardPredicateExpression`` | |
| struct VariableWrappingExpression<T>: StandardPredicateExpression { | |
| let predicate: Predicate<T> | |
| let variable: PredicateExpressions.Variable<T> | |
| func evaluate(_ bindings: PredicateBindings) throws -> Bool { | |
| // resolve the variable |
On MacOS, cmd-tab only toggles between different apps. To toggle between different windows of the same app, you need to use cmd-` . However this is cumbersome for regular usage, as it requires stretching your fingers unnaturally. This rule allows to use cmd-CapsLock instead, which is much easier.
- Install Karabiner Elements and give it all permissions it asks for
cd ~/.config/karabiner/assets/complex_modificationsand put the json file below there- Restart Karabiner Elements
- Go to "Complex Modifications > Add rule"
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
| // ==UserScript== | |
| // @name Prevent keyboard shortcut hijacking | |
| // @description Prevent websites to hijack keyboard shortcuts, for example <Ctrl+F> on Discourse | |
| // @namespace Violentmonkey Scripts | |
| // @match *://*/* | |
| // @grant none | |
| // @version 1.0 | |
| // @author notDavid | |
| // ==/UserScript== |
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
| extension Task where Failure == Error { | |
| // Start a new Task with a timeout. If the timeout expires before the operation is | |
| // completed then the task is cancelled and an error is thrown. | |
| init(priority: TaskPriority? = nil, timeout: TimeInterval, operation: @escaping @Sendable () async throws -> Success) { | |
| self = Task(priority: priority) { | |
| try await withThrowingTaskGroup(of: Success.self) { group -> Success in | |
| group.addTask(operation: operation) | |
| group.addTask { | |
| try await _Concurrency.Task.sleep(nanoseconds: UInt64(timeout * 1_000_000_000)) |
NewerOlder