Skip to content

Instantly share code, notes, and snippets.

View OleksandrKucherenko's full-sized avatar

Oleksandr OleksandrKucherenko

View GitHub Profile
@OleksandrKucherenko
OleksandrKucherenko / JsonLoader.java
Last active March 23, 2018 06:20
Volley Library adaptation for Loader pattern.
import android.os.Handler;
import android.os.Message;
import android.support.v4.content.Loader;
import com.android.volley.NoConnectionError;
import com.android.volley.Response;
import com.android.volley.RetryPolicy;
import com.android.volley.TimeoutError;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonRequest;
@OleksandrKucherenko
OleksandrKucherenko / git-get-latest.sh
Created June 30, 2016 07:31
Get Latest version of the source code from Upstream Master and rebase own branch against it.
#!/bin/bash
# wait for Enter key
function pause(){
read -p "$*"
}
MASTER=master
BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
CHANGED_FILES="$(git status --porcelain --untracked-files=no | wc -l)"
@OleksandrKucherenko
OleksandrKucherenko / git-fix-submodules.sh
Last active June 30, 2016 07:32
Revert all submodules of the project to initial state.
#!/bin/bash
# wait for Enter key
function pause(){
read -p "$*"
}
echo ''
echo Reverting all submodules...
echo ''
@OleksandrKucherenko
OleksandrKucherenko / git-log-top10.sh
Created June 30, 2016 07:34
Get fancy git log, get last top 10 commits. (By parameter can be defined number of line to print)
#!/bin/bash
if [ -z "$1" ]; then
TOP=10
else
TOP=$1
fi
# display top 10 messages with line numbering
git --no-pager log --pretty=format:"%h%x09%Cblue%cr%Cgreen%x09%an%Creset%x09%s%Cred%d%Creset" -n $TOP --date=short | nl -w2 -s" "
@OleksandrKucherenko
OleksandrKucherenko / RobolectricTestsHelper.java
Last active April 27, 2020 09:30
Robolectric full lifecycle of activity/fragment looper.
package net.easypark.junit;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.*;
@OleksandrKucherenko
OleksandrKucherenko / version-up.sh
Last active May 2, 2024 13:04
Calculate Next Suitable Version Tag for Your Git based project
#!/usr/bin/env bash
# shellcheck disable=SC2155
## Copyright (C) 2017, Oleksandr Kucherenko
## Last revisit: 2023-09-30
## Version: 2.0.2
## License: MIT
## Fix: 2023-10-01, prefix for initial INIT_VERSION was not applied
## Fix: 2023-10-01, correct extraction of latest tag that match version pattern
## Added: 2023-09-30, @mrares prefix modification implemented
package **; // <-- add own package name
import android.support.annotation.Nullable;
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.Subject;
/** Generic implementation of value/property that triggers subscribers on value change. */
public class RxValue<T> {
package /* YOUR PROJECT PACKAGE */.utils;
import android.support.annotation.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
@OleksandrKucherenko
OleksandrKucherenko / MoshiAdapters.java
Created June 8, 2017 12:29
Some Moshi adapters for solving common issues with JSON serialization: Null replace by specific value, exclude empty fields from json;
package com.artfulbits.json.moshi;
import android.support.annotation.*;
import com.ryanharter.auto.value.moshi.MoshiAdapterFactory;
import com.squareup.moshi.FromJson;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.JsonQualifier;
import com.squareup.moshi.JsonReader;
import com.squareup.moshi.JsonWriter;
@OleksandrKucherenko
OleksandrKucherenko / AndroidDevMetricsWorkaround.java
Created June 29, 2017 13:05
Workaround for Robolectric Unit Tests with Android Dev Metrics tool attached
public class TheApp extends Application {
@Override
public void onCreate() {
// now give the app code do the rest: launch activities, etc.
super.onCreate();
// Use it only in debug builds
if (BuildConfig.DEBUG) {
initializeAndroidDevMetrics(this);
}