Skip to content

Instantly share code, notes, and snippets.

View carloxavier's full-sized avatar
:octocat:

Carlo Lopez carloxavier

:octocat:
View GitHub Profile
@AndrewReitz
AndrewReitz / Repository.java
Created August 13, 2014 15:30
Repository pattern using RxJava
import java.util.LinkedHashMap;
import java.util.Map;
import rx.Observer;
import rx.Subscription;
import rx.subjects.PublishSubject;
abstract class Repository<K, V> {
private final Cache<K, V> cache;
@gitanuj
gitanuj / RecursiveFileObserver.java
Created May 20, 2015 19:15
A FileObserver for Android which monitors all the files/folders in a directory recursively.
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;
import android.os.FileObserver;
/**
* A FileObserver that observes all the files/folders within given directory
* recursively. It automatically starts/stops monitoring new folders/files
@fancellu
fancellu / Insert.scala
Created August 30, 2015 15:03
Simple insertion into an ordered List
val li=List(1,2,10,20,30) //> li : List[Int] = List(1, 2, 10, 20, 30)
def insert[T](li:List[T],x:T)(implicit cmp:Ordering[T])={
val (first,last)=li.partition {cmp.lteq(_, x) }
first:::x::last
} //> insert: [T](li: List[T], x: T)(implicit cmp: Ordering[T])List[T]
insert(li,11) //> res0: List[Int] = List(1, 2, 10, 11, 20, 30)
insert(li,10) //> res1: List[Int] = List(1, 2, 10, 10, 20, 30)
insert(li,9) //> res2: List[Int] = List(1, 2, 9, 10, 20, 30)
@alexforrester
alexforrester / Moshi Kotlin Codegen Example with Custom Adapter
Last active August 28, 2022 19:39
Moshi Kotlin Codegen Example with Custom Adapter
//app build.gradle
apply plugin: 'kotlin-kapt'
...
dependencies {
{
//Moshi Core
implementation "com.squareup.moshi:moshi:1.8.0"
//Moshi Codegen