Skip to content

Instantly share code, notes, and snippets.

View y-polek's full-sized avatar

Yurii Polek y-polek

View GitHub Profile
@y-polek
y-polek / build.gradle
Last active February 5, 2022 15:30
Gradle: Read property from file
/**
* Read property with {@code propertyName} from file with {@code fileName}.
* <p>
* Example of property file content:<br>
* api_key=5c7f743fe85eae73489af35c1a387a05
* apiSecret=12345678910
*
* @return Value of specified property.
* @throws GradleException if file not found or there is no specified property in a file.
*/
@y-polek
y-polek / LiveDataExt.kt
Last active November 25, 2021 01:22
'map' and 'combineLatest' transformations for LiveData
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MediatorLiveData
import android.arch.lifecycle.MutableLiveData
fun <X, Y> LiveData<X>.map(func: (X?) -> Y?): MutableLiveData<Y?> {
return MediatorLiveData<Y>().apply {
addSource(this@map) { x -> value = func(x) }
}
}
@y-polek
y-polek / doze_mode_adb_commands.sh
Last active October 15, 2024 14:32
adb commands to test Doze mode
#! /bin/zsh
# Buttery powered state
adb shell dumpsys battery | grep powered
# Unplug battery
adb shell dumpsys battery unplug
# Reset battery
adb shell dumpsys battery reset
#!/bin/sh
# List connected devices (-l for long output)
adb devices
# Restart adbd listening on TCP on PORT
adb tcpip 5555
# Get IP address (Wi-Fi) of connected device
adb shell ip addr show wlan0