Skip to content

Instantly share code, notes, and snippets.

package com.tp.theah64.orchid.utils.extensions
import android.util.Log
fun Any.debug(message: String) {
Log.d(getTag(this), message)
}
fun Any.info(message: String) {
Log.i(getTag(this), message)
@theapache64
theapache64 / Main.kt
Created February 15, 2019 05:58
Delegation Pattern `by` Kotlin
interface Car {
fun carMethod();
}
interface Bus {
fun busMethod();
}
class Leyland : Bus {
override fun busMethod() {
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.view.View
class DonutView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {
private val icingPathEffect = ComposePathEffect(
CornerPathEffect(50f),
DiscretePathEffect(80f, 50f)
object Calculator {
fun divide(a: Int, b: Int): Int {
return a / b
}
}
@RunWith(Parameterized::class)
class ParameterizedTest(
private val num1: Int,
private val num2: Int,
package com.theapache64.mockitosample
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.MockitoAnnotations
@theapache64
theapache64 / pull_file.sh
Created October 3, 2020 11:01
Search and Pull File via ADB
function pull_file(){
filePath=$(adb shell find /storage/emulated/0 -iname "*$1*" | tr -d '\r' | xargs -n1)
x=$(echo "$filePath" | tr '\n' ' ' | xargs)
adb pull "$x"
}
😇 Initializing auto-motion ...
🔊 Analyzing audio stream...
✔️ Audio analysis finishednition: 100% |###########################| Time: 0:05:19
🎥 Analyzing video stream...
✔️ Video analysis finished
🎸 Analyzing BGM...
↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️↔️
↪ Total BGM duration : 00:12:07
↪ Passed BGM duration : 00:03:41
❗ Remaining BGM needed : 00:08:26
@theapache64
theapache64 / sh.sh
Created November 13, 2020 09:13
Turn ON/OFF device animation using ADB
function animOff(){
adb shell settings put global window_animation_scale 0 &
adb shell settings put global transition_animation_scale 0 &
adb shell settings put global animator_duration_scale 0
}
function animOn(){
adb shell settings put global window_animation_scale 1 &
adb shell settings put global transition_animation_scale 1 &
@theapache64
theapache64 / mvvmize.sh
Created November 15, 2020 18:41
Add this to your .bashrc file
function mvvmize () {
# to hold local data source classes such as room,sqlite,realm etc.
mkdir -p data/local &&
# to hold remote data source such as Retrofit, OkHttp etc
mkdir -p data/remote &&
# to hold repository classes that will manage both local and remote data sources
mkdir -p data/repositories &&
function git-ls {
# tree respecting gitignore
local ignored=$(git ls-files -ci --others --directory --exclude-standard)
local ignored_filter=$(echo "$ignored" \
| egrep -v "^#.*$|^[[:space:]]*$" \
| sed 's~^/~~' \
| sed 's~/$~~' \
| tr "\\n" "|")
tree --prune -I ".git|${ignored_filter: : -1}" "$@"
}