Skip to content

Instantly share code, notes, and snippets.

Avatar
👉
👁👃👁

Suguru Kishimoto sgr-ksmt

👉
👁👃👁
View GitHub Profile
@sgr-ksmt
sgr-ksmt / StoryboardInstantiatable.swift
Last active Nov 15, 2021
Create UIViewController from storyboard and pass parameter safely.
View StoryboardInstantiatable.swift
public protocol StoryboardInstantiatable {
static var storyboardName: String { get }
static var viewControllerIdentifier: String? { get }
static var bundle: Bundle? { get }
}
public extension StoryboardInstantiatable where Self: UIViewController {
public static var storyboardName: String {
return String(describing: self)
}
@sgr-ksmt
sgr-ksmt / UIView+NibInstantiatable.swift
Last active Oct 20, 2021
Load ViewController from Storyboard or View from Xib (These are same name.) Require : Swift 2.0
View UIView+NibInstantiatable.swift
protocol NibInstantiatable {
static var NibName: String { get }
}
extension NibInstantiatable {
static var NibName: String { return String(Self) }
static func instantiate() -> Self {
return instantiateWithName(NibName)
@sgr-ksmt
sgr-ksmt / AnyObserver+.swift
Last active Sep 13, 2021
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 / dart.json
Created Nov 6, 2020
VSCode Snippet: river_pod provider template
View dart.json
{
"prvdr": {
"prefix": "prvdr",
"body": [
"import 'package:hooks_riverpod/hooks_riverpod.dart';",
"final ${1:${TM_FILENAME_BASE/((^[a-z])|_([a-z]))/${2:/downcase}${3:/upcase}/g}} = Provider$2((ref) => ${TM_FILENAME_BASE/((^[a-z])|_([a-z]))/${2:/upcase}${3:/upcase}/g}(ref.read));",
"",
"class ${TM_FILENAME_BASE/((^[a-z])|_([a-z]))/${2:/upcase}${3:/upcase}/g} {",
" const ${TM_FILENAME_BASE/((^[a-z])|_([a-z]))/${2:/upcase}${3:/upcase}/g}(this._read);",
" final Reader _read;",
@sgr-ksmt
sgr-ksmt / zenkaku_hankaku.swift
Last active Jul 15, 2021
[Swift] : 文字列の全角/半角の変換 + 数字だけ半角/全角変換
View zenkaku_hankaku.swift
extension String {
private func convertFullWidthToHalfWidth(reverse: Bool) -> String {
let str = NSMutableString(string: self) as CFMutableString
CFStringTransform(str, nil, kCFStringTransformFullwidthHalfwidth, reverse)
return str as String
}
var hankaku: String {
return convertFullWidthToHalfWidth(false)
}
@sgr-ksmt
sgr-ksmt / file.swift
Created Sep 26, 2016
Safe DispatchQueue.main.sync (Swift3.0)
View file.swift
extension DispatchQueue {
class func mainSyncSafe(execute work: () -> Void) {
if Thread.isMainThread {
work()
} else {
DispatchQueue.main.sync(execute: work)
}
}
class func mainSyncSafe<T>(execute work: () throws -> T) rethrows -> T {
@sgr-ksmt
sgr-ksmt / firestore.rules
Created Dec 31, 2019
Convenience `firestore.rules`'s function.
View firestore.rules
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 / Contents.swift
Last active Oct 19, 2020
JSONDecoder+keypath
View Contents.swift
//: Playground - noun: a place where people can play
import UIKit
var json: String = """
{
"result": {
"persons": [
{
@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 / job_description_2020-04-01.md
Last active Jun 26, 2020
2020/05以降のお仕事を探しています。
View job_description_2020-04-01.md

募集

2020年5月以降(早くて4月中旬以降)を目処に、副業先を探しています。

連絡先

TwitterのDM或いは、以下のメールアドレス宛にお願いします。([at]→@)

melodydance.k.s+biz[at]gmail.com