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 MCP | |
| #if canImport(FoundationEssentials) | |
| import FoundatioNEssentials | |
| #else | |
| import Foundation | |
| #endif | |
| public protocol MCPTool<Input, Output>: Sendable { | |
| associatedtype Input |
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 StringProtocol { | |
| subscript(_ offset: Int) -> String.Element { | |
| if offset >= 0 { | |
| self[index(startIndex, offsetBy: offset)] | |
| } else { | |
| self[index(endIndex, offsetBy: offset)] | |
| } | |
| } | |
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
| // TODO: Depend on https://github.com/21GramConsulting/Beton instead |
The docs for GitHub show a command to create a key with the ed25519 encryption method which is not allowed by Xcode. Even if you are not using the Source Control features in Xcode you will often need to use an account with GitHub when you are consuming Swift packages which are pulled from GitHub.
For SSH keys there are 4 algorithms.
- 🚨 DSA: This is an older algorithm which is no longer supported and is superceded with more modern algorithms.
⚠️ RSA: This algorithm was an improvement but it is now outdated and a more modern method should be used.- 👀 ECDSA: Another improvement which is dependent on your computer's ability to generate random numbers.
- ✅ Ed25519: The most recommended public-key algorithm today which you should use with GitHub.
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
| class FloatingPanel: NSPanel { | |
| init(contentRect: NSRect, backing: NSWindow.BackingStoreType, defer flag: Bool) { | |
| // Not sure if .titled does affect anything here. Kept it because I think it might help with accessibility but I did not test that. | |
| super.init(contentRect: contentRect, styleMask: [.nonactivatingPanel, .resizable, .closable, .fullSizeContentView], backing: backing, defer: flag) | |
| // Set this if you want the panel to remember its size/position | |
| // self.setFrameAutosaveName("a unique name") | |
| // Allow the pannel to be on top of almost all other windows |
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 Collection { | |
| func parallelMap<T>( | |
| parallelism requestedParallelism: Int? = nil, | |
| _ transform: @escaping (Element) async throws -> T | |
| ) async throws -> [T] { | |
| let defaultParallelism = 2 | |
| let parallelism = requestedParallelism ?? defaultParallelism | |
| let n = self.count | |
| if n == 0 { |
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
| enum Nullable<T>: Codable where T: Codable { | |
| case some(_ value: T) | |
| case null | |
| case undefined | |
| init(from decoder: Decoder) throws { | |
| let container = try decoder.singleValueContainer() | |
| if container.decodeNil() { | |
| self = .null | |
| } 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
| struct User: Equatable { | |
| var firstName: String | |
| var lastName: String | |
| } | |
| @main | |
| struct MyApp: App { | |
| @State var value = User(firstName: "", lastName: "") | |
| @State var showEdit = false | |
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 | |
| @_functionBuilder struct XMLBuilder { | |
| static func buildBlock(_ content: String) -> String { | |
| return content | |
| } |
NewerOlder









