Skip to content

Instantly share code, notes, and snippets.

View epool's full-sized avatar

Eduardo Pool epool

  • Bitso
  • Mérida, México
View GitHub Profile
@epool
epool / introrx.md
Last active August 29, 2015 14:23 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@epool
epool / CreditCardFormattingTextWatcher.java
Created March 14, 2016 22:02
Text watcher for giving "#### #### #### ####" format to edit text.
import android.text.Editable;
import android.text.TextWatcher;
/**
* Text watcher for giving "#### #### #### ####" format to edit text.
* Created by epool on 3/14/16.
*/
public class CreditCardFormattingTextWatcher implements TextWatcher {
private static final String EMPTY_STRING = "";
@epool
epool / FirebaseUtil.java
Last active January 29, 2018 16:40
Firebase util class to serialize and deserialize Object for Firebase 9.2.0 using Auto-Value and Jackson.
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.GenericTypeIndicator;
import java.util.Map;
public enum FirebaseUtil {

PairAndroid

Pair programming for Android candidates

Environment Setup

For this you will need:

  1. Android Studio 3.+
  2. Android SDK for 7.0+ (API 24)
  3. A handset virtual machine with Nougat (API 24) installed. We recommend one based on the Nexus 6P.
@epool
epool / kotlin-blocking.kt
Created January 5, 2018 22:40
Kotlin Blocking
val profile = Pikmail.getProfile("eduardo.alejandro.pool.ake@gmail.com").blockingGet()
profile.profilePictureUrl
profile.resizeProfilePictureUrl(500)
profile.nickname
// OR
Pikmail.getProfilePictureUrl(email).blockingGet()
Pikmail.getProfilePictureUrl(email, 500).blockingGet()
Pikmail.getProfileNickname(email).blockingGet()
@epool
epool / kotlin-non-blocking.kt
Created January 5, 2018 22:41
Kotlin Non-Blocking
Pikmail.getProfile("eduardo.alejandro.pool.ake@gmail.com")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{ println(it.toString()) },
{ println(it.cause.toString()) }
)
@epool
epool / PikmailInvalidEmailTest.kt
Created January 5, 2018 23:11
Pikmail Invalid Email Test
object PikmailTest : Spek({
given("a Pikmail object") {
on("get a profile for an invalid Gmail address") {
val invalidGmailAddress = "test@mail.com"
val testObservable = Pikmail.getProfile(invalidGmailAddress).test()
it("should throw a ProfileNotFountException") {
@epool
epool / PikmailApiMain.kt
Created January 8, 2018 20:25
Simplified main method of the Pikmail API
@JvmStatic
fun main(args: Array<String>) {
val port = System.getenv("PORT")?.toInt() ?: 8080
embeddedServer(Netty, port) {
routing {
static {
staticRootFolder = File("./static")
files("./")
default("index.html")
}
...
mainClassName = 'org.jetbrains.ktor.netty.DevelopmentHost'
kotlin {
experimental {
coroutines "enable"
}
}
...
@epool
epool / LiveDataReactiveStreamsActivity.kt
Created September 13, 2018 05:28 — forked from arekolek/LiveDataReactiveStreamsActivity.kt
Using LiveDataReactiveStreams to handle lifecycle and threading while computing list diff for recycler view
package com.github.arekolek.diffutil
import android.arch.lifecycle.*
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.util.DiffUtil
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.LayoutInflater
import android.view.View