Skip to content

Instantly share code, notes, and snippets.

🕶
I may be slow to respond.

Suguru Kishimoto sgr-ksmt

🕶
I may be slow to respond.
Block or report user

Report or block sgr-ksmt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sgr-ksmt
sgr-ksmt / AnyObserver+.swift
Last active Sep 19, 2019
MVVM + RxSwift + Property Wrapper
View AnyObserver+.swift
extension AnyObserver {
static func create<E>(_ relay: PublishRelay<E>) -> AnyObserver<E> {
return .init { event in
guard case let .next(value) = event else { return }
relay.accept(value)
}
}
static func create<E>(_ relay: BehaviorRelay<E>) -> AnyObserver<E> {
return .init { event in
@sgr-ksmt
sgr-ksmt / sample.ts
Created Nov 15, 2018
Issue Dynamic Link via Cloud Functions
View sample.ts
import * as functions from 'firebase-functions'
import * as request from 'request-promise-native'
export namespace IssueDynamicLink {
export interface Request {
params: DynamicLinkParameters
}
export interface Response {
url: string
@sgr-ksmt
sgr-ksmt / source.swift
Created Oct 22, 2018
RxPlayground Demo
View source.swift
//: Playground - noun: a place where people can play
import UIKit
import RxSwift
import RxCocoa
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
// PublishRelay vs BehaviorRelay
do {
@sgr-ksmt
sgr-ksmt / source.swift
Created Oct 22, 2018
RxPlayground demo
View source.swift
import UIKit
import RxSwift
import RxCocoa
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
// PublishRelay vs BehaviorRelay
do {
let relay = PublishRelay<Int>()
View bug_firestore.rules
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() {
return request.auth != null;
}
match /user/{userID} {
allow read: if isAuthenticated();
allow create: if true;
allow update: if request.writeFields.size() == 1;
View _.swift
protocol PushNotificationPayload: Decodable {
}
protocol SubscribeContainer {
func parse(_ json: Data)
}
extension SubscribeContainer {
func parse(_ json: Data) {
View gist:0c5c1007b93d5fed3af44c5de0f057ab
[##][A-Za-zA-Za-z一-鿆0-90-9ぁ-ヶヲ-゚ー]+
// http://qiita.com/corin8823/items/75309761833d823cac6f
View datasource.swift
protocol DataSourceSection {
associatedtype Element
var elements: [Element] { get }
}
protocol DataSource {
associatedtype Section: DataSourceSection
var sections: [Section] { get }
}
@sgr-ksmt
sgr-ksmt / gta.swift
Created Jul 29, 2017
Generic Type Aliases
View gta.swift
typealias Generator<T> = (CIImage) -> T?
func outputCGImage<T: CGImage>(generator: Generator<T>) -> T? {
return filter.outputImage.flatMap(generator)
}
func outputUIImage<T: UIImage>(generator: Generator<T>) -> T? {
return filter.outputImage.flatMap(generator)
}
View set.swift
var set: Set<Int> = [1,2,3,4]
func f1<T>(value: T, set: inout Set<T>) {
if set.contains(value) {
set.remove(value)
} else {
set.insert(value)
}
}
You can’t perform that action at this time.