π₯
This file contains hidden or 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
@dynamicMemberLookup | |
protocol JSONType { | |
subscript(dynamicMember member: String) -> JSONType? { get set } | |
} | |
extension JSONType { | |
subscript(dynamicMember member: String) -> JSONType? { | |
get { nil } | |
set { } | |
} | |
subscript<T>(type: T.Type) -> T? { |
This file contains hidden or 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 | |
// Time Complexity: O(N), N stands for the level of key path | |
extension Dictionary where Key == String { | |
subscript(keyPath keyPath: String) -> Any? { | |
get { | |
guard !keyPath.isEmpty else { return nil } | |
var value: Any? = self | |
for key in keyPath.components(separatedBy: ".") { | |
if let node = (result as? [Key: Any])?[key] { |
This file contains hidden or 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 Either<A, B> { | |
case left(A) | |
case right(B) | |
} | |
extension Either: Decodable where A: Decodable, B: Decodable { | |
init(from decoder: Decoder) throws { | |
let container = try decoder.singleValueContainer() | |
if let a = try? container.decode(A.self) { | |
self = .left(a) |
This file contains hidden or 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 | |
read -p "Please enter passphrase to decrypt certifications: " passphrase | |
outputPath="./output" | |
mkdir -p ${outputPath} | |
read -p "Pleas enter password to decrypt output p12 file: " outputPassword | |
for entry in ./certs/*/*.cer | |
do |
This file contains hidden or 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 Moya | |
import RxSwift | |
import PromiseKit | |
import Alamofire | |
import SwiftyJSON | |
typealias Method = HTTPMethod | |
extension String { | |
var urlEscaped: String { |
This file contains hidden or 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
// original: https://gist.github.com/mikelehen/3596a30bd69384624c11 | |
class PushIDGenerator { | |
private init() { } | |
static private let PUSH_CHARS = Array("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz") | |
static private var lastPushTime: UInt64 = 0 | |
static private var lastRandChars = Array<Int>(repeating: 0, count: 12) | |
static func generate() -> String { |
This file contains hidden or 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
# This file contains the fastlane.tools configuration | |
# You can find the documentation at https://docs.fastlane.tools | |
# | |
# For a list of all available actions, check out | |
# | |
# https://docs.fastlane.tools/actions | |
# | |
# For a list of all available plugins, check out | |
# | |
# https://docs.fastlane.tools/plugins/available-plugins |
This file contains hidden or 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
// UIViewController | |
import UIKit | |
final public class <#AnyViewController#>: UIViewController { | |
// MARK: - π Constants | |
// MARK: - πΆ Properties | |
// MARK: - π¨ Style | |
// MARK: - π§© Subviews | |
// MARK: - π Actions |
This file contains hidden or 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 Date { | |
var secondPassedFromNow: TimeInterval { | |
return -timeIntervalSince(Date()) | |
} | |
var relativeDate: String { | |
// if second is negative, means its in future | |
let seconds = secondPassedFromNow.rounded(.down) | |
guard seconds >= 0 else { return "\(seconds)" } |
This file contains hidden or 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 Int { | |
var relativeCount: String { | |
return relativeCount(toDigit: 1) | |
} | |
func relativeCount(toDigit digit: Int) -> String { | |
// should not round to negative digit, its impossible | |
guard digit >= 0 else { fatalError() } | |
// if is negative, just return self |