Skip to content

Instantly share code, notes, and snippets.

View ivanbruel's full-sized avatar

Ivan Bruel ivanbruel

View GitHub Profile
@ivanbruel
ivanbruel / swift_swizzle
Created April 9, 2015 17:26
Swift Class Method Swizzle
//
// LHNetworking+Endpoint.swift
// magellan
//
// Created by Ivan Bruel on 09/04/15.
// Copyright (c) 2015 Passworks S.A. All rights reserved.
//
import Foundation
import Lighthouse
@ivanbruel
ivanbruel / Optional+Unwrap.swift
Last active August 29, 2015 14:23
Easy Swift Unwrapping
infix operator ?-> { associativity left precedence 140 }
func ?-><T>(lhs: T?, rhs: ((T)->(Void))) {
if let value = lhs {
rhs(value)
}
}
// Usage
var someOptionalVariable : Int?
<activity
android:name="com.hokolinks.activity.HokoActivity"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask"
android:noHistory="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<data android:scheme="<your-app-scheme>"/>
<action android:name="android.intent.action.VIEW" />
@ivanbruel
ivanbruel / UIImage+UIColor
Created September 29, 2015 18:14
Animate crossfade UIColor and UIImage with SDWebImage
//
// UIImage+UIColor.swift
//
import UIKit
extension UIImage {
class func imageWithColor(color: UIColor) -> UIImage {
let rect = CGRectMake(0.0, 0.0, 1.0, 1.0)
UIGraphicsBeginImageContext(rect.size)
@ivanbruel
ivanbruel / MyActivity.java
Created November 23, 2015 17:50
A little permissions wrapper for Android Marshmellow with usage example
public class MainActivity extends Activity {
private Permissions mPermissions;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPermissions = Permissions.with(this);
}
@ivanbruel
ivanbruel / Animal.swift
Created March 11, 2016 11:10
Animal.swift
class Animal {
var name: String
var age: Int
var image: UIImage
init(name: String, age: Int, image: UIImage) {
self.name = name
self.age = age
self.image = image
}
@ivanbruel
ivanbruel / AnimalViewController.swift
Created March 11, 2016 11:13
AnimalViewController.swift
class AnimalViewController: UIViewController {
// Model Object
var animal: Animal
// View Object
var imageView: UIImageView
override func viewDidLoad() {
// Maps Model into a View
class AnimalViewModel {
let name: String
let image: UIImage
private let _hungry: Variable<Bool>
var hungry: Observable<Bool> {
return _hungry.asObservable()
}
init(animal: Animal) {
class AnimalTableViewCell: UITableViewCell {
private var imageView: UIImageView
private var nameLabel: UILabel
private var hungryIconView: HungryIconView
private let disposeBag = DisposeBag()
var viewModel: AnimalViewModel {
didSet {
@ivanbruel
ivanbruel / DressDetailsAddToBagViewModel.swift
Last active April 19, 2016 16:08
DressDetailsAddToBagViewModel
//
// DressDetailsAddToBagViewModel.swift
// ChicByChoice
//
// Created by Ivan Bruel on 18/04/16.
// Copyright © 2016 Chic by Choice. All rights reserved.
//
import Foundation
import RxSwift