Skip to content

Instantly share code, notes, and snippets.

import Combine
import SwiftUI
extension CaseIterable where Self: Equatable{
func next() -> Self {
let all = Self.allCases
let idx = all.firstIndex(of: self)!
let next = all.index(after: idx)
return all[next == all.endIndex ? all.startIndex : next]
}
import SwiftUI
struct DemoBanner {
let title: String
let message: String
}
final class PresentBannerManager: ObservableObject {
@Published var isPresented: Bool = false
@yyokii
yyokii / gasToFirestore.js
Created July 18, 2021 04:21
Sending data from a spreadsheet to Firestore using grahamearley/FirestoreGoogleAppsScript(https://github.com/grahamearley/FirestoreGoogleAppsScript)
const email = "{ service account email }";
const key = "{ -----BEGIN PRIVATE KEY-----\n ~~ \n-----END PRIVATE KEY-----\n }"
const projectId = "{projectId}";
const firestore = FirestoreApp.getFirestore(email, key, projectId);
/**
* Demo
*/
function DemoCreateData() {
import SwiftUI
enum DialogContent: View {
case contentDetail01(isPresented: Binding<Bool>)
case contentDetail02(isPresented: Binding<Bool>)
@ViewBuilder
var body: some View {
switch self {
/*
https://fromkk.me/n/n8212b6f808c6
compactMapを先に行うことでflatMapにオプショナルではない値を流せる
*/
func loadData() {
userProfileRepository.$subscribedServices
.compactMap {[weak self] items in
self?.exploreSubscRepository.loadData(with: items.map{ $0.serviceID })
}
.flatMap(maxPublishers: .max(1)) { $0 }
// https://www.swiftbysundell.com/articles/caching-in-swift/ より
import Foundation
/// キャッシュ管理クラス。任意の値を保存でき、メモリキャッシュのみ対応。
final class Cache<Key: Hashable, Value> {
private let wrapped = NSCache<WrappedKey, Entry>()
private let dateProvider: () -> Date
private let entryLifetime: TimeInterval

git エイリアス

alias gs="git status"
alias gd="git diff"
alias gb="git branch"
alias gco="git checkout" 
alias gcm="git commit"
alias gca="git commit --amend"
alias glo="git log --oneline"
@yyokii
yyokii / weak.swift
Created September 21, 2020 14:46 — forked from ktanaka117/weak.swift
よそから参照されていない、weak参照のプロパティは即座に解放されるという話。
import UIKit
class ViewController: UIViewController {
var presenter: Presenter!
func inject(presenter: Presenter) {
self.presenter = presenter
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
@yyokii
yyokii / iosdc_2020.md
Last active September 20, 2020 04:43

iOSDC 2020

新しい、普段みないようなものを強制的にみたいね
どうせあとで全部見れるだろうし 書籍等で得られる情報なら今じゃなくてもいいかも

SourceKit-LSPをブラウザでコードを読むために活用する

ブラウザでxcodeのような体験できる

職務経歴書

基本情報

項目 内容
氏名 東原 与生 (ヒガシハラ ヨキ)
生年月日 1993/05/20
Twitter @enyyokii