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 SwiftSyntax | |
import SwiftSyntaxMacros | |
import SwiftCompilerPlugin | |
public enum SerialError: Error, CustomStringConvertible { | |
case invalidInput | |
case invalidOutput | |
public var description: String { | |
switch 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
/// A queue that executes async functions in order, and atomically. | |
/// That is, each enqueued func executes fully before the next one is started. | |
struct AsyncSerialQueue { | |
typealias Block = () async throws -> [Int] | |
private struct Item { | |
let block: Block | |
let continuation: CheckedContinuation<[Int], Error> | |
} |
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 AppStoreConnect_Swift_SDK | |
func updateMetadata(forBundleID bundleID: String) async throws { | |
let configuration = try! APIConfiguration(issuerID: "...", privateKeyID: "...", privateKey: "...") | |
let provider = APIProvider(configuration: configuration) | |
// Get app | |
let appRequest = APIEndpoint.v1 | |
.apps | |
.get(parameters: .init(filterBundleID: [bundleID], include: [.appInfos, .appStoreVersions])) |
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
actor Queue { | |
private var tasks: [() async -> Void] = [] | |
func enqueue(_ task: @escaping () async -> Void) { | |
tasks.append(task) | |
Task { await runNext() } | |
} | |
private func runNext() async { | |
guard !tasks.isEmpty else { return } |
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
struct Label: Hashable { | |
var label: String | |
} | |
protocol LabelUniquing { | |
var label: Label { get } | |
} | |
extension LabelUniquing { |
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
// | |
// Lightweight but powerful state machine. | |
// | |
// Usage: | |
// enum TrafficLight: State { | |
// case red, orange, green | |
// } | |
// | |
// var trafficLights = StateMachine<TrafficLight>(initialState: .red) | |
// trafficLights.addRoute(from: .red, to: .green) |
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 | |
import SwiftUI | |
import Combine | |
let dateFormatter: DateFormatter = { | |
let dateFormatter = DateFormatter() | |
dateFormatter.locale = Locale(identifier: "en_US_POSIX") | |
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" | |
return dateFormatter | |
}() |
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 python | |
import sys, os.path | |
import os | |
import json | |
from xml.dom.minidom import parse | |
rootdir = os.getcwd() | |
lgPaths = ["iOS/AuthKitUI.lg", "iOS/CalendarUIKit.lg", "iOS/iCloudDriveSettings.lg", "iOS/MobileNotes.lg", "macOS/CalendarUI.lg", "macOS/Finder_FE.lg", "macOS/Finder_FinderKit.lg", "macOS/iCloudPrefPane.lg", "macOS/Notes.lg", "macOS/Reminders.lg", "macOS/TextEdit.lg"] | |
languageDirs = ["Dutch", "French"] |
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
Here is some SwiftUI code I have. | |
------ | |
NavigationView { | |
List(translations) { translation in | |
Button(action: { | |
self.dataSource.selectedTranslationId = translation.id | |
}) { | |
TranslationCell(translation: translation) | |
} | |
} |
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 | |
struct Small { | |
var i: Int | |
var j: Int | |
} | |
var s = Small(i: 1, j: 2) | |
DispatchQueue.global(qos: .background).async { |
NewerOlder