https://unix.stackexchange.com/a/293941
read -n 1 -s -r -p "Press any key to continue"
https://unix.stackexchange.com/a/293941
read -n 1 -s -r -p "Press any key to continue"
// | |
/* | |
* Created by 游宗諭 in 2021/5/26 | |
* | |
* Using Swift 5.0 | |
* | |
* Running on macOS 11.4 | |
*/ | |
import Combine |
// MARK: - UserRecord | |
struct UserRecord: Codable { | |
let name: String | |
@PolymorphicValue | |
var pet: Animal | |
} | |
import XCTest |
let containerCellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, OutlineItem> { cell, _, menuItem in | |
var contentConfiguration = cell.defaultContentConfiguration() | |
contentConfiguration.text = menuItem.title | |
if menuItem.imageName != nil { | |
contentConfiguration.image = UIImage(systemName: menuItem.imageName!) | |
} | |
contentConfiguration.textProperties.font = .preferredFont(forTextStyle: .headline) |
/* Also working with UIControl, UITableViewCell */ | |
class Cell: UICollectionViewCell { | |
override var isHighlighted: Bool { | |
didSet { | |
let duration = isHighlighted | |
? 0.45 | |
: 0.4 | |
let transform = isHighlighted | |
? CGAffineTransform(scaleX: 0.96, y: 0.96) | |
: CGAffineTransform.identity |
// | |
/* | |
* Created by 游宗諭 in 2021/2/26 | |
* | |
* Using Swift 5.0 | |
* | |
* Running on macOS 10.15 | |
*/ | |
import UIKit |
# Protocol, ["TopLevel", "ClassImplementation"] | |
snippet protocol | |
protocol <#name#> { | |
<#requirements#> | |
} | |
# Struct, ["TopLevel", "ClassImplementation"] | |
snippet struct | |
struct <#name#> { | |
<#fields#> | |
} |
@propertyWrapper struct Lock<Value> { | |
private var inner: LockInner | |
init(wrappedValue: Value) { | |
inner = LockInner(wrappedValue) | |
} | |
var wrappedValue: Value { | |
get { return inner.value } | |
nonmutating _modify { |
extension Result { | |
func tryMap<T>(_ transform:(Success) throws -> T) -> Result<T, Swift.Error> { | |
switch self { | |
case let .success(success): | |
do { | |
return .success(try transform(success)) | |
} catch { | |
return .failure(error) | |
} | |
case let .failure(failure): |