Skip to content

Instantly share code, notes, and snippets.

@oillio
oillio / MyServiceImpl.java
Created October 5, 2016 20:05
bi-directional stream gRPC with RxJava
public class MyServiceImpl extends DeviceServiceGrpc.DeviceServiceImplBase {
@Override
public StreamObserver<GetLocationRequest> getLocations(StreamObserver<GetLocationResponse> responseObserver) {
RequestBridge<GetLocationRequest> request = new RequestBridge<>();
ResponseBridge response = new ResponseBridge((ServerCallStreamObserver) responseObserver);
request.map(this::doGetLocation)
.subscribe(response);
return request;
}
@smithaaron
smithaaron / ClickToSelectEditText.java
Last active January 2, 2019 18:37 — forked from rodrigohenriques/ClickToSelectEditText.java
Used to make your EditText a better option than Spinners
public class ClickToSelectEditText <T> extends AppCompatEditText {
CharSequence mHint;
OnItemSelectedListener<T> onItemSelectedListener;
ListAdapter mSpinnerAdapter;
public ClickToSelectEditText(Context context) {
super(context);
@lsowen
lsowen / README.md
Created October 5, 2015 15:44
django-rest-framework-json-api dynamic filter relationship

I needed to be able to filter which items of a ManyRelatedField were returned, based on some attributes of the request user. Normally, all items in the relationship are returned, however I was able to override the ManyRelatedField.to_attribute() function to enable additional filtering of the relationship.

@alexsinger
alexsinger / build.gradle
Last active July 10, 2019 04:42
Separate Crashlytics reporting for debug and release buildTypes using a Gradle build
// The following code allows an app to report Crashlytics crashes separately
// for release and debug buildTypes when using Gradle. This code should be inserted
// into the specified locations within your build.gradle (Module:app) file
// The buildTypes { } block should be inserted inside the android { } block
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.crashlyticsApiSecret = "release api secret"
@JakeWharton
JakeWharton / ForegroundImageView.java
Created July 10, 2014 16:42
An ImageView which supports a foreground drawable.
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
public class ForegroundImageView extends ImageView {
private Drawable foreground;
@dodyg
dodyg / gist:5823184
Last active March 29, 2024 03:59
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.