Repro script for comparing two commits with a heavier synthetic workload.
Usage:
bash swiftsoup-ab-bench.shDefaults (override with env vars):
| extension String { | |
| private static let wordLikeRegex = /([A-Z]+[^A-Z\s_]+)|(?:[\s_]|^)+([^A-Z\s_]+)/ | |
| /// Creates a copy of the current string by turning into snake case | |
| /// | |
| /// ## Example | |
| /// ```swift | |
| /// // Outputs: my_spaced_name24_long_string | |
| /// "My SpacedName24_Long_____String".snakeCased() | |
| /// ``` |
| class AudioSessionManager: NSObject, ObservableObject { | |
| @Published var microphones: [AVCaptureDevice] = [] | |
| var captureSession: AVCaptureSession = .init() | |
| var audioOutput: AVCaptureAudioDataOutput? | |
| var configured: Bool = false | |
| private var audioInput: AVCaptureDeviceInput? | |
| let dataOutputQueue = DispatchQueue(label: "audio_queue", | |
| qos: .userInteractive, |
This is straightforward, copy-pasted code from an app I'm building, where I needed to wrap NSCollectionView for SwiftUI.
It's really bad code, but it works at least.
SwiftNSCollectionView(items: ["a", "b", "a", "b", "a", "b", "a", "b", "a", "b", "a", "b", "a", "c"], itemSize: nil) { item in
Text(item)
}| // ==UserScript== | |
| // @name Youtube adblock | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.2 | |
| // @description enough with the ads! | |
| // @author 4v3ngR | |
| // @match https://*.youtube.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
| // @grant none | |
| // @run-at document-start |
| /** | |
| * MacEditorTextView | |
| * Copyright (c) Thiago Holanda 2020-2021 | |
| * https://twitter.com/tholanda | |
| * | |
| * MIT license | |
| * Modified by https://github.com/cjwcommuny for TextKit 2 | |
| */ | |
| import Combine |
| // A URLSession extension that fetches data from a URL and decodes to some Decodable type. | |
| // Usage: let user = try await URLSession.shared.decode(UserData.self, from: someURL) | |
| // Note: this requires Swift 5.5. | |
| extension URLSession { | |
| func decode<T: Decodable>( | |
| _ type: T.Type = T.self, | |
| from url: URL, | |
| keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, | |
| dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .deferredToData, | |
| dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate |
| import SwiftUI | |
| /// SwiftUI implementation of a responsive-feeling scrollview with tappable tiles. | |
| /// We use a custom UIScrollView via UIViewRepresentable and a UIView tap overlay to | |
| /// get around current SwiftUI issues with simultaneous gesture recognition and allow | |
| /// the tiles to respond instantly to presses while scrolling. | |
| struct ContentView: View { | |
| @State private var showSheet = false |
| // -- Usage | |
| struct Content: View { | |
| @State var open = false | |
| @State var popoverSize = CGSize(width: 300, height: 300) | |
| var body: some View { | |
| WithPopover( | |
| showPopover: $open, | |
| popoverSize: popoverSize, |