Skip to content

Instantly share code, notes, and snippets.

View Sar777's full-sized avatar
🎯
Focusing

Arthur Antonevich Sar777

🎯
Focusing
  • Minsk, Republic of Belarus
  • 03:40 (UTC +03:00)
View GitHub Profile
@Sar777
Sar777 / build.gradle
Created September 17, 2019 18:40 — forked from delor/build.gradle
Gradle task for generating Maven's POM file for Android AAR
task createPom {
apply plugin: 'maven'
description "Generates pom.xml"
pom {
project {
groupId 'com.example'
artifactId 'example'
version '0.0.1-SNAPSHOT'
packaging 'aar'
}
@Sar777
Sar777 / ScrollToTopDataObserver.kt
Created May 12, 2019 16:29 — forked from danielgomezrico/ScrollToTopDataObserver.kt
Android / Kotlin - Scroll recycler view automatically based on initial items and scroll to bottom on new items (like a chat room)
class ScrollToTopDataObserver(val layoutManager: LinearLayoutManager,
val recyclerView: RecyclerView)
: RecyclerView.AdapterDataObserver() {
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
super.onItemRangeInserted(positionStart, itemCount)
val lastVisiblePosition = layoutManager.findLastCompletelyVisibleItemPosition()
// If the recycler view is initially being loaded or the user is at the bottom of the
// list, scroll to the bottom of the list to show the newly added message.
if (lastVisiblePosition == -1 || positionStart >= itemCount - 1 && lastVisiblePosition == positionStart - 1) {
@Sar777
Sar777 / Debounce.kt
Created February 11, 2019 08:17 — forked from elizarov/Debounce.kt
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,
@Sar777
Sar777 / ErrorInterceptor.kt
Created December 19, 2018 10:00 — forked from yitz-grocerkey/ErrorInterceptor.kt
Retrofit RxJava global error handling in Kotlin
// for any errors that should be handled before being handed off to RxJava.
// In other words global error logic.
// An example might be 401 when not logging in
import okhttp3.Interceptor
import okhttp3.Response
class ErrorInterceptor: Interceptor {
override fun intercept(chain: Interceptor.Chain?): Response {
@Sar777
Sar777 / extensions.md
Created March 29, 2018 06:43
A list of AutoValue extensions
@Sar777
Sar777 / Makefile
Created July 11, 2017 09:53 — forked from kwk/Makefile
Compiling with Address Sanitizer (ASAN) with CLANG and with GCC-4.8
.PHONY: using-gcc using-gcc-static using-clang
using-gcc:
g++-4.8 -o main-gcc -lasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc
using-gcc-static:
g++-4.8 -o main-gcc-static -static-libstdc++ -static-libasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc-static
@Sar777
Sar777 / how-to-install-latest-gcc-on-ubuntu-lts.txt
Created July 3, 2017 19:08 — forked from application2000/how-to-install-latest-gcc-on-ubuntu-lts.txt
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
@Sar777
Sar777 / Api.java
Created June 8, 2017 15:22 — forked from imminent/Api.java
Call retrying with Retrofit 2.0
package com.example.api;
import java.util.Map;
import retrofit.Call;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
public interface Api {
@Sar777
Sar777 / AccountAuthenticator.java
Created June 3, 2017 14:08 — forked from burgalon/AccountAuthenticator.java
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
@Sar777
Sar777 / webpack.server.config.js
Created April 10, 2017 10:37 — forked from madx/webpack.server.config.js
Webpack config for an Express app in Node.js
const path = require("path")
const fs = require("fs")
// -- Webpack configuration --
const config = {}
// Application entry point
config.entry = "./src/server/index.js"