Skip to content

Instantly share code, notes, and snippets.

View Sar777's full-sized avatar
🎯
Focusing

Arthur Antonevich Sar777

🎯
Focusing
  • Minsk, Republic of Belarus
  • 02:47 (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
diff --git a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp
index eeb5f7b..2bbdf42 100644
--- a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp
+++ b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp
@@ -127,16 +127,19 @@ public:
auto list = mgr.GetModifiableThreatList();
auto it = list.begin(), end = list.end();
if (it == end)
+ {
EnterEvadeMode(EVADE_REASON_NO_HOSTILES);
@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 / AuthInterceptor.java
Created June 26, 2017 22:45
OkHttp network interceptor for replace http status code.
public class AuthInterceptor implements Interceptor {
@Override
public Response intercept(@NonNull Chain chain) throws IOException {
Request request = chain.request();
// Handle only post requests
if (!request.method().equals("POST")) {
return chain.proceed(chain.request());
}
@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 {