Skip to content

Instantly share code, notes, and snippets.

View yoxisem544's full-sized avatar
🥑

David Lin yoxisem544

🥑
View GitHub Profile
import Foundation
enum SteakerRegex {
case email
case password
case address(String)
case chineseCharacter
var rawRegex: String {
switch self {
@yoxisem544
yoxisem544 / Refactor.swift
Created April 27, 2022 13:59
重構 77~147 行
var previous: LineChartDataSet?
let lineSets = [PE14, PE16, PE18, PE20, PE22, PE24]
let colors = [
UIColor(displayP3Red: 18/255, green: 31/255, blue: 29/255, alpha: 0.5),
UIColor(displayP3Red: 41/255, green: 196/255, blue: 180/255, alpha: 1),
UIColor(displayP3Red: 162/255, green: 212/255, blue: 209/255, alpha: 1),
UIColor(displayP3Red: 231/255, green: 197/255, blue: 105/255, alpha: 1),
UIColor(displayP3Red: 242/255, green: 162/255, blue: 110/255, alpha: 1),
UIColor(displayP3Red: 241/255, green: 129/255, blue: 97/255, alpha: 1)
]
extension String {
func match(regex pattern: String) -> [String] {
do {
let text = self
let regex = try NSRegularExpression(pattern: pattern)
let matches = regex.matches(in: text,
range: NSRange(text.startIndex..., in: text))
return matches.flatMap { match in
(0..<match.numberOfRanges).map {
//
// InteractiveLabel.swift
// Hahow2C
//
// Created by David on 2020/7/23.
// Copyright © 2020 Hahow. All rights reserved.
//
import UIKit
import Siatke
@yoxisem544
yoxisem544 / DefaultsStorage.swift
Created November 5, 2020 03:27
UserDefaults property wrapper
public protocol AnyOptional {
var isNil: Bool { get }
}
extension Optional: AnyOptional {
public var isNil: Bool { self == nil }
}
@propertyWrapper
public struct DefaultsStorage<T> where T: Codable {
@yoxisem544
yoxisem544 / KeychainStorage.swift
Created November 5, 2020 03:26
Property wrapper of keychain store
import Foundation
import KeychainAccess
//https://www.swiftbysundell.com/articles/property-wrappers-in-swift/
public protocol AnyOptional {
var isNil: Bool { get }
}
extension Optional: AnyOptional {
public var isNil: Bool { self == nil }
- cache-push:
inputs:
- cache_paths: |-
...
# 新增
$MINT_PACKAGES
- cache-push:
inputs:
- cache_paths: |-
$BITRISE_CACHE_DIR
...
# 新增以下 cache_path
$BREW_MINT
$BREW_OPT_MINT
- script:
title: Brew install
inputs:
- content: |-
# 執行上述的 install 方法,沒有套件則先安裝,有的話直接 link cache 中的套件
brew install mint
brew link mint
- script:
title: Set Env Path
inputs:
- content: |-
# 增加我們要 cache 的 brew 套件環境變數,如果有使用到其他的套件,請再手動增加
envman add --key BREW_MINT --value "$(brew --cellar)/mint" # 指定套件名稱位置
envman add --key BREW_OPT_MINT --value "/usr/local/opt/mint" # 指定套件名稱位置,此為 file alias