-
Roll-your-own lazy singleton
public final class Single { private static Single INSTANCE; private Single() {}
This file contains 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 net.aquadc.commonandroid.lists; | |
import android.graphics.Rect; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.View; | |
public class FirstLastItemSpacesDecoration extends RecyclerView.ItemDecoration { | |
private final int directSpace; | |
private final int reverseSpace; |
This file contains 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 whatever | |
import com.google.gson.Gson | |
import com.google.gson.JsonElement | |
import com.google.gson.JsonObject | |
import com.google.gson.reflect.TypeToken | |
import okhttp3.RequestBody | |
import okhttp3.ResponseBody | |
import retrofit2.Converter | |
import retrofit2.Retrofit |
This file contains 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 net.aquadc.util; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Collections; | |
import java.util.List; | |
/** | |
* For lists with O(n) random-deletion time (array-based lists, like {@link ArrayList}), | |
* it's faster to mark items as removed and them sweep them all together. |
This file contains 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
import android.os.Handler; | |
import android.os.Looper; | |
import android.support.annotation.NonNull; | |
import java.util.concurrent.Executor; | |
public class Handlecutor extends Handler implements Executor { | |
public Handlecutor(@NonNull Looper looper) { |
This file contains 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 net.aquadc.flawless.service | |
import android.app.Service | |
import android.content.Context | |
import android.content.Intent | |
import android.content.ServiceConnection | |
import android.os.Binder | |
import android.os.IBinder | |
/** |
This file contains 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
# preverify is useful only for J2ME | |
# R8 doesn't preverify by default | |
#-dontpreverify | |
-optimizationpasses 5 | |
# this seems to be enough | |
# remove indirection | |
-allowaccessmodification |
This file contains 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 net.aquadc.recycler; | |
import android.content.Context; | |
import android.graphics.Rect; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import android.view.View; | |
/** |
This file contains 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
use std::env; | |
use std::io; | |
use std::io::Write; | |
use std::str::FromStr; | |
#[macro_use] | |
extern crate lazy_static; | |
fn main() { |
This file contains 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
// Java(?) way | |
interface Fraction<E extends Exception> { | |
int numerator() throws E; | |
int denominator() throws E; | |
} | |
class FracStatic implements Fraction<RuntimeException> // don't force catching | |
class FracSum<E1, E2> implements Fraction<EitherException<E1, E2>> // impossible due to type erasure | |
// Kotlin, Scala, Rust way |