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
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
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
#!/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
import PlaygroundSupport | |
import UIKit | |
/// Solver for cubic bezier curve with implicit control points at (0, 0) and (1, 1) | |
/// Based on https://github.com/adobe/webkit/blob/master/Source/WebCore/platform/graphics/UnitBezier.h | |
struct UnitBezier { | |
private let a: CGPoint | |
private let b: CGPoint | |
private let c: CGPoint | |
private let epsilon: CGFloat = 0.000001 |
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
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
public final class Extension<Base> { | |
public let base: Base | |
public init(_ base: Base) { | |
self.base = base | |
} | |
} | |
public struct StaticExtension<Base> { } | |
public protocol ExtensionCompatible { |
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"sort" | |
"time" | |
) |
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
func reduce<T,R>(list: [T], block: (([R],T) -> R?)) -> [R]? { | |
var acc = [R]() | |
for x in list { | |
if let val = block(acc, x) { | |
acc += [val] | |
} | |
} | |
return acc | |
} |