Skip to content

Instantly share code, notes, and snippets.

View vani2's full-sized avatar

Ivan Vavilov vani2

View GitHub Profile
@vani2
vani2 / SSL-pinning-example.swift
Last active June 27, 2021 09:17
SSL Pinning PK Example
override func urlSession(
_ session: URLSession,
didReceive challenge: URLAuthenticationChallenge,
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
// 1
guard
challenge.protectionSpace.host == baseURL.host,
challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,
let trust = challenge.protectionSpace.serverTrust
else {
import UIKit
protocol Presenter: AnyObject {
associatedtype T: VCLogic
var viewController: T? { get set }
}
protocol VCLogic: UIViewController {
func foo()
}
@vani2
vani2 / simulator_build.rb
Created January 14, 2021 09:29
Fastlane for app-file build
desc "Build simulator"
lane :build_simulator do
cocoapods
zip_path = "./#{app_target}.zip"
Dir.mktmpdir do |dir|
gym(
scheme: app_debug_scheme,
workspace: app_workspace,
final class FetchImageOperation: AsyncOperation {
private(set) var result: Result<UIImage, Error>?
private lazy var imageProvider = ImageProvider()
private let imageID: String
init(imageID: String) {
self.imageID = imageID
super.init()
class AsyncOperation: Operation {
enum State: String {
case ready, executing, finished
fileprivate var keyPath: String {
return "is" + rawValue.capitalized
}
}
var state = State.ready {
willSet {
// Services Layer
final class EntityService: APIService, EntityServiceProtocol {
typealias EntityCompletion = (Result<Entity, Error>) -> Void
@discardableResult
func createEntity(_ entity: Entity, completion: @escaping EntityCompletion) -> Progress {
let endpoint = CreateEntityEndpoint(entity: entity)
return apiClient.request(endpoint, completionHandler: completion)
import UIKit
import Service
import Database
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
let user = Service().getUsers()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
import UIKit
import Service
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
let user = Service().getUsers()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
import Foundation
import Model
public class Service {
public init() {}
public func getUsers() -> [User] {
return [User(name: “Johny”)]
}
}
platform :iOS, ’13.0’
use_frameworks!
target ‘ModuleExample’ do
end
target ‘Service’ do
pod ‘Model’, :path => ‘Model’
end