Skip to content

Instantly share code, notes, and snippets.

View OleksandrKucherenko's full-sized avatar

Oleksandr OleksandrKucherenko

View GitHub Profile
@OleksandrKucherenko
OleksandrKucherenko / mvp.java
Created December 10, 2017 21:53
MVP pattern, basic interfaces
/** Copyright 2017, Oleksandr Kucherenko */
package olku.android.mvp;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.*;
import java.lang.annotation.Retention;
import java.util.HashMap;
import java.util.Map;
@OleksandrKucherenko
OleksandrKucherenko / dumpviewshierarchy.java
Created February 1, 2018 08:18
Dump Android View hierarchy (very good for unit tests)
package your.name;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
@OleksandrKucherenko
OleksandrKucherenko / keysToList.lua
Created October 5, 2018 12:07
Redis LUA Script. Create from KEYS a list/array/queue.
local list = KEYS[1]
local search = KEYS[2]
local instances = redis.call('KEYS', search)
if nil == instances then return nil end
redis.call('DEL', list)
local counter = 0
for i,instance in ipairs(instances) do
redis.call('LPUSH', list, instance)
counter = counter + 1
@OleksandrKucherenko
OleksandrKucherenko / reserveWithTtl.lua
Created October 5, 2018 12:19
Redis LUA script. Reserve instance from queue/list with TTL.
local list = KEYS[1]
local user = KEYS[2]
local instance = redis.call('RPOPLPUSH', list, list)
if nil == instance then return nil end
local first = instance
while true do
local id = string.sub(tostring(instance), string.len('instance.') + 1)
local reserved = 'reserved.' .. id
local confirmed = redis.call('SET', reserved, user, 'EX', 2400, 'NX')
@OleksandrKucherenko
OleksandrKucherenko / batch-convert-to-mp4.cmd
Created October 13, 2018 08:08
Convert multiple files to MP4 compatible with chromecast
call :convert "02. Pup Pup Boogie + Pups in a Fog.mkv"
exit 0
:convert
SET VIDEO=%~1
SET IN_FOLDER=C:\Users\alexk\Downloads\PAW.Patrol.S01.720p.WEB-DL
SET OUT_FOLDER=D:\downloads\paw-patrol
ffmpeg ^
-i "%IN_FOLDER%\%VIDEO%" ^
@OleksandrKucherenko
OleksandrKucherenko / DebugViews.java
Last active August 30, 2024 19:20
Android View Hierarchy dump with transformation properties
/** Author: Oleksandr Kucherenko, 2018-present */
package {your.package.name};
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Matrix;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.util.Pair;
@OleksandrKucherenko
OleksandrKucherenko / KeyboardHelper.java
Last active May 2, 2021 18:50
Helper class that help to track opening/close of virtual keyboard in activity/fragment.
// Author: Oleksandr Kucherenko, 2016-present
package your.package.android.utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
@OleksandrKucherenko
OleksandrKucherenko / wait-online-device.gradle
Created December 3, 2018 16:26
Script force all 'installDebug' task wait 10 seconds for device attaching.
static isAnyDeviceOnline() {
def start = System.currentTimeMillis()
def firstTime = true
while (System.currentTimeMillis() - start < 10000) {
def out = new StringBuilder()
def process = 'adb devices -l'.execute()
process.consumeProcessOutput(out, null)
process.waitForOrKill(1000)
@OleksandrKucherenko
OleksandrKucherenko / bitbucket-pipelines.yml
Created March 31, 2019 09:02
Bitbucket Pipelines For Android Builds (usual for docker based images thing)
# fix android sdk licenses 
 - mkdir "$ANDROID_HOME/licenses" || true 
 - echo -e "\ncf461b4a7cc1448899002f845b02532d01783529" > "$ANDROID_HOME/licenses/android-sdk-license" 
 - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" >> "$ANDROID_HOME/licenses/android-sdk-license" 
 - echo -e "\n504667f4c0de7af1a06de9f4b1727b84351f2910" > "$ANDROID_HOME/licenses/android-sdk-preview-license" 
 - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" >> "$ANDROID_HOME/licenses/android-sdk-preview-license" 
 - echo -e "\nd975f751698a77b662f1254ddbeed3901e976f5a" > "$ANDROID_HOME/licenses/intel-android-extra-license" 
 # show default install SDK components 
 - android-sdk-linux/tools/bin/sdkmanager - list 
 # update installation from CANNERY channel 
# Moshi
-dontwarn okio.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault
-keepclasseswithmembers class * {
 @com.squareup.moshi.* <methods>;
}