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
# Pull Request の差分に対して swift-format でフォーマットして commit & push する GitHub Actions の設定 | |
name: swift-format | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '**/*.swift' |
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
public protocol IDProtocol: RawRepresentable, Hashable, Sendable, Identifiable, Codable, CustomStringConvertible where RawValue: Hashable & Sendable & Codable & CustomStringConvertible {} | |
extension IDProtocol { | |
public init(_ value: RawValue) { | |
self.init(rawValue: value)! | |
} | |
// MARK: CustomStringConvertible | |
public var description: String { rawValue.description } |
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
// https://www.w3.org/TR/WCAG20/ | |
// Contrast ratio | |
// Relative luminance | |
import UIKit | |
extension UIColor { | |
convenience init(hex: UInt, alpha: CGFloat = 1) { | |
self.init(red: CGFloat((hex & 0xff0000) >> 16) / 255, | |
green: CGFloat((hex & 0x00ff00) >> 8) / 255, |
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 UIKit | |
final class ViewController: UITableViewController { | |
private var names: [String] = (50...99).map { String($0) } | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
DispatchQueue.main.asyncAfter(deadline: .now() + 3.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
import Foundation | |
private extension CFStringTokenizer { | |
var hiragana: String { string(to: kCFStringTransformLatinHiragana) } | |
var katakana: String { string(to: kCFStringTransformLatinKatakana) } | |
private func string(to transform: CFString) -> String { | |
var output: String = "" | |
while !CFStringTokenizerAdvanceToNextToken(self).isEmpty { | |
output.append(letter(to: transform)) |
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
#!/bin/bash | |
# Google Sheets の最終行に追記するスクリプト | |
# 訳あって最終行の位置を特定するために行数を取得している | |
# OAuth周りは下記がわかりやすい | |
# https://qiita.com/shin1ogawa/items/49a076f62e5f17f18fe5 | |
CLIENT_ID="Google API ClientID" | |
CLIENT_SECRET="Google API's client secret" | |
REFRESH_TOKEN="Google API's refresh token" |
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
public struct Extension<Base> { | |
public let base: Base | |
public init(_ base: Base) { | |
self.base = base | |
} | |
} | |
public protocol ExtensionCompatible { | |
associatedtype Compatible | |
var ex: Extension<Compatible> { get set } |
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 Sequence where Iterator.Element: Hashable { | |
var unique: [Iterator.Element] { | |
var checked: Set<Iterator.Element> = [] | |
return filter { checked.insert($0).inserted } | |
} | |
} | |
extension Sequence where Iterator.Element: Equatable { | |
var unique: [Iterator.Element] { | |
reduce([]) { $0.contains($1) ? $0 : $0 + [$1] } |
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
// refers to https://qiita.com/imk2o/items/1771682e9665865851e1 | |
import Foundation | |
protocol UserDefaultConvertible { | |
init?(with object: Any) | |
func object() -> Any? | |
} | |
extension UserDefaultConvertible { |
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
#!/bin/sh | |
# setting | |
COMMAND=/opt/cisco/anyconnect/bin/vpn | |
GROUP='' | |
USER='' | |
SERVICE='Cisco AnyConnect' | |
PASS=`security find-generic-password -a "${USER}" -s "${SERVICE}" -w` | |
PASS2='' | |
HOST='' |
NewerOlder