Skip to content

Instantly share code, notes, and snippets.

View marty-suzuki's full-sized avatar
Back to the future

Taiki Suzuki marty-suzuki

Back to the future
View GitHub Profile
@marty-suzuki
marty-suzuki / DynamicUserDefaults.swift
Created June 9, 2019 04:40
Sample usage of Swift 5.1 dynamicMemberLookup that supports KeyPath.
import Foundation
@dynamicMemberLookup
final class DynamicUserDefaults {
static var standard: DynamicUserDefaults {
return DynamicUserDefaults(.standard)
}
private let keys = Keys()
@marty-suzuki
marty-suzuki / iosMain_GC.kt
Last active October 17, 2021 04:40
An Adapter of Kotlin native GarbageCollector for iOS project
import kotlin.native.internal.GC as internalGC
/**
* https://github.com/JetBrains/kotlin/blob/1.5.30/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/GC.kt
*/
object GC {
var threshold: Int
get() = internalGC.threshold
set(value) { internalGC.threshold = value }
import Combine
import FirebaseAuth
public struct CombineAuth {
fileprivate let auth: Auth
}
extension CombineAuth {
public enum Error: Swift.Error {
@marty-suzuki
marty-suzuki / WPTextAttachment.h
Created February 19, 2016 11:20 — forked from stuartjmoore/WPTextAttachment.h
Creates an NSTextAttachment the takes up the entire width of the line fragment (while maintaining its aspect ratio). Instead of a simple image, any UIView (that has a (CGFloat)heightThatFits method) will work.
//
// WPTextAttachment.h
// ReadArticle
//
// Created by Moore, Stuart on 12/27/13.
// Copyright (c) 2013 The Washington Post. All rights reserved.
//
#import <UIKit/UIKit.h>
import Combine
import SwiftUI
struct ContentView: View {
@ObservedObject var viewModel = ViewModel()
var body: some View {
Button("Refresh") { viewModel.objectWillChange.send() }
ScrollView(.vertical) {
LazyVStack {
Pod::Spec.new do |spec|
module PrivateRepository
class Spec
attr_reader :version
attr_reader :homepage
attr_reader :source
def initialize(owner, name, version, source)
@version = version
@homepage = "https://github.com/#{owner}/#{name}"
@source = source
enum _Value<Initial, Changed> {
case initial(Initial)
case changed(Changed)
}
typealias StateRepresentable<T> = _Value<T, T>
typealias ChangeHandleable<T> = _Value<Void, T>
extension _Value where Initial == Void {
static func initial() -> _Value<Void, Changed> {
@marty-suzuki
marty-suzuki / UnioSystem.swift
Last active May 17, 2020 05:51
https://github.com/cats-oss/Unio で公開しているFrameworkの動きを簡易的に表現しています
// Playgroundでの実行を想定しているのでCombineを利用
import Combine
// MARK: - CombineをRxSwiftのように定義する
typealias Observable<T> = AnyPublisher<T, Error>
typealias PublishRelay<T> = PassthroughSubject<T, Never>
typealias BehaviorRelay<T> = CurrentValueSubject<T, Never>
typealias DisposeBag = [AnyCancellable]
// MARK: - Output関連
// Playgroundでの実行を想定しているのでCombineを利用
import Combine
// MARK: - CombineをRxSwiftのように定義する
typealias Observable<T> = AnyPublisher<T, Error>
typealias PublishRelay<T> = PassthroughSubject<T, Never>
typealias BehaviorRelay<T> = CurrentValueSubject<T, Never>
typealias DisposeBag = [AnyCancellable]
/// valueのsetterを非公開にしたBehaviorRelay
@startuml
package Reversi.app {
class ViewController {
~ viewModel: ReversiViewModelType
}
}
package ReversiLogic.framework {
class ReversiViewModel {
+ input: InputWrapper<ReversiViewModel.Input>