Skip to content

Instantly share code, notes, and snippets.

View Debounce.kt
import kotlinx.coroutines.experimental.DefaultDispatcher
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.consumeEach
import kotlinx.coroutines.experimental.channels.produce
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.runBlocking
import kotlin.coroutines.experimental.CoroutineContext
fun <T> ReceiveChannel<T>.debounce(
wait: Long = 300,
vishna / debounce-broadcast.kt
Created Nov 5, 2017
Debounce input from an EditText and relay to a TextView with a timeout.
View debounce-broadcast.kt
package me.vishna.kdebounce
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import android.widget.TextView
import kotlinx.coroutines.experimental.*
zmts /
Last active Apr 9, 2021
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
trent-dev / Jetbrains IDE Essential
Last active Feb 18, 2021
Essential Shortcuts for Jetbrains IDEs, including IntelliJ IDEA, Android Studio & others.
View Jetbrains IDE Essential

Jetbrains IDE Essential Shortcuts

This is a list of Jetbrains IDE shortcuts I use everyday.

Comments welcome! Tell me your favorites.

Navigating Between Windows

Change Focus to Window

Zhuinden /
Last active Sep 22, 2017
Thread-local Realm
public class RealmManager {
private ThreadLocal<Realm> realms;
public RealmManager() {
realms = new ThreadLocal<>();
public Realm openRealm() {
danilValeev / ObjectMapper operator for
Last active May 31, 2019
Easy mapping Realm's List and RealmOptional with ObjectMapper
View ObjectMapper operator for

This code helps using ObjectMapper with RealmSwift.

RealmSwift uses List<T> collection for "to many" relashionships and RealmOptional<T> for optional primitive types, but ObjectMapper can't map directly to List<T> and RealmOptional<T>.

With this operators you can properly define RealmSwift's relashionships and optional properties and use <- operator to map them.


import Foundation
brendanw /
Created Aug 17, 2016
RxBus with Sticky Events
* An RxJava-backed EventBus class that can support sending and receiving multiple event types.
* Based on
public class EventBus<T> {
private static EventBus<Object> INSTANCE;
private List<T> events;
lisawray /
Last active Mar 24, 2021
Equal column spacing in a RecyclerView with GridLayoutManager
package com.example.columnspacing
import android.util.Log;
import android.view.View;
dlew /
Created Mar 1, 2016
Automated onError() message generation
public static Action1<Throwable> crashOnError() {
final Throwable checkpoint = new Throwable();
return throwable -> {
StackTraceElement[] stackTrace = checkpoint.getStackTrace();
StackTraceElement element = stackTrace[1]; // First element after `crashOnError()`
String msg = String.format("onError() crash from subscribe() in %s.%s(%s:%s)",
mttkay /
Created Nov 4, 2015
A simple Rx based pager
public class Pager<I, O> {
private static final Observable FINISH_SEQUENCE = Observable.never();
private PublishSubject<Observable<I>> pages;
private Observable<I> nextPage = finish();
private Subscription subscription = Subscriptions.empty();
private final PagingFunction<I> pagingFunction;
private final Func1<I, O> pageTransformer;