Skip to content

Instantly share code, notes, and snippets.

View soxjke's full-sized avatar

Petro Korienev soxjke

View GitHub Profile

#Twitter client with offline mode.

  • As a user I can login to Twitter
  • As a user I see my twitter name in the navigation bar
  • As a user I can view my Twitter feed (fail plan: display error)
  • As a user I can refresh my feed using pull-to-refresh (fail plan: display error)
  • As a user I can view my Twitter feed without internet connection
  • As a user I expect that feed will be automatically updated when network connection is available
  • As a user I can tap on system compose button on the right of navigation bar and get to post new tweet screen
  • As a user I can post new tweet (fail plan: display error)
@soxjke
soxjke / injectionexample.swift
Last active October 4, 2016 15:08 — forked from PaulTaykalo/injectionexample.swift
Function Injection example
//: Playground - noun: a place where people can play
import Foundation
import UIKit
typealias ImagePostProcessingOp = (UIImage) -> Void
class ImageProcessor {
let postProcessOp : ImagePostProcessingOp
//: Playground - noun: a place where people can play
import Foundation
import UIKit
typealias ImagePostProcessingOp = (UIImage) -> Void
enum ImageProcessor {
case PostProcessOp(ImagePostProcessingOp)
@soxjke
soxjke / gist:08b260362f5b122f719400f72c9f9c6c
Created October 18, 2016 07:56
My app main router event loop
init() {
(eventSignal, eventObserver) = Signal<MainRouterSourceEvent, NoError>.pipe();
eventSignal.observeNext { (event) in
let processed = self.handlers.map( { $0(self) }).reduce(false, combine: { (processed, handler) -> Bool in
return processed ? true : handler(event)
})
assert(processed, "Unknown event")
}
}
@soxjke
soxjke / BreakingKissPrinciple.playground
Created October 22, 2016 07:55
Breaking KISS principle for the win
//: Playground - noun: a place where people can play
import UIKit
typealias 🍻 = String
typealias 😱 = String
typealias 🕶 = String
typealias 👍 = String
enum Decision{
import Foundation
enum ConnectionFailure : ErrorType {
case Error
}
func throwConnectionError() throws -> String {
throw ConnectionFailure.Error
return connect()
}
class APIService {
fileprivate static let baseURL:String = ""
fileprivate let requestor:NetModule = NetModule(configuration: NetConfig(cacheSize: 250, pinnedHosts: [""]), baseURL: baseURL)
fileprivate var analyzer:Analyzable?
fileprivate var accessHandler:(()->())?
fileprivate var invalidAccessSignal:(Signal<Bool, NoError>, Observer<Bool, NoError>)?
var authorizationService: AuthentificationService = AuthentificationService(baseURL: baseURL)
@soxjke
soxjke / CoreDataStack.swift
Created December 13, 2016 05:34
ManagedObjectMapper
import CoreData
public class CoreDataStack {
// 2
public let model:NSManagedObjectModel
public let persistentStoreCoordinator:NSPersistentStoreCoordinator
public let context:NSManagedObjectContext
public init() {
// 3.1
@soxjke
soxjke / ReactiveHell.json
Last active March 2, 2017 20:39
ReactiveHell
Vehicle:
{
"vehicle":{
"id":1,
"name":"AlfaRomeo",
"chassi":[12, 13, 27, 24],
"wings":[3, 250, 1],
"engine":[29],
"headlights":[201],
"profile":901
@soxjke
soxjke / Example.m
Last active March 2, 2017 21:47
RACSequence additions
- (NSString *)stringByTrimmingWhiteSpacesForEachLine {
return [[self.rac_lineSequence map:^id(NSString * line) {
return [line stringByTrimmingWhiteSpaces];
}] foldLeftWithStart:@"" reduce:^NSString *(NSString *accumulator, NSString *value) {
return [accumulator stringByAppendingFormat:@"%@\n", value];
}];
}