echo -e "> \033[1;92m git branch\033[0m"
git branch | nl
BRANCHINDEX=`echo $1 | xargs`
BRANCHNAME=`git branch | sed -n "$BRANCHINDEX p" | sed "s/\*//g"`
// 1. | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
dataSource = CardListDataSource( | |
tableView: tableView, | |
onPlusTapped: { self in | |
self.launchCardIssue() | |
}) | |
} |
// test | |
{ | |
"aps": { | |
"alert": { | |
"title": "hello", | |
"body": "this is a push notification" | |
}, | |
"sound": "default" | |
} | |
} |
import Foundation | |
import Tagged | |
struct Product: Codable { | |
let id: ProductID | |
let descr: String | |
typealias ProductID = Tagged<Product, UUID> | |
} |
import UIKit | |
// | |
// ViewModel, all KVO compliant to ViewController can observe changes in a decouple way. | |
// | |
class MyViewModel: NSObject { | |
@objc dynamic var firstName:String = "" | |
@objc dynamic var lastName: String = "" | |
// Fullname, concatenation of first and last. |
enum Easing { | |
// Linear interpolation (no easing) | |
case linear | |
// Quadratic easing; p^2 | |
case quadraticIn | |
case quadraticOut | |
case quadraticInOut | |
// Cubic easing; p^3 | |
case cubicIn | |
case cubicOut |
// Fisher–Yates Array shuffle | |
extension Array { | |
func shuffledArray() -> Array { | |
var arr = self | |
for i in 0..<count { | |
print(count - i) | |
let j = i + Int(arc4random_uniform(UInt32(count - i))) | |
let tmp = arr[i] | |
arr[i] = arr[j] |
public struct DictArray<Key: Hashable, Value> : CustomDebugStringConvertible { | |
private typealias Bucket = [Value] | |
private var buckets: [ Key: Bucket ] | |
init() { | |
buckets = [:] | |
} | |
public mutating func add(value:Value, key:Key) { | |
var bucket:Bucket |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
super.prepare(for: segue, sender: sender) | |
var indexPath:IndexPath? = nil | |
if let cell = sender as? UITableViewCell { | |
indexPath = tableView.indexPath(for: cell) | |
} | |
if let button = sender as? UIButton { | |
let buttonFrame = button.convert(button.bounds, to:tableView) | |
indexPath = tableView.indexPathForRow(at: buttonFrame.origin) |
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) { | |
tableView.beginUpdates() | |
} | |
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange sectionInfo: NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType) { | |
switch type { | |
case .insert: | |
tableView.insertSections(IndexSet(integer: sectionIndex), with: .fade) | |
case .delete: | |
tableView.deleteSections(IndexSet(integer: sectionIndex), with: .fade) |