Skip to content

Instantly share code, notes, and snippets.

View theapache64's full-sized avatar
๐Ÿš
Focusing

theapache64 theapache64

๐Ÿš
Focusing
View GitHub Profile
@theapache64
theapache64 / pulls.sh
Last active June 30, 2023 07:19
A shell function to pull images and compare
# pull last modified (n) screenshots
function pulls() {
DEFAULT_COUNT='2'
COUNT="${1:-$DEFAULT_COUNT}"
echo "โฌ‡๏ธ Pulling $COUNT screenshot(s)"
# Get the list of last modified screenshots
local screenshots=(`adb shell ls -t /storage/emulated/0/Pictures/Screenshots/ | head -n "$COUNT"`)
if [ ${#screenshots[@]} -eq 0 ]; then
@theapache64
theapache64 / adb.sh
Last active July 4, 2023 10:30
adb with device selection
function adb() {
# Execute the actual command
local totalLines=$(command adb devices | wc -l | xargs)
local totalDeviceConnected=$(expr $totalLines - 2)
if [[ "$@" != *"-s "* && $totalDeviceConnected -gt 1 ]]; then
# Get the list of connected devices
devices=(`command adb devices | awk '$2 == "device" {print $1}'`)
devicesText=""
// depends-on-plugin org.jetbrains.kotlin
import com.intellij.psi.util.parentOfType
import liveplugin.editor
import liveplugin.executeCommand
import liveplugin.psiFile
import liveplugin.registerAction
import liveplugin.show
import org.jetbrains.kotlin.analysis.api.fir.utils.addImportToFile
@theapache64
theapache64 / install-last-apk.sh
Created April 3, 2023 08:20
To install recently download APK file
# To install recently downloaded APK file
function i(){
lastModifiedFile=$(ls -lt | head -2)
echo $lastModifiedFile
if echo "$lastModifiedFile" | grep -q ".apk"; then
read yn\?"โ“ Do you want to install the above file? (y/n)"
case $yn in
[Yy]* ) installLastModifiedFile; echo "โœ… Done";;
[Nn]* ) echo "Cancelled APK installation";;
* ) echo "Please answer yes or no.";;
import org.json.JSONObject
import java.io.File
const val tinyPngApiKey = "<YOUR-API-KEY-GOES-HERE>"
val projectDir = File("<PATH-TOPROJECT-ROOT>")
val supportedExtensions = listOf("png", "jpg")
fun main() {
projectDir.walk().forEach { srcFile ->
if (supportedExtensions.contains(srcFile.extension)) {
@theapache64
theapache64 / crashlytics_auto_redirect.js
Created August 26, 2022 06:31
Auto redirect to different account - crashlytics
// Extension URL RegEx : https:\/\/console.firebase.google.com\/u\/0\/.+
var accountIndex = 1 // Auto redirect account index
var newUrl = "https://console.firebase.google.com/u/"
+ accountIndex
+ window.location.toString().split("/u/0")[1]
window.location = newUrl
@theapache64
theapache64 / launcTime.sh
Last active August 18, 2022 13:09
To measure average Activity startup time
# To measure lauch time
fun launchTime(){
# Config
LAUNCH_COUNT=10
REGEX='TotalTime: (\d+)'
# The two params are configurable via argument
DEFAULT_PACKAGE_NAME='com.your.packagename'
@theapache64
theapache64 / FileWatcher.kt
Created April 24, 2022 17:35
To watch file changes
import java.io.File
import java.nio.file.*
class FileWatcher(watchFile: String) {
private val folderPath: Path
private val watchFile: String
init {
val filePath = Paths.get(watchFile)
val isRegularFile = Files.isRegularFile(filePath)
Column {
val list = remember { mutableStateListOf<String>("A") }
val listState = rememberLazyListState()
LaunchedEffect(list.size) {
listState.animateScrollToItem(list.lastIndex)
}
Button(onClick = {
list.add(System.currentTimeMillis().toString())
}) {
Text(text = "ADD")
Column {
var flag by remember { mutableStateOf(false) }
val transition = updateTransition(targetState = flag, label = "My Animation")
// Method #1
LaunchedEffect(transition.currentState == transition.targetState) {
if (transition.currentState == transition.targetState) {
println("Animation finished (1)")
}
}
// Method #2