Skip to content

Instantly share code, notes, and snippets.

View antonshkurenko's full-sized avatar
⚜️
:)

Anton Shkurenko antonshkurenko

⚜️
:)
View GitHub Profile
@elizarov
elizarov / Debounce.kt
Last active August 26, 2019 00:19
Debounce
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
vishna / debounce-broadcast.kt
Created November 5, 2017 19:38
Debounce input from an EditText and relay to a TextView with a timeout.
package me.vishna.kdebounce
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import android.widget.TextView
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.android.UI
@zmts
zmts / tokens.md
Last active May 2, 2024 15:03
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 25.08.2020

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

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
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() {
@danilValeev
danilValeev / ObjectMapper operator for Realm.md
Last active June 17, 2021 08:16
Easy mapping Realm's List and RealmOptional with ObjectMapper

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.

Example

import Foundation
@brendanw
brendanw / StickyRxBus.java
Created August 17, 2016 06:06
RxBus with Sticky Events
/**
* An RxJava-backed EventBus class that can support sending and receiving multiple event types.
*
* Based on https://gist.github.com/benjchristensen/04eef9ca0851f3a5d7bf
*/
public class EventBus<T> {
private static EventBus<Object> INSTANCE;
private List<T> events;
@lisawray
lisawray / ColumnItemDecoration.java
Last active May 29, 2023 21:11
Equal column spacing in a RecyclerView with GridLayoutManager
package com.example.columnspacing
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
@dlew
dlew / File.java
Created March 1, 2016 20:46
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)",
element.getClassName(),
element.getMethodName(),
element.getFileName(),
element.getLineNumber());
@mttkay
mttkay / Pager.java
Created November 4, 2015 15:46
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;