Skip to content

Instantly share code, notes, and snippets.

View d-date's full-sized avatar
🏠
Working from home

Daiki Matsudate d-date

🏠
Working from home
View GitHub Profile
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
@d-date
d-date / project.yml
Last active March 17, 2024 21:17
XcodeGen Example
name: XXXX
attributes:
LastUpgradeCheck: 1140
ORGANIZATIONNAME: "kankak, Inc."
options:
bundleIdPrefix: com.xxxx.xxxxxxxx
deploymentTarget:
iOS: 13.1.3
configs:
Develop Debug: debug
@d-date
d-date / UIActivityType+PopularServices.swift
Created March 14, 2018 10:08
Share extension for popular apps
private extension UIActivityType {
static let postToLINE = UIActivityType("jp.naver.line.Share")
static let gmail = UIActivityType("com.google.Gmail.ShareExtension")
static let postToSlack = UIActivityType("com.tinyspeck.chatlyio.share")
static let facebookMessanger = UIActivityType("com.facebook.Messenger.ShareExtension")
static let tweetbot4 = UIActivityType("com.tapbots.Tweetbot4.shareextension")
static let evernote = UIActivityType("com.evernote.iPhone.Evernote.EvernoteShare")
static let bear = UIActivityType("net.shinyfrog.bear-iOS.Bear-iPhone-Sharing-Extension")
}
@d-date
d-date / BundleCurrent.swift
Created April 22, 2023 09:10
Workaround for previewing SwiftPM resources
// 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 {}
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 }
@d-date
d-date / CoreSpotlight.swift
Last active December 14, 2020 06:02
Core Spotlight
import CoreSpotlight
import Foundation
#if canImport(UniformTypeIdentifiers)
import UniformTypeIdentifiers
#endif
import MobileCoreServices
struct ShopIndexHandler {
static let `default` : ShopIndexHandler = .init()
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
}
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 }
}
import UIKit
open class VStackViewController: UIViewController {
public let scrollView: UIScrollView = .init()
public let stackView: UIStackView = {
let stackView: UIStackView = .init()
stackView.axis = .vertical
stackView.alignment = .fill
stackView.distribution = .equalSpacing
stackView.spacing = 0
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)