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 CreditCardBrand: String { | |
enum Pattern { | |
static let visa = #"^4[0-9]{12}(?:[0-9]{3})?"# | |
static let master = #"^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$"# | |
static let amex = #"^3[47][0-9]{13}$"# | |
static let diners = #"^3(?:0[0-5]|[68][0-9])[0-9]{11,13}$"# | |
static let discover = #"^6(?:011|5[0-9]{2})[0-9]{12}$"# | |
static let jcb = #"^(?:2131|1800|35\d{3})\d{7}"# | |
} |
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 SwiftUI | |
public struct DatePickerTextField: View { | |
/// Config | |
var components: DatePicker.Components | |
@Binding var date: Date | |
var formattedString: (Date) -> String | |
/// View properties | |
@State private var viewID: String = UUID().uuidString | |
@FocusState private var isActive |
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
// Workaround for Bundle resource when running on Xcode previews | |
// https://forums.swift.org/t/xcode-previews-swiftpm-resources-xcpreviewagent-crashed/51680/10 | |
// https://developer.apple.com/forums/thread/664295?answerId=673644022#673644022 | |
// https://gist.github.com/ctreffs/ad9d23e08d586cf75e4d1c3bb1b1061f | |
import class Foundation.Bundle | |
import class Foundation.ProcessInfo | |
private class BundleFinder {} |
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 EmailAddress: RawRepresentable, Codable { | |
let rawValue: String | |
init?(rawValue: String) { | |
let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue) | |
let range = NSRange(rawValue.startIndex..<rawValue.endIndex,in: rawValue) | |
let matches = detector?.matches(in: rawValue, options: [], range: range) | |
guard let match = matches?.first, matches?.count == 1 else { return nil } |
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 CoreSpotlight | |
import Foundation | |
#if canImport(UniformTypeIdentifiers) | |
import UniformTypeIdentifiers | |
#endif | |
import MobileCoreServices | |
struct ShopIndexHandler { | |
static let `default` : ShopIndexHandler = .init() |
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 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 |
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 | |
import ImageIO | |
extension UIImage { | |
public static func gifImage(data: Data) -> UIImage? { | |
guard let source = CGImageSourceCreateWithData(data as CFData, nil) else { | |
print("image doesn't exist") | |
return nil | |
} |
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
name: XXXX | |
attributes: | |
LastUpgradeCheck: 1140 | |
ORGANIZATIONNAME: "kankak, Inc." | |
options: | |
bundleIdPrefix: com.xxxx.xxxxxxxx | |
deploymentTarget: | |
iOS: 13.1.3 | |
configs: | |
Develop Debug: debug |
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 | |
let intJson = #"{ "inUse": 1, "name": "Daiki Matsudate", "twitter": "d_date", "stars": 99999, "occupation": null}"# | |
let boolJson = #"{ "inUse": true, "name": "Daiki Matsudate", "twitter": "d_date", "stars": 99999, "occupation": null}"# | |
protocol Inherits { | |
associatedtype SuperType | |
var `super`: SuperType { get } | |
} |
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
let of = Observable.of(1,2,3) | |
.do(onNext: { print($0) }) | |
let just = Observable.just(4) | |
.do(onNext: { print($0) }) | |
let error = Observable<Any?>.error(FakeError()) | |
.do(onError: { print($0) }) | |
Observable.zip(of, just, error) | |
.subscribe() | |
.disposed(by: disposeBag) |
NewerOlder