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
// | |
// ContentView.swift | |
// search-test | |
// | |
// Created by Alex on 5/15/24. | |
// | |
import SwiftUI | |
import SwiftUI |
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 SomeManager { | |
private var tasks: [String: DataTask] = [:] | |
private func data(for request: URLRequest) async throws -> Data { | |
let requestKey = request.urlRequest?.url?.absoluteString ?? "" | |
let task = tasks[requestKey] ?? DataTask(task: Task { | |
try await self._data(for: request, key: requestKey) | |
}) | |
let subscriptionID = UUID() | |
task.subscriptions.insert(subscriptionID) |
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
CREATE TABLE ZSTATSRECORDVALUE ( Z_PK INTEGER PRIMARY KEY, Z_ENT INTEGER, Z_OPT INTEGER, ZSTATSRECORD INTEGER, ZBESTVIEWSPERDAYCOUNT INTEGER, ZPOSTSCOUNT INTEGER, ZVIEWSCOUNT INTEGER, ZVISITORSCOUNT INTEGER, ZINSIGHTYEAR INTEGER, ZMOSTPOPULARDAYOFWEEK INTEGER, ZMOSTPOPULARDAYOFWEEKPERCENTAGE INTEGER, ZMOSTPOPULARHOUR INTEGER, ZMOSTPOPULARHOURPERCENTAGE INTEGER, ZTOTALCOMMENTSCOUNT INTEGER, ZTOTALIMAGESCOUNT INTEGER, ZTOTALLIKESCOUNT INTEGER, ZTOTALPOSTSCOUNT INTEGER, ZTOTALWORDSCOUNT INTEGER, ZCLICKSCOUNT INTEGER, ZPARENT INTEGER, ZVIEWSCOUNT1 INTEGER, ZDOWNLOADCOUNT INTEGER, ZCOUNT INTEGER, ZTYPE INTEGER, ZTYPE1 INTEGER, ZCOMMENTSCOUNT INTEGER, ZLIKESCOUNT INTEGER, ZPOSTID INTEGER, ZVIEWSCOUNT2 INTEGER, ZOTHERCOUNT INTEGER, ZTOTALCOUNT INTEGER, ZFOLLOWERSCOUNT INTEGER, ZVIEWSCOUNT3 INTEGER, ZPARENT1 INTEGER, ZVIEWSCOUNT4 INTEGER, ZCURRENTSTREAKLENGTH INTEGER, ZLONGESTSTREAKLENGTH INTEGER, ZPOSTCOUNT INTEGER, ZSTREAKINSIGHT INTEGER, ZTYPE2 INTEGER, ZVIEWSCOUNT5 INTEGER, ZPARENT2 INTEGER, ZCOMMENTSCOUNT1 INTEG |
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
// The MIT License (MIT) | |
// | |
// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). | |
import SwiftUI | |
public protocol ScrollViewPrefetcherDelegate: AnyObject { | |
/// Returns all valid indices for the collection. | |
func getAllIndicesForPrefetcher(_ prefetcher: ScrollViewPrefetcher) -> Range<Int> | |
func prefetcher(_ prefetcher: ScrollViewPrefetcher, prefetchItemsAt indices: [Int]) |
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
// The MIT License (MIT) | |
// | |
// Copyright (c) 2020–2022 Alexander Grebenyuk (github.com/kean). | |
import Pulse | |
import Foundation | |
import ObjectiveC.runtime | |
#if DEBUG | |
extension Experimental { |
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 | |
/// Input: | |
/// | |
/// public static let purple = UIColor(red: 74/255, green: 21/255, blue: 153/255, alpha: 1.0) | |
/// | |
/// Output: | |
/// | |
/// #4A1599 (74, 21, 153) | |
/// public static let purple = #colorLiteral(red: 0.2901960784, green: 0.0823529412, blue: 0.6, alpha: 1) |
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
// The MIT License (MIT) | |
// | |
// Copyright (c) 2020 Alexander Grebenyuk (github.com/kean). | |
import Foundation | |
#if !os(macOS) | |
import UIKit | |
#else | |
import AppKit | |
#endif |
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 UIKit | |
// Almost pseudocode, but should be possible to write in proper Swift | |
// MARK: High-Level APIs | |
// Decodes the document. By default, ignores errors and warnings. | |
func decode(data: Data, isStrict: Bool = false) -> throws OpenAPI.Document { | |
let parser = JSONDecoder().decoder(DocumentParser.self, from: data) | |
// Or maybe be even more granular: "strict", "ignoreWarnings", "ignoreAll"? |
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
extension URLRequest { | |
public func cURLDescription() -> String { | |
guard let url = url, let method = httpMethod else { | |
return "$ curl command generation failed" | |
} | |
var components = ["curl -v"] | |
components.append("-X \(method)") | |
for header in allHTTPHeaderFields ?? [:] { | |
let escapedValue = header.value.replacingOccurrences(of: "\"", with: "\\\"") | |
components.append("-H \"\(header.key): \(escapedValue)\"") |
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
enum APIEnvironment: String, CaseIterable { | |
case dev | |
case test | |
case stage | |
case prod | |
} | |
struct ContentView: View { | |
@State private var selection: APIEnvironment? = env | |
NewerOlder