Skip to content

Instantly share code, notes, and snippets.

View rpassis's full-sized avatar

Rogerio de Paula Assis rpassis

  • ANZx
  • Sunshine Beach, Australia
View GitHub Profile
@rpassis
rpassis / AppEnvironment.swift
Created July 11, 2017 19:26
Differentiates between dev, Testflight/AdHoc and appStore environments
import Foundation
// Important: Ensure a DEBUG flag is set under OTHER SWIFT FLAGS (Debug environment only)
enum AppConfig: String {
case debug = "Debug"
case testFlight = "TestFlight"
case appStore = "Appstore"
@rpassis
rpassis / RxStore.swift
Created August 8, 2017 13:50 — forked from Odrakir/RxStore.swift
ReSwift + Rx
import Foundation
import RxSwift
public class RxStore: StoreSubscriber {
private var stateObservable:Observable<AppState> {
return subject.asObserver()
.shareReplay(1)
}
private var subject = PublishSubject<AppState>()
@rpassis
rpassis / Style.swift
Created May 12, 2018 11:41
Swift - Stylesheet
struct Style<View: UIView> {
private let style: (View) -> Void
init(style: @escaping (View) -> Void) {
self.style = style
}
func apply(to view: View) {
style(view)
}
@rpassis
rpassis / PagingCollectionViewController.swift
Created May 15, 2018 07:04 — forked from michaelevensen/PagingCollectionViewController.swift
An example of perfectly paging horizontal UICollectionViewController with overflowing cells. Works great with Storyboard — no need to set any specific attributes, just add this Class to the Controller and set your desired size for the cells like you would normally.
import UIKit
private let reuseIdentifier = "Cell"
class CollectionViewController: UICollectionViewController {
/* Custom scrollView for paging */
let pagingScrollView = UIScrollView()
/* Return item size */
@rpassis
rpassis / HKT.swift
Created August 12, 2018 19:29 — forked from anandabits/HKT.swift
Emulating HKT in Swift
// This example shows how higher-kinded types can be emulated in Swift today.
// It acheives correct typing at the cost of some boilerplate, manual lifting and an existential representation.
// The technique below was directly inspired by the paper Lightweight Higher-Kinded Polymorphism
// by Jeremy Yallop and Leo White found at http://ocamllabs.io/higher/lightweight-higher-kinded-polymorphism.pdf
/// `ConstructorTag` represents a type constructor.
/// `Argument` represents an argument to the type constructor.
struct Apply<ConstructorTag, Argument> {
/// An existential containing a value of `Constructor<Argument>`
/// Where `Constructor` is the type constructor represented by `ConstructorTag`
//
// EmitWhile.swift
//
// Created by Daniel Tartaglia on 09/06/2018.
// Copyright © 2018 Daniel Tartaglia. MIT License.
//
import RxSwift
/**
@rpassis
rpassis / lldb_cheat_sheet.md
Created November 6, 2018 19:42 — forked from ryanchang/lldb_cheat_sheet.md
LLDB Cheat Sheet

LLDB Cheat Sheet

A complete gdb to lldb command map.

Print out

  • Print object
(lldb) po responseObject
(lldb) po [responseObject objectForKey@"state"]
  • p - Print primitive type
@rpassis
rpassis / CoreDataChangeSetPlaygrounds.swift
Created January 13, 2019 18:07
Observe changes to a CoreData context using RxSwift
import UIKit
import CoreData
import Playgrounds
import RxSwift
import RxCocoa
@objc(ProductEntity)
final class ProductEntity: NSManagedObject {
@NSManaged public var uuid: String?
@NSManaged public var title: String?
@rpassis
rpassis / Publisher+Unwrap.swift
Created July 3, 2019 14:57
Combine Recipe - Unwrapping an optional type operator
public protocol OptionalType {
associatedtype Wrapped
var value: Wrapped? { get }
}
extension Optional: OptionalType {
public var value: Wrapped? {
return self
}
}
@rpassis
rpassis / DeallocTests.swift
Last active July 14, 2019 20:32
Unit testing memory leaks
//
// DeallocTests.swift
//
// Created by Rogerio de Paula Assis on 7/14/19.
// Extracted from this CCH Melbourne talk: https://www.youtube.com/watch?v=514rJ1efv84
//
import XCTest
class DeallocTests: XCTestCase {