Skip to content

Instantly share code, notes, and snippets.

View sgr-ksmt's full-sized avatar
👉
👁👃👁

Suguru Kishimoto sgr-ksmt

👉
👁👃👁
View GitHub Profile
@sgr-ksmt
sgr-ksmt / firestore.rules
Created December 31, 2019 07:33
Convenience `firestore.rules`'s function.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Create `Path` from array of string.
function documentPath(paths) {
return path([
['databases', database, 'documents'].join('/'),
paths.join('/')
].join('/'));
}
@sgr-ksmt
sgr-ksmt / ModelA.swift
Last active November 2, 2019 10:27
PropertyWrapper+Codable crash.
struct ModelA: Codable {
@Wrap<ModelA> var a: String? = "foobar"
}
@sgr-ksmt
sgr-ksmt / AnyObserver+.swift
Last active September 9, 2022 10:07
MVVM + RxSwift + Property Wrapper
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 November 15, 2018 09:34
Issue Dynamic Link via Cloud Functions
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 October 22, 2018 02:44
RxPlayground Demo
//: 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 October 22, 2018 02:37
RxPlayground demo
import UIKit
import RxSwift
import RxCocoa
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
// PublishRelay vs BehaviorRelay
do {
let relay = PublishRelay<Int>()
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;
protocol PushNotificationPayload: Decodable {
}
protocol SubscribeContainer {
func parse(_ json: Data)
}
extension SubscribeContainer {
func parse(_ json: Data) {
[##][A-Za-zA-Za-z一-鿆0-90-9ぁ-ヶヲ-゚ー]+
// http://qiita.com/corin8823/items/75309761833d823cac6f
@sgr-ksmt
sgr-ksmt / datasource.swift
Created August 4, 2017 10:18
DataSource
protocol DataSourceSection {
associatedtype Element
var elements: [Element] { get }
}
protocol DataSource {
associatedtype Section: DataSourceSection
var sections: [Section] { get }
}