Skip to content

Instantly share code, notes, and snippets.

@yasuradodo
yasuradodo / Persistence.swift
Created May 8, 2022 14:10
Handy Persistence class in Swift
// Handy Persistence class in Swift which use `subscript` syntax
final class Persistence {
struct Key<Value> {
let name: String
}
private let userDefaults: UserDefaults
init(userDefaults: UserDefaults = UserDefaults.standard) {
@yasuradodo
yasuradodo / HalfSheetModal.swift
Created February 27, 2022 08:55
HalfSheetModal in SwiftUI
import SwiftUI
extension View {
func halfModal<Sheet: View>(
showing: Binding<Bool>,
@ViewBuilder sheet: @escaping () -> Sheet
) -> some View {
background(
HalfModalSheet(
sheet: sheet,
@yasuradodo
yasuradodo / git_command.md
Last active November 20, 2021 03:03
Git command

Remove local branches which are gone in remote

git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
@yasuradodo
yasuradodo / UITableView+UITableViewCell.swift
Created April 2, 2020 17:31
handy UITableView extension for UITableViewCell
extension UITableView {
func register<T: UITableViewCell>(nibCellType: T.Type) {
let className = nibCellType.className
let nib = UINib(nibName: className, bundle: nil)
register(nib, forCellReuseIdentifier: className)
}
func register<T: UITableViewCell>(cellType: T.Type) {
let className = cellType.className
register(cellType, forCellReuseIdentifier: className)