Skip to content

Instantly share code, notes, and snippets.

View yoxisem544's full-sized avatar
🥑

David Lin yoxisem544

🥑
View GitHub Profile
@sebj
sebj / AnyInsettableShape.swift
Last active September 1, 2023 09:36
AnyInsettableShape
/// A type-erased shape that is able to inset itself to produce another shape.
///
/// See: [AnyShape](https://developer.apple.com/documentation/swiftui/anyshape), [InsettableShape](https://developer.apple.com/documentation/swiftui/insettableshape)
struct AnyInsettableShape: InsettableShape {
private let _sizeThatFits: (ProposedViewSize) -> CGSize
private let _path: (CGRect) -> Path
private let _inset: (CGFloat) -> AnyInsettableShape
init<S>(_ shape: S) where S : InsettableShape {
@pofat
pofat / LaunchTracker.swift
Created February 22, 2023 02:10
Get permain and check if it's prewarm
/// iOS 15+
func isPrewarm() -> Bool {
if let prewawrmEnv = ProcessInfo.processInfo.environment["ActivePrewarm"],
prewawrmEnv == "1" {
return true
} else {
return false
}
}
@ViewBuilder
private func build<#name#>(_ viewStore: ViewStoreType) -> some View {
}
@ethanhuang13
ethanhuang13 / FacebookAuth.swift
Last active March 28, 2024 08:24
FacebookAuth is for iOS app developers who need to support Facebook login but don't want to use the official SDK
//
// FacebookAuth.swift
// GitHub: ethanhuang13
// Twitter: @ethanhuang13
import AuthenticationServices
import SafariServices
/*
Updated:
@yesleon
yesleon / UIWindow+AuthenticationSession.swift
Last active July 13, 2020 03:51
A wrapper around ASWebAuthenticationSession and SFAuthenticationSession.
//
// Usage:
//
// Facebook:
//
// 1. Follow this guide (WITHOUT setting up a URL scheme in Xcode):
// https://github.com/fullstackreact/react-native-oauth/issues/76#issuecomment-335902057
//
// 2. call startFacebookAuthenticationSession(appID:completionHandler:) on a window:
//
enum Equality<T: Equatable> {
case equal(T)
case notEqual
}
func == <T: Equatable>(lhs: T, rhs: T) -> Equality<T> {
if lhs == rhs {
return .equal(lhs)
} else {
return .notEqual
import Combine
import UIKit
public protocol CombineCompatible {}
// MARK: - UIControl
public extension UIControl {
final class Subscription<SubscriberType: Subscriber, Control: UIControl>: Combine.Subscription where SubscriberType.Input == Control {
private var subscriber: SubscriberType?
private let input: Control
@greenchiu
greenchiu / Promise.swift
Last active March 26, 2020 13:49
Practice Promise
import Foundation
enum PromiseError: Error {
case invaild
}
public struct AsyncExecutor {
public static let main = AsyncExecutor()
public static let background = AsyncExecutor(qos: .default)
private let queue: DispatchQueue
//
// MapHelper.swift
//
// Created by Michael Vieth on 1/6/20.
//
import Foundation
import GoogleMaps
import GoogleMapsBase
import MapKit
// Created by Marcin Krzyzanowski
import Foundation
public protocol JSONEncodable: Encodable { }
public extension JSONEncodable {
func toJSON(using encoder: @autoclosure () -> JSONEncoder = JSONEncoder()) throws -> String {
try String(decoding: encoder().encode(self), as: UTF8.self)
}