Skip to content

Instantly share code, notes, and snippets.

View jemshit's full-sized avatar
👑
Solving Problems

Jemshit Iskanderov jemshit

👑
Solving Problems
View GitHub Profile
public class LazySingleton {
private LazySingleton() {
}
private static volatile LazySingleton sInstance;
public static LazySingleton INSTANCE() {
if (sInstance == null) {
@laaptu
laaptu / ParcelableSparseArray.java
Created July 15, 2015 06:59
Parcelable Sparse Array Implementation
package com.zala.model;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseArray;
/**
* https://gist.github.com/kaushikgopal/9eea148a2188dc58fe37
*/
public class ParcelableSparseArray<T>
@duguyue100
duguyue100 / video-iterator.py
Last active April 19, 2017 12:08
A video iterator in Keras
"""A video iterator in Keras.
Use it like any other iterators.
Author: Yuhuang Hu
Email : duguyue100@gmail.com
"""
from __future__ import print_function
import os
import shutil
@kaushikgopal
kaushikgopal / ParcelableSparseArray.java
Last active June 26, 2017 16:30
Parcelable version of Android's SparseArray. Apache 2 licensed
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseArray;
import junit.framework.TestCase;
public class ParcelableSparseArray
extends SparseArray<Object>
public class RxBus {
private static RxBus sInstance;
private final Relay<Object> mBus = PublishRelay.create().toSerialized();
public static RxBus getInstance() {
if (sInstance == null){
sInstance = new RxBus();
}
@rahulgautam
rahulgautam / ApiModule.java
Created November 7, 2015 08:06 — forked from koesie10/ApiModule.java
Retrofit 1 error handling behaviour in Retrofit 2
// Dagger 1 example
@Module(
complete = false,
library = true
)
public final class ApiModule {
@Provides
@Singleton
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
// don't start emitting items just yet by turning the observable to a connected one
ConnectableObservable<Object> tapEventEmitter = _rxBus.toObserverable().publish();
tapEventEmitter.publish((Func1) (stream) -> {
// inside `publish`, "stream" is truly multicasted
// applying the same technique for getting a debounced buffer sequence
return stream.buffer(stream.debounce(1, TimeUnit.SECONDS));
@Zhuinden
Zhuinden / RealmManager.java
Last active September 22, 2017 19:20
Thread-local Realm
@Singleton
public class RealmManager {
private ThreadLocal<Realm> realms;
@Inject
public RealmManager() {
realms = new ThreadLocal<>();
}
public Realm openRealm() {
@josomers
josomers / build.gradle
Last active November 10, 2017 14:42
Test coverage with Jacoco on Android gradle project with injection frameworks like Dagger/Butterknife and Robolectric 2.3
apply plugin: 'jacoco'
apply plugin: 'idea'
jacoco {
toolVersion = "0.7.0.201403182114"
}
jacocoTestReport {
reports {
xml.enabled = true
/*
* Copyright (C) 2017 Darel Bitsy
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,