Skip to content

Instantly share code, notes, and snippets.

View yoxisem544's full-sized avatar
🥑

David Lin yoxisem544

🥑
View GitHub Profile
- cache-push:
inputs:
- cache_paths: |-
# 記得把註解拿掉,bitrise 不會忽略註解,會造成路徑錯誤
$GEM_CACHE_PATH -> ./.ruby-version # 官方文件的環境變數
./vendor -> ./Gemfile.lock # 當 gemfile lock 有變化時,更新 ./vendor 底下的 cache
- script@1:
title: Bundle Install
inputs:
- content: |-
bundle i
@yoxisem544
yoxisem544 / NetworkRequest.swift
Created June 1, 2020 05:06
NetworkRequest wrapper of Alamofire 5
//
// NetworkRequest.swift
//
// Created by David on 2020/5/31.
// Copyright © 2020 David. All rights reserved.
//
import Alamofire
public struct NetworkRequest<Response: Decodable> {
//
// DetectDevice.swift
// DetectDevice
//
// Created by David on 2020/5/21.
// Copyright © 2020 David Lin. All rights reserved.
//
import UIKit
import CoreTelephony
import Foundation
struct Foobar<T: Equatable> {
let value: T
let count: Int
}
extension Collection {
func sumOfCounts<T>(where predicate: (T) -> Bool) -> Int where Element == Foobar<T> {
reduce(0, { $0 + (predicate($1.value) ? $1.count : 0) })
// Created by Marcin Krzyzanowski
import Foundation
public protocol JSONEncodable: Encodable { }
public extension JSONEncodable {
func toJSON(using encoder: @autoclosure () -> JSONEncoder = JSONEncoder()) throws -> String {
try String(decoding: encoder().encode(self), as: UTF8.self)
}
//
// UIImageView+Unsplash.swift
// Created by David on 2019/12/9.
//
import UIKit.UIImageView
import Kingfisher
/// check api doc: https://source.unsplash.com/
fileprivate let randomUnsplashImageURL = "https://source.unsplash.com/random"
UIImage(named: "Cross", in: <ANY_BUNDLE>, compatibleWith: nil)
internal struct WrappedBundleImage: _ExpressibleByImageLiteral {
let image: UIImage?
init(imageLiteralResourceName name: String) {
image = UIImage(named: name, in: <ANY_BUNDLE>, compatibleWith: nil)
}
}
extension UIImage {
static func fromWrappedBundleImage(_ wrappedImage: WrappedBundleImage) -> UIImage? {
fileprivate class ThisClass {}
public struct Resources {
public static var testBundle: Bundle {
let path = Bundle(for: ThisClass.self).resourcePath! + "/ThisIsATestBundle.bundle"
return Bundle(path: path)!
}
}