Skip to content

Instantly share code, notes, and snippets.

View vovkab's full-sized avatar

Vladimir Baryshnikov vovkab

  • if(we)
  • San Francisco
View GitHub Profile
@vovkab
vovkab / MainThreadWatchDog.java
Created March 8, 2018 05:10
Monitors main thread for timeouts.
package io.wondrous.sns.utils;
import android.os.Handler;
import android.os.Looper;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
public class MainThreadWatchDog {
public static final long MAIN_THREAD_PING_INTERVAL = 200;
@vovkab
vovkab / ExperimentDagger.java
Last active April 14, 2019 22:37
Example of using Dagger 2 in libraries
package com.example;
import java.lang.annotation.Retention;
import javax.inject.Inject;
import javax.inject.Scope;
import javax.inject.Singleton;
import dagger.Binds;
import dagger.BindsInstance;
@vovkab
vovkab / repo
Created November 3, 2017 07:26
gerrit repo
Show traces:
$ repo --trace <command>
Upload for review with topic set to current branch name:
$ repo upload -t
or
review.URL.uploadtopic = true
Issues
gradlew :app:dependencyInsight --configuration testCompile --dependency kotlin-reflect
gradlew :tapp:dependencyInsight --configuration appDebugCompileClasspath --dependency okhttp
Resolve all dependencies. Force gradle to precache dependencies for all configurations:
```
allprojects {
task resolveAllDependencies {
doLast {
configurations.all { it.resolve() }
}
@vovkab
vovkab / android-recycler-merge-adapter-tools
Last active February 25, 2017 00:59
Tools for RecyclerMergeAdapter
/**
* Calculates correct item position based on RecyclerAdapter and ViewHolder adapter position.
* Takes in consideration RecyclerMergeAdapter and adjust position accordingly
*
* @param adapter RecyclerAdapter with access to RecyclerView instance
* @param viewHolder ViewHolder that was created by @adapter
* @return adjusted local position for viewHolder
*/
public static int getLocalPosition(RecyclerAdapter adapter, RecyclerView.ViewHolder viewHolder) {
int position = viewHolder.getAdapterPosition();
@vovkab
vovkab / gist:d9f76e3429cdf20a4e0c
Created January 13, 2016 18:05 — forked from ohmrefresh/gist:55149f68c41a148ae673
How to Server-side verification of Google Play subscriptions
1.create google app (google console)
Example:
Client ID xxx.apps.googleusercontent.com
Email address [email protected]
Client secret xxx
Redirect URIs
https://localhost/oauth2callback
Javascript Origins
https://localhost
sudo ln -s /usr/local/bin/VBoxManage /usr/bin/VBoxManage
http://stackoverflow.com/questions/31364475/genymotion-error-unable-to-load-virtualbox-engine-on-yosemite-virtualbox-ins
private String decodeBody(Response response) throws IOException {
final ResponseBody body = response.body();
if (body == null) return null;
if (isZipped(response)) {
return unzip(response.body());
} else {
return body.string();
}
}
@vovkab
vovkab / android-memory-class
Last active June 12, 2017 09:46
Android device memory class
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
int memoryClass = manager.getMemoryClass();
48 - Samsung Nexus S
64 - Samsung Galaxy Nexus
Samsung S2
Samsung S3
128 - Samsung S4
@vovkab
vovkab / mac-os-haxm.md
Created October 21, 2014 03:42
Installing HAXM for Mac OS 10.10

Enable unsigned kext to be installed:

$ sudo nvram boot-args="kext-dev-mode=1"