Skip to content

Instantly share code, notes, and snippets.

View andrespch's full-sized avatar

Andrés Portillo andrespch

View GitHub Profile
{
"locationActivityMetrics" : {
"cumulativeBestAccuracyForNavigationTime" : "20 secs",
"cumulativeBestAccuracyTime" : "30 secs",
"cumulativeHundredMetersAccuracyTime" : "30 secs",
"cumulativeNearestTenMetersAccuracyTime" : "30 secs",
"cumulativeKilometerAccuracyTime" : "20 secs",
"cumulativeThreeKilometersAccuracyTime" : "20 secs"
},
"cellularConditionMetrics" : {
#import <XCTest/XCTest.h>
#import "User.h"
@interface UserTests : XCTestCase
@end
@implementation UserTests {
User *subject;
}
#import <Specta/Specta.h>
#import "User.h"
SpecBegin(User)
__block User *subject;
before(^{
subject = [[User alloc] init];
});
@andrespch
andrespch / mvvm_rx_search_inputs_outputs.md
Created December 16, 2018 15:03
view model inputs and outputs
class SearchViewModel<T> {
    // inputs
    private let searchSubject = PublishSubject<String>()
    var searchObserver: AnyObserver<String> {
        return searchSubject.asObserver()
    }
     
    // outputs
 private let loadingSubject = PublishSubject()
@andrespch
andrespch / 161218search_function.md
Last active December 17, 2018 22:21
Search function to be subclassed
func search(byTerm term: String) -> Observable<[T]> {
    fatalError("Override this function with your custom implementation")
}

Model

  • Add strictly the properties that you will use as opposed to all the properties delivered in the network response.
  • Conform to Codable when used to map network response
  • Use CodingKeys enum when mapping a reduced part of the response or when needing to specify different names (specially if the names coming from the server make little sense).
  • Question: Class or Struct Convention?
struct SelectCarResponse: Codable {
@andrespch
andrespch / react-native-integration-tool.md
Last active January 9, 2018 11:10
First Wiki draft on code generation tool

React Native Bridge Generator

This is a Visual Code Extension that allows you to generate native code (swift and java) to initialize and interact with React Native views.

Background

The Problem

The React Native framework comes with a set of APIs that allows us to load and interact with views. For the React Native SDK to be able to retrieve our view we need to specify our bundle containing the Javascript sources, and pass along the props we wanna initialize this view with. For every view we initialize we might also need to send messages back and forth between both ends of our application (native side and react native side). To accomplish this we need to conform to a protocol (iOS) and implement an interface (Java).

@andrespch
andrespch / cloudSettings
Created July 31, 2017 14:11 — forked from spencercarli/bd3d4befe38185704bf0fc875e9deed6|configuration.json
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-07-29T21:12:58.647Z","extensionVersion":"v2.8.2"}
@andrespch
andrespch / UINavigationControllerExtension.swift
Created April 19, 2017 14:57
NavigationController Extension to push/pop with a completion closure
extension UINavigationController {
private func doAfterAnimatingTransition(animated: Bool, completion: @escaping (() -> Void)) {
if let coordinator = transitionCoordinator, animated {
coordinator.animate(alongsideTransition: nil, completion: { _ in
completion()
})
} else {
DispatchQueue.main.async {
completion()
}
import Cocoa
struct MyNumber {
private var string:String!
var lenght:Int {
get {
return string.characters.count
}