Skip to content

Instantly share code, notes, and snippets.

View piotrbernad's full-sized avatar

Piotr Bernad piotrbernad

View GitHub Profile
@piotrbernad
piotrbernad / CachingPlugin.swift
Created September 27, 2017 18:51
CachingPlugin
struct CachingPlugin: Moya.PluginType {
func didReceive(_ result: Result<Response, MoyaError>, target: TargetType) {
guard let cachableTarget = target as? CachableTarget else {
return
}
guard cachableTarget.cachingEnabled else { return }
@piotrbernad
piotrbernad / CachableTarget.swift
Created September 27, 2017 18:45
CachableTarget
public protocol CachableTarget {
var cachingEnabled: Bool { get }
var cacheKey: String { get }
}
extension CachableTarget where Self: TargetType {
var cacheKey: String {
return self.path
}
}
@piotrbernad
piotrbernad / PostsTableViewController.swift
Created September 27, 2017 18:19
EmptyDataSetSource Example
extension PostsTableViewController: DZNEmptyDataSetSource {
func title(forEmptyDataSet scrollView: UIScrollView!) -> NSAttributedString! {
switch self.state {
case .loading:
return NSAttributedString(string: NSLocalizedString("Loading...", comment: ""))
case .refreshing:
return NSAttributedString(string: NSLocalizedString("Refreshing", comment: ""))
case .error:
return NSAttributedString(string: NSLocalizedString("Error", comment: ""))
default:
@piotrbernad
piotrbernad / LoadableState.swift
Created September 27, 2017 18:14
LoadableState
public enum LoadableState<ItemType> {
case idle
case loading
case loaded(items: [ItemType])
case contentUnavailable
case refreshing
case error(error: Error)
}
func testForgotPasswordByUsernamePage() {
start(104, "Login Screen: Test if user is able to resset password.")
_ = Application(test: self)
.showLogin()
.openForgotPassword()
.sendRessetPasswordByUsername()
.backToLogin()
}
@piotrbernad
piotrbernad / gitlab-ci.yml
Created July 13, 2017 13:10
Gitlab CI Deploy Tests Results Job
test:
stage: test
script:
- bundle exec fastlane ios test
artifacts:
paths:
- fastlane/test_output/
tags:
- xcode8.3
@piotrbernad
piotrbernad / HomePage.swift
Created June 13, 2017 07:35
Home Page Structure Example
struct HomePage: Page {
var test: BaseCase!
var pageIdentifier: String { return “home_page” }
func openMenu() -> MenuPage { … }
func openMusic() -> MusicLandingPage { … }
func openVideo() -> VideoLandingPage { … }
func openPlaylists() -> PlaylistsLandingPage { … }
func createPlaylist() -> PlaylistNamePage { … }
import PlaygroundSupport
import RxSwift
PlaygroundPage.current.needsIndefiniteExecution = true
extension ObservableType where E: Sequence {
typealias T = E.Iterator.Element
/// Create an observable which is an Array of the projected values
["$ curl -i \\\n\t-X POST \\\n\t-b \"__cfduid=db84f6ef92630eb33c1b947145f2de44c1487849321\" \\\n\t-H \"Content-Type: application/json\" \\\n\t-H \"Accept-Language: en;q=1.0\" \\\n\t-H \"Authorization: Bearer 6472b3570b118264debf25365958ba2cdde6f79c\" \\\n\t-H \"User-Agent: zinnow/1.0 (com.appunite.zumba; build:16; iOS 10.2.0) Alamofire/4.3.0\" \\\n\t-H \"Accept-Encoding: gzip;q=1.0, compress;q=0.5\" \\\n\t-d \"{\\\"name\\\":\\\"jdkdjdjd\\\",\\\"modified\\\":1488382623,\\\"songs\\\":[{\\\"music\\\":{\\\"can_stream\\\":true,\\\"name\\\":\\\"A Good Man\\\",\\\"release_date\\\":1465862400,\\\"categories\\\":[{\\\"name\\\":\\\"Zumba® Country\\\",\\\"thumbnail_url\\\":\\\"\\\",\\\"image\\\":\\\"\\\",\\\"num_music\\\":10,\\\"description\\\":\\\"Get down and fit to country favorites!\\\",\\\"type\\\":\\\"regular\\\",\\\"display_order\\\":9999,\\\"children_categories\\\":[]},{\\\"name\\\":\\\"Zumba® Original Music\\\",\\\"thumbnail_url\\\":\\\"https:\\/\\/d29za44huniau5.cloudfront.net\\/wp-content\\/uploads\\/2016\\/1
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit