View gas.js
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
/// パスから末尾の拡張子を取得する | |
function getFileExtension(path) { | |
let splitted= url.split("."); | |
return splitted[splitted.length - 1]; | |
} | |
/// Google Driveのルート直下の指定の名前の | |
/// フォルダを作成または取得する | |
function getTargetFolder(folderName) { | |
let rootFolder = DriveApp.getRootFolder(); |
View WeakObject.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
import Foundation | |
final class WeakObject<T: AnyObject> { | |
weak var _object: T? | |
init(_ object: T) { | |
_object = object | |
} | |
} |
View String+hexRepresentation.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
private func _hexString<I: BinaryInteger>(_ value: I) -> String { | |
"0x" + String(value, radix: 16) | |
} | |
extension Character { | |
func hexRepresentation() -> String { | |
unicodeScalars | |
.map { _hexString($0.value) } | |
.joined(separator: ", ") | |
} |
View AVAsset+Extension.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
extension AVAsset { | |
private func _generator(size: CGSize) -> AVAssetImageGenerator { | |
let generator = AVAssetImageGenerator(asset: self) | |
generator.maximumSize = size | |
generator.appliesPreferredTrackTransform = true | |
return generator | |
} | |
func extractUIImageAsync(size: CGSize) -> Single<UIImage?> { | |
let generator = _generator(size: size) |
View Decodable+Extension.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 extension KeyedDecodingContainerProtocol { | |
func decode<T: Decodable>(forKey key: Key) throws -> T { | |
try decode(T.self, forKey: key) | |
} | |
func decodeSafe<T: Decodable>(forKey key: Key, defaultValue: T) -> T { | |
(try? decode(T.self, forKey: key)) ?? defaultValue | |
} | |
} |
View EmptyDecoded.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
import Foundation | |
public protocol EmptyInitializable { | |
init() | |
} | |
extension Int: EmptyInitializable {} | |
extension String: EmptyInitializable {} | |
extension Array: EmptyInitializable {} | |
extension Bool: EmptyInitializable {} |
View UIKit+lerp.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
// | |
// UIKit+lerp.swift | |
// ha1f | |
// | |
extension CGRect { | |
/// 線形補間した中間矩形を返す | |
/// - parameter otherRect: 目指す先の矩形 | |
/// - parameter rate: 0-1の間の値。0なら自分と、1ならotherRectと同じ。 | |
func lerp(_ otherRect: CGRect, rate: CGFloat) -> CGRect { |
View CopyableLabel.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
import UIKIt | |
class CopyableLabel: UILabel { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
_commonInit() | |
} | |
required init?(coder: NSCoder) { | |
super.init(coder: coder) |
View UIImagePickerController+Rx.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
extension Reactive where Base: UIImagePickerController { | |
static func createAndPresent(from parent: UIViewController?, animated: Bool = true, configureImagePicker: @escaping (UIImagePickerController) throws -> Void = { x in }) -> Observable<[UIImagePickerController.InfoKey: Any]> { | |
return Observable.create { [weak parent] observer in | |
let imagePicker = UIImagePickerController() | |
let dismissDisposable = imagePicker.rx | |
.didCancel | |
.subscribe(onNext: { [weak imagePicker] _ in | |
guard let imagePicker = imagePicker else { | |
return | |
} |
View URLBuilder.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
/// JavaのStringBuilder的なインターフェースを想定 | |
final class URLBuilder { | |
private var components: URLComponents | |
init?(string: String) { | |
guard let components = URLComponents(string: string) else { | |
return nil | |
} | |
self.components = components | |
} |
NewerOlder