Skip to content

Instantly share code, notes, and snippets.

View lion4ik's full-sized avatar

Alexey Pushkarev lion4ik

  • Glovo
View GitHub Profile
[0,25,13,-9,-18,0,137,13,-16,0,3,-9,-9,-9,136,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,135,13,-16,0,3,-9,-9,-9,134,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,133,13,-16,0,3,-9,-9,-9,132,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,131,13,-16,0,3,-9,-9,-9,130,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,129,13,-16,0,3,-9,-9,-9,128,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,127,13,-16,0,3,-9,-9,-9,126,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,125,13,-16,0,3,-9,-9,-9,124,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,123,13,-16,0,3,-9,-9,-9,122,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,121,13,-16,0,3,-9,-9,-9,120,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,119,13,-16,0,3,-9,-9,-9,118,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,117,13,-16,0,3,-9,-9,-9,116,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,115,13,-16,0,3,-9,-9,-9,114,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,113,13,-16,0,3,-9,-9,-9,112,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,111,13,-16,0,3,-9,-9,-9,110,13,12,0,-12,0,-11,-9,0,0,3,-9,9,8,-18,0,109,13,-16,0,3,-9,-9,-9,108,13,12,0,-12,0,-11,-9,0,0,3
@lion4ik
lion4ik / MergeSortedArraysTest.kt
Last active June 3, 2020 21:03
Merge sorted arrays
import org.junit.Test
import java.util.*
class MergeArraySortTest {
@Test
fun test() {
val original = LinkedList(mutableListOf(4, 5, 8, 11, 15, 17, 20)) //n
val addition =
LinkedList(mutableListOf(1, 3, 6, 10, 11, 13, 19, 21)) //m
@lion4ik
lion4ik / themes-debug.xml
Created December 9, 2018 16:53 — forked from dlew/themes-debug.xml
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>
class SomeClass {
private val channel: BroadcastChannel<List<Purchase>> = BroadcastChannel(Channel.CONFLATED)
override fun onPurchasesUpdated(responseCode: Int, purchases: MutableList<Purchase>?) {
GlobalScope.launch {
purchases?.run { channel.send(toList()) }
}
}
import java.security.SecureRandom
/**
* Created by alexeypushkarev on 04.06.17.
*/
fun randomArrayOfUniques(size: Int, maxValue: Int): List<Int> {
if (size > maxValue) {
throw IllegalArgumentException("maxValue should be greater than size")
}
package ru.avs.express.android.interactor.common;
/**
* Базовый класс репозитория
*/
public class BaseRepository {
private ConnectionQualityProvider connectionQualityProvider;
public BaseRepository(ConnectionQualityProvider connectionQualityProvider) {
/**
* Осуществляет гибридный запрос, в методе происходит объединение данных приходящих с сервера и из кеша
*
* @param cacheRequest запрос к кешу
* @param networkRequestCreator функция, которая должна вернуть запрос к серверу,
* Integer параметр этой функции определяет {@link QueryMode}
* @param <T> тип возвращаемого значения
*/
protected <T> Observable<T> hybridQuery(Observable<T> cacheRequest,
Func1<Integer, Observable<T>> networkRequestCreator) {
@lion4ik
lion4ik / SignatureCheck.java
Created February 22, 2017 18:34 — forked from scottyab/SignatureCheck.java
Simple Android signature check. It's not bullet proof but does increase the difficulty of backdooring the app
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
public class TamperCheck {
//we store the hash of the signture for a little more protection
private static final String APP_SIGNATURE = "1038C0E34658923C4192E61B16846";
```java
@OnClick({R.id.cvAnswerA, R.id.cvAnswerB, R.id.cvAnswerC, R.id.cvAnswerD})
public void onClick(View v) {
Transition slideLeft = new Slide(Gravity.LEFT)
.addListener(new Transition.TransitionListenerAdapter() {
@Override
public void onTransitionEnd(Transition transition) {
TransitionManager.beginDelayedTransition(container, new Slide(Gravity.RIGHT));
cvPicture.setVisibility(View.VISIBLE);