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 / 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 / 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 / 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 / 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"

Keybase proof

I hereby claim:

  • I am rpassis on github.
  • I am rogerio (https://keybase.io/rogerio) on keybase.
  • I have a public key whose fingerprint is 93B9 0AFB 0F54 4E95 B636 D6DB 5D85 65EB 0F79 CE6A

To claim this, I am signing this object:

@rpassis
rpassis / ImagePickerHandler.swift
Last active August 27, 2019 10:40
Protocol and extension for handling the presentation of image picker controllers and selection of media
// Since we are unable to extend ObjC protocols in swift, we wrap this around a custom NSObject subclass
// that deals exclusive with handling the image picker delegate methods and chaining the response down to
// the MediaPickerPresenter conforming delegate
class ImagePickerHandler: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
var delegate: MediaPickerPresenter?
let sourceType: UIImagePickerControllerSourceType
let picker = UIImagePickerController()
@rpassis
rpassis / KeyboardObservable.swift
Last active November 3, 2016 22:23
Protocol for observing keyboardWillShow & keyboardWillHide notifications
import UIKit
protocol KeyboardObservable {
var bottomSpaceToMainViewConstraint: NSLayoutConstraint! { get }
func subscribeToKeyboardNotifications()
}
extension KeyboardObservable where Self: UIViewController {
@rpassis
rpassis / universal-framework.sh
Created September 20, 2016 12:24 — forked from cromandini/universal-framework.sh
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures).
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@rpassis
rpassis / gist:ea8f44ad07a5c7ae5108c97d2560a990
Created May 23, 2016 00:20
Docker App fails to connect to localhost when pow is installed
Pow install script enables the PF firewall and adds a rule to forward all port 80 traffic to the Pow server port.
Unfortunately, simply stopping the Pow server won't help as it doesn't stop PF.
Stop PF and use Docker for Mac: `sudo pfctl -d`
Start PF and use Pow: `sudo pfctl -e`
@rpassis
rpassis / pre_build_trigger.sh
Last active May 2, 2016 06:11
Xcode bot before trigger with cocoapods
export LC_ALL="en_US.UTF-8"
PODFILE=`find . -type f -name Podfile`
cd `dirname $PODFILE`
POD_PATH=`which pod`
$POD_PATH install