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
protocol RxRequestProtocol { | |
func get<U: Decodable>(returnType: U.Type, path: String, query: [String: String]?, token: String?) -> Observable<U> | |
func get(path: String, query: [String: String]?, token: String?) -> Observable<Void> | |
func post<T: Encodable, U: Decodable>(returnType: U.Type, path: String, query: [String: String]?, body: T, token: String?) -> Observable<U> | |
func post<T: Encodable>(path: String, query: [String: String]?, body: T, token: String?) -> Observable<Void> | |
func put<T: Encodable, U: Decodable>(returnType: U.Type, path: String, query: [String: String]?, body: T, token: String?) -> Observable<U> | |
func put<T: Encodable>(path: String, query: [String: String]?, body: T, token: String?) -> Observable<Void> | |
func delete<U: Decodable>(returnType: U.Type, path: String, query: [String: String]?, token: String?) -> Observable<U> | |
func delete(path: String, query: [String: String]?, token: String?) -> Observable<Void> | |
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 synchronize<T>(_ single: Single<T>) -> (element: T?, error: Error?) { | |
var element: T? | |
var error: Error? | |
let condition = NSCondition() | |
condition.lock() | |
_ = single.subscribe({ event in | |
condition.lock() | |
switch event { | |
case .success(let elm): element = elm | |
case .error(let err): error = err |
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
enum Logger { | |
static let dateFormatter: DateFormatter = { | |
let df = DateFormatter() | |
df.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS" | |
return df | |
}() | |
static func log(_ item: String, file: String = #file, line: UInt = #line, function: String = #function) { | |
printLikeRxDebug(item, file, line, function) | |
} | |
static func isMainThread(file: String = #file, line: UInt = #line, function: String = #function) { |
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 | |
import Differentiator | |
struct SingleSectionModel<ItemType: Equatable> { | |
var items: [ItemType] | |
init(items: [ItemType]) { | |
self.items = items | |
} | |
} |
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
@IBDesignable | |
final class ClipToRoundView: UIView { | |
@IBInspectable | |
var fillColor: UIColor = .white { | |
didSet { | |
shapeLayer.fillColor = fillColor.cgColor | |
} | |
} | |
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 | |
protocol Roundable { | |
var cornerRadius: CGFloat { get set } | |
} | |
protocol Borderable { | |
var borderWidth: CGFloat { get set } | |
var borderColor: UIColor? { get set } | |
} | |
protocol Shadowable { |
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
# vim: syntax=ruby | |
private_lane :custom_slack do |options| | |
ENV["TZ"] = "Asia/Tokyo" | |
slack( | |
message: options.fetch(:message, "No messages"), | |
success: options.fetch(:success, true), | |
slack_url: "hoge", | |
payload: { | |
"Build Date" => Time.new.to_s, |
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
var inputLines = [String]() | |
while let line = readLine() { | |
inputLines.append(line) | |
} | |
let rows = inputLines.dropFirst() | |
rows.forEach { print($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
const sharp = require('sharp') | |
const path = require('path') | |
const filePath = './image.png' | |
const fileName = path.basename(filePath, path.extname(filePath)) | |
sharp(filePath) | |
.resize(1024, 1024, { | |
fit: sharp.fit.inside, | |
withoutEnlargement: true |
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 { readFile, writeFile } from 'fs' | |
import { promisify } from 'util' | |
import * as JSZip from 'jszip' | |
const main = async () => { | |
const oldPath = 'old.zip' | |
const oldBuf = await promisify(readFile)(oldPath) | |
const oldZip = await JSZip.loadAsync(oldBuf) | |
const files = oldZip.files |
OlderNewer