This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Opt<T> { | |
| public interface Function<T> { | |
| void apply(T object); | |
| } | |
| private final T object; | |
| public Opt(T object) { | |
| this.object = object; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main; | |
| sealed class Maybe<A>(private val a: A?) { | |
| class Just<A>(a: A) : Maybe<A>(a) { | |
| override fun toString() = "Just(${wrapped()})" | |
| } | |
| class None<A> : Maybe<A>(null) { | |
| override fun toString() = "None" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import subprocess | |
| EXCLUDE = ["patrick-video-player-integration"] | |
| GET_MERGED_BRANCHES = ["git", "branch", "--merged"] | |
| DELETE_BRANCH = ["git", "branch", "--delete"] | |
| PRUNE_ORIGIN = ["git", "remote", "prune", "origin"] | |
| def runSubProc(proc): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Allows us to call the script via git bp | |
| [alias] | |
| bp = !~/clean_merged_branches.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Database interface | |
| interface Database { | |
| fun getUserById(id: String): Observable<User> | |
| fun getAllUsers(): Observable<List<User>> | |
| fun getUserChangeEvents(): Observable<ChangeEvent<User>> | |
| } | |
| // Describes what happened to what item | |
| data class ChangeEvent<T>(val eventType: ChangeEventType, val t: T) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sealed class Either<L, R> { | |
| class Left<L, R>(val l: L) : Either<L, R>() { | |
| override fun toString(): String = "Left $l" | |
| } | |
| class Right<L, R>(val r: R) : Either<L, R>() { | |
| override fun toString(): String = "Right $r" | |
| } | |
| infix fun <Rp> bind(f: (R) -> (Either<L, Rp>)): Either<L, Rp> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Model { | |
| fun first10Users(): Observable<List<Data>> | |
| } | |
| interface View { | |
| fun displayUserList(users: List<Data>) | |
| fun backButtonClicks(): Observable<ClickEvent> | |
| } | |
| class Presenter { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun rx_infinite() { | |
| val testSub = TestSubscriber<Int>() | |
| var start = 0 | |
| fun inc(): Int { | |
| start += 1 | |
| return start | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Our Monoid interface, which provides an "append" and "empty" | |
| interface Monoid<M> { | |
| fun append(l: M, r: M): M | |
| fun empty(): M | |
| } | |
| sealed class ValidationResult { | |
| companion object : Monoid<ValidationResult> { | |
| // Appends two validation results. If both are failures, append messages with newline |