Skip to content

Instantly share code, notes, and snippets.

View jeksys's full-sized avatar

Eugene Yagrushkin jeksys

View GitHub Profile
import PlaygroundSupport
import Foundation
struct Resource<A> {
var request: URLRequest
var parse: (Data) throws -> A
}
protocol Loadable {
static var request: URLRequest { get }
@jeksys
jeksys / CodableHelper.swift
Created March 13, 2019 22:57
Encodable and Decodable helper extensions
extension String {
func parse<D>(to type: D.Type) -> D? where D: Decodable {
let data: Data = self.data(using: .utf8)!
let decoder = JSONDecoder()
do {
let _object = try decoder.decode(type, from: data)
@jeksys
jeksys / SimpleParsingJson.swift
Created February 28, 2019 17:17 — forked from kobeumut/SimpleParsingJson.swift
Simple Fetch Url and Parse Json on Swift 4 with codable and URLSession
func fetchResultsFromApi() {
struct MyGitHub: Codable {
let name: String?
let location: String?
let followers: Int?
let avatarUrl: URL?
let repos: Int?
private enum CodingKeys: String, CodingKey {
@jeksys
jeksys / isTestFlight.wsift
Created February 4, 2019 20:40
isTestFlight
func isTestFlight() -> Bool{
guard let appStoreReceiptURL = Bundle.main.appStoreReceiptURL else {
return false
}
return appStoreReceiptURL.lastPathComponent == "sandboxReceipt"
}
@jeksys
jeksys / gist:2cb4ffc71c2e568fc92a3c7b798b2632
Last active August 15, 2018 01:01
Coding interview resuorces
https://news.ycombinator.com/item?id=17755688
https://app.codility.com/programmers/lessons/1-iterations/
https://www.educative.io/collection/5642554087309312/5679846214598656
https://shop.bigmachine.io/products/the-imposters-handbook
https://leetcode.com/problemset/top-100-liked-questions/
https://www.interviewcake.com/
https://teamtreehouse.com/community/fizzbuzz-swift-challenge
po [[[UIWindow keyWindow] rootViewController] _printHierarchy]
po view.recursiveDescription()
#if DEBUG
extension UIWindow {
class var key: UIWindow {
let selector: Selector = NSSelectorFromString("keyWindow")
let result = UIWindow.perform(selector)
class WireFrame {
let navigationController: UINavigationController!
func showViewController1(data: Any?) {
let vc = ... //instantiate your view controller
vc.data = data
navigationController.pushViewController(vc, animated: true)
}
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
swift33Targets = ['', '']
installer.pods_project.targets.each do |target|
if oldSwiftTargets.include? target.name
protocol protocolDelegate: class {
func didCancel(controller: RBSigninViewController)
}
extension protocolDelegate where Self: UIViewController {
// Code
}