Skip to content

Instantly share code, notes, and snippets.

@Tetr4
Tetr4 / ADB_commands.md
Last active September 11, 2019 12:14
ADB commands
# take screenshot
adb exec-out screencap -p > screen.png

# start intent with url, e.g. to test deep linking urls
adb shell 'am start -a android.intent.action.VIEW -d "https://my.url.io/my_file"'

# enter text
adb shell 'input text "asdf"'
@Tetr4
Tetr4 / git_lg.md
Last active November 12, 2019 15:17
Pretty git log overview

Pretty git log overview

Use this alias (git lg) to print a nice compact overview of all commits, branches, tags, etc:

git config --global alias.lg "log --all --color --graph --date-order --pretty=format:'%C(auto)%h %d %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"

For git version < v.1.7.10:

@Tetr4
Tetr4 / ColorInterpolator.java
Created June 14, 2015 17:25
How to interpolate over multiple argb colors
/**
* Use methods provided in this class for linear interpolation over multiple argb colors, e.g. to
* create gradients. <br>
* For better results try converting to a different colorspace before interpolating (e.g. CIELAB
* {@link <a href="http://www.cs.rit.edu/~ncs/color/t_convert.html">Color Conversion Algorithms</a>}
* ).
*/
public final class ColorInterpolator {
/**
@Tetr4
Tetr4 / ForceCacheOrNetwork.java
Last active February 1, 2020 05:17
How to force a cached or network response on Android with Retrofit + OkHttp
OkHttpClient okHttpClient = new OkHttpClient();
try {
int cacheSize = 10 * 1024 * 1024 // 10 MiB
Cache cache = new Cache(getCacheDir(), cacheSize);
okHttpClient.setCache(cache);
} catch (IOException e) {
Log.e(TAG, "Could not set cache", e);
}
// Forces cache. Used for cache connection