Skip to content

Instantly share code, notes, and snippets.

View alexito4's full-sized avatar

Alejandro Martínez alexito4

View GitHub Profile
@alexito4
alexito4 / Task.swift
Created October 12, 2022 21:21
SwiftUI View.task backwards compatibility
import Foundation
import SwiftUI
public extension View {
@available(iOS, obsoleted: 15.0, message: "SwiftUI.View.task is available on iOS 15.")
@_disfavoredOverload
@inlinable func task(
priority: _Concurrency.TaskPriority = .userInitiated,
@_inheritActorContext _ action: @escaping @Sendable () async -> Swift.Void
) -> some SwiftUI.View {
@alexito4
alexito4 / App.swift
Created December 2, 2021 17:53
Why does the body of FeatureView get recomputed when the alert is shown/dismissed? There is no @State on that view.
@main
struct PreviewApp: App {
var body: some Scene {
WindowGroup {
NavigationView {
AlertContainer { route in
FeatureView(route: route)
}
}
2021-06-16T14:41:27.0909702Z ##[section]Starting: Request a runner to run this job
2021-06-16T14:41:27.1958031Z Can't find any online and idle self-hosted runner in current repository that matches the required labels: 'ubuntu-latest'
2021-06-16T14:41:27.2207687Z Can't find any online and idle self-hosted runner in current repository's organization account that matches the required labels: 'ubuntu-latest'
2021-06-16T14:41:27.3009672Z Found online and idle hosted runner in current repository's organization account that matches the required labels: 'ubuntu-latest'
2021-06-16T14:41:27.4308924Z ##[section]Finishing: Request a runner to run this job
2021-06-16T14:41:34.8739654Z Current runner version: '2.278.0'
2021-06-16T14:41:34.8764440Z ##[group]Operating System
2021-06-16T14:41:34.8765340Z Ubuntu
2021-06-16T14:41:34.8765754Z 20.04.2
2021-06-16T14:41:34.8766219Z LTS
@alexito4
alexito4 / annotation with doc
Created March 11, 2021 16:02
Sourcery 1.3 regressions
CODE:
/*
docs
*/
@objc(WAGiveRecognitionCoordinator)
// sourcery: AutoProtocol, AutoMockable
class GiveRecognitionCoordinator: NSObject {
}
@alexito4
alexito4 / AutoMockable.stencil
Created August 4, 2020 07:55
Sourcery templates for automatic mocks from a concrete type
// swiftlint:disable line_length
// swiftlint:disable variable_name
import Foundation
#if os(iOS) || os(tvOS) || os(watchOS)
import UIKit
#elseif os(OSX)
import AppKit
#endif
import RxSwift

Keybase proof

I hereby claim:

  • I am alexito4 on github.
  • I am alejandromp (https://keybase.io/alejandromp) on keybase.
  • I have a public key ASBeRlhREhfheuUvVgFu8p0uvh_gwMzlE74WIJ7jk_wRtwo

To claim this, I am signing this object:

@alexito4
alexito4 / gist:42488bfcf5385467c758633e389eb62f
Created February 16, 2020 08:43
SwiftUI Mac broken foreach ?
import SwiftUI
import Combine
struct Object: Identifiable {
var id: String { name }
let name: String
}
final class Data: ObservableObject {
@alexito4
alexito4 / markAllFilesAsViewed.js
Created October 15, 2019 09:28
GitHub PR Mark ALL files as viewed
for (const checkbox of document.querySelectorAll('.js-reviewed-checkbox')) {
if (checkbox.attributes["data-ga-click"].value.includes("value:false")) {
checkbox.click();
}
}
@alexito4
alexito4 / RemoteImage.swift
Last active August 19, 2020 15:32
Rough sketch of SwiftUI RemoteImage using AlamofireImage
import SwiftUI
import Combine
import AlamofireImage
let imageDownloader = ImageDownloader(
configuration: ImageDownloader.defaultURLSessionConfiguration(),
downloadPrioritization: .fifo,
maximumActiveDownloads: 4,
imageCache: AutoPurgingImageCache()
)
@alexito4
alexito4 / lists.swift
Last active May 8, 2019 14:35
Swift script to convert Reminders export files (.ics) to lists.
#!/usr/bin/swift sh
import Foundation
guard let path = CommandLine.arguments.dropFirst().first else { exit(1) }
print(path)
let content = try! String(contentsOfFile: path)
let lines = content