This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
typealias BatchUpdatable = Identifiable & Equatable | |
/// 배치 업데이트를 위한 비교 모델 | |
/// | |
struct BatchUpdates { | |
let deleted: [Int] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TaskCancelledOnDismissView.swift | |
// SwiftUITaskWorkout | |
// | |
// Created by Paul Hudson. | |
// https://twostraws.gumroad.com/l/concurrency | |
// | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TaskWithIdView.swift | |
// SwiftUITaskWorkout | |
// | |
// | |
// Created by Paul Hudson. | |
// https://twostraws.gumroad.com/l/concurrency | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 배열의 조합 구하기 | |
/// 순서에 상관없이 같은 요소가 포함되어 있다면, 같은 조합으로 처리 (결국 처음 제공되는 배열 요소들의 순서를 유지한다) | |
/// - Parameters: | |
/// - arr: 제공되는 배열 | |
/// - select: 몇개의 요소를 선택해서 조합할지 결정 | |
/// - Returns: 제공된 배열에서 select 개를 선택해서 조합된 새 배열 | |
func getPermutations(_ arr: [Book], select: Int) -> [[Book]] { | |
var results: [[Book]] = [] | |
if select == 1 { | |
return arr.map { [$0] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Int { | |
/// 숫자 범위에 따라 텍스트 표시 | |
func readableCount() -> String { | |
let formatter = NumberFormatter() | |
formatter.numberStyle = .decimal | |
formatter.groupingSeparator = "" | |
formatter.maximumFractionDigits = 1 | |
switch self { | |
case _ where self < 1000: | |
return "\(self)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 배열의 모든 조합 구하기 (순열) | |
/// 순서에 상관하여 같은 요소라도 순서가 다르면 다른 조합으로 처리 | |
/// - Parameters: | |
/// - arr: 제공되는 배열 | |
/// - select: 몇개의 요소를 선택해서 조합할지 결정 | |
/// - Returns: 제공된 배열에서 select 개를 선택해서 조합된 새 배열 | |
func getAllPermutations(_ arr: [Int], select: Int) -> [[Int]] { | |
var results: [[Int]] = [] | |
if select == 1 { | |
return arr.map { [$0] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NullIterable<E> on Iterable<E> { | |
E? getFirstOrNull(bool test(E element)) { | |
try { | |
return this.firstWhere(test); | |
} catch (e) { | |
return null; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// [Page] 배열에서 movies 값만 모아 가져오기. | |
extension Array where Element == Page { | |
var movies: [String] { | |
flatMap { $0.movies } | |
} | |
} | |
/// Page 샘플 | |
struct Page { | |
let movies: [String] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from Node.js 하이 퍼포먼스 | |
var users = {}; | |
function getUser(id, next) { | |
if (users.hasOwnPropoerty(id)) { | |
if (users[id].hasOwnProperty("data")) { | |
return next(null, users[id].data); | |
} | |
// 아직 값이 없음 |
NewerOlder