Skip to content

Instantly share code, notes, and snippets.

View marius-m's full-sized avatar

Marius Merkevičius marius-m

View GitHub Profile
@marius-m
marius-m / adb-copy-folder.sh
Created December 12, 2022 11:47
Copy folder from app package (requires root)
#!/bin/bash
### Copy folder from app package (requires root)
#
# ./adb-copy-folder.sh [app-package-name] [log-folder]
# Ex: ./adb-copy-folder.sh lt.markmerkk.blindless.app.debug databases
INPUT_PACKAGE=$1
INPUT_FOLDER=$2
if [[ -z ${INPUT_PACKAGE} && -z ${INPUT_FOLDER} ]] ; then
@marius-m
marius-m / LogExport.kt
Created November 11, 2022 14:44
Logging export mechanism (With zip funct)
import android.content.Context
import android.os.Environment
import androidx.lifecycle.LifecycleCoroutineScope
import com.spotos.core.LogUtils.withLogInstance
import com.spotos.core.LogUtils.withLogKlass
import com.spotos.core.Tags
import com.spotos.data.SentryInteractor
import com.spotos.data.ViewProvider
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
@marius-m
marius-m / FSLogTree.kt
Created November 11, 2022 12:47
Timber logging tree to file system and auto file rotation
import android.content.Context
import android.os.Environment
import android.util.Log
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.LoggerContext
import ch.qos.logback.classic.encoder.PatternLayoutEncoder
import ch.qos.logback.classic.html.HTMLLayout
import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.core.encoder.LayoutWrappingEncoder
import ch.qos.logback.core.rolling.RollingFileAppender
@marius-m
marius-m / decrypt.sh
Last active July 12, 2022 14:05
SH script that uses `openssl` to decrypt raw text input to aes-sha256-cbc + base64 (Check crypt.sh for inverse function)
#!/bin/bash
# Decrypts input file (+base64) contents with AES-256-CBC and a password
#set -x
FILE_IN=$1
if [[ -f $FILE_IN ]]; then
echo "Converting..."
else
echo "File not found!"
@marius-m
marius-m / crypt.sh
Last active July 12, 2022 14:06
SH script that uses `openssl` to encrypt raw text input to aes-sha256-cbc + base64 (Check decrypt.sh for inverse function)
#!/bin/bash
# Encrypts input file (+base64) contents with AES-256-CBC and a password
#set -x
FILE_IN=$1
if [[ -f $FILE_IN ]]; then
echo "Converting..."
else
echo "File not found!"
@marius-m
marius-m / qrcode.sh
Created June 22, 2022 13:43
Bash - QRCode generator
#!/bin/bash
#set -x
OUT_NAME=qrencode-$(uuidgen)
OUT_FILEEXT=png
OUT_FILENAME=${OUT_NAME}.${OUT_FILEEXT}
OUT_FILENAME_TXT=${OUT_NAME}-txt.${OUT_FILEEXT}
OUT=/tmp/${OUT_FILENAME}
OUT_TXT=/tmp/${OUT_FILENAME_TXT}
INPUT=$1
if [[ $# -eq 0 ]] ; then
@marius-m
marius-m / ViewExtensions.kt
Created May 20, 2022 09:09
Dynamically apply padding to view. Useful in RecyclerView with comples item composition.
/**
* Dynamically applies padding
*/
fun View?.applyPadding(
paddingStart: Int? = null,
paddingEnd: Int? = null,
paddingTop: Int? = null,
paddingBottom: Int? = null,
) {
this?.setPadding(
@marius-m
marius-m / ViewExtensions.kt
Created May 20, 2022 09:08
Dynamically apply margin to view. Useful in RecyclerView items when composing complex views
/**
* Dynamically applies margin
*/
fun View?.applyMargin(
marginStart: Int? = null,
marginEnd: Int? = null,
marginTop: Int? = null,
marginBottom: Int? = null,
) {
if (this !is ViewGroup) {
@marius-m
marius-m / DividerItemWithoutLastDecoration.kt
Last active May 20, 2022 08:12
ItemDecorator for RecyclerView + no decorator on the last item + offset for decorator
class DividerItemWithoutLastDecoration(
val divider: Drawable,
val dividerOffset: ItemDecoratorOffset = ItemDecoratorOffset.asEmpty(),
) : RecyclerView.ItemDecoration() {
override fun onDrawOver(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) {
val dividerLeft = parent.paddingLeft + dividerOffset.start
val dividerRight = parent.width - parent.paddingRight - dividerOffset.end
val childCount = parent.childCount
for (i in 0..childCount - 2) {
@marius-m
marius-m / ItemDecoratorOffset.kt
Created May 20, 2022 07:16
Helper class to define offset values in ItemDecorator
data class ItemDecoratorOffset private constructor(
val top: Int,
val bottom: Int,
val start: Int,
val end: Int,
) {
companion object {
fun asEmpty(): ItemDecoratorOffset {
return ItemDecoratorOffset(
top = 0,