Skip to content

Instantly share code, notes, and snippets.

Petro Korienev soxjke

Block or report user

Report or block soxjke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:d4b13c772569a7188d5741afa32f2cef

#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 Oct 4, 2016 — forked from PaulTaykalo/injectionexample.swift
Function Injection example
View injectionexample.swift
//: Playground - noun: a place where people can play
import Foundation
import UIKit
typealias ImagePostProcessingOp = (UIImage) -> Void
class ImageProcessor {
let postProcessOp : ImagePostProcessingOp
View injectionExample.playground
//: Playground - noun: a place where people can play
import Foundation
import UIKit
typealias ImagePostProcessingOp = (UIImage) -> Void
enum ImageProcessor {
case PostProcessOp(ImagePostProcessingOp)
View gist:08b260362f5b122f719400f72c9f9c6c
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 Oct 22, 2016
Breaking KISS principle for the win
View BreakingKissPrinciple.playground
//: Playground - noun: a place where people can play
import UIKit
typealias 🍻 = String
typealias 😱 = String
typealias 🕶 = String
typealias 👍 = String
enum Decision{
View do-catch
import Foundation
enum ConnectionFailure : ErrorType {
case Error
}
func throwConnectionError() throws -> String {
throw ConnectionFailure.Error
return connect()
}
View APIService.swift
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 Dec 13, 2016
ManagedObjectMapper
View CoreDataStack.swift
import CoreData
public class CoreDataStack {
// 2
public let model:NSManagedObjectModel
public let persistentStoreCoordinator:NSPersistentStoreCoordinator
public let context:NSManagedObjectContext
public init() {
// 3.1
View ReactiveHell.json
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 Mar 2, 2017
RACSequence additions
View Example.m
- (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];
}];
}
You can’t perform that action at this time.