Skip to content

Instantly share code, notes, and snippets.

View nomisRev's full-sized avatar
🏂

Simon Vergauwen nomisRev

🏂
View GitHub Profile
@MisterRager
MisterRager / Rx2ServiceBindingFactory.java
Last active July 17, 2019 18:46
Bind to an Android service using RxJava!
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Binder;
import android.os.IBinder;
import io.reactivex.Observable;
@EricKuck
EricKuck / ButterknifeConductor.kt
Last active May 9, 2019 20:30
Kotterknife(ish) view binding for Conductor controllers
// Largely borrowed from Jake Wharton's Kotterknife (https://github.com/JakeWharton/kotterknife)
// and paweljaneczek's PR for resetting cached views (https://github.com/JakeWharton/kotterknife/pull/37)
package com.bluelinelabs.conductor.butterknife
import android.view.View
import com.bluelinelabs.conductor.Controller
import java.util.Collections
import java.util.WeakHashMap
import kotlin.properties.ReadOnlyProperty
@raulraja
raulraja / validation.kt
Last active May 9, 2019 08:25
Validation: Accumulating errors and failing fast in Arrow with `ApplicativeError`
import arrow.*
import arrow.core.*
import arrow.typeclasses.*
import arrow.data.*
sealed class ValidationError(val msg: String)
data class DoesNotContain(val value: String) : ValidationError("Did not contain $value")
data class MaxLength(val value: Int) : ValidationError("Exceeded length of $value")
data class NotAnEmail(val reasons: Nel<ValidationError>) : ValidationError("Not a valid email")
@raulraja
raulraja / dstagless.kt
Last active December 15, 2018 01:23
Tagless data source strategies with Arrow
import arrow.Kind
import arrow.core.Option
import arrow.core.left
import arrow.core.right
import arrow.effects.typeclasses.Async
import arrow.typeclasses.ApplicativeError
data class UserId(val value: String)
data class User(val userId: UserId)
data class Task(val value: String)
@raulraja
raulraja / typeclassless_tagless_extensions.kt
Last active June 17, 2018 12:43
Tagless with Arrow & typeclassless using extension functions and instances
import arrow.Kind
import arrow.core.Option
import arrow.core.Try
import arrow.core.functor
import arrow.effects.IO
import arrow.effects.fix
import arrow.effects.functor
import arrow.typeclasses.Functor
/* algebras */