Skip to content

Instantly share code, notes, and snippets.

@alashow
alashow / AnimationModifier.kt
Created October 21, 2024 22:11
animateContentSizeWithoutClipping
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationEndReason
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.AnimationVector2D
import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.VectorConverter
import androidx.compose.animation.core.VisibilityThreshold
import androidx.compose.animation.core.spring
import androidx.compose.runtime.getValue
@alashow
alashow / diff-plex-media-items.py
Created March 12, 2023 00:39
Get a diff of plex database media items by checking guids
import sqlite3
from tqdm import tqdm
from multiprocessing import cpu_count, Pool
def get_db(db_path):
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
return cursor
def is_relevant_section_type(item):
/**
* Returns a [Shape] for BottomSheet's current [sheetState].
* @return gradually un-rounding/rounding shape when [sheetState] is changing to [ModalBottomSheetValue.Expanded] or [ModalBottomSheetValue.HalfExpanded].
*/
@Composable
internal fun shape(
sheetState: ModalBottomSheetState,
radius: Dp = 16.0.dp,
): Shape {
val offsetFraction by remember {
@alashow
alashow / CurrencyAmountMask.kt
Created September 13, 2022 08:25
Buggy CurrencyAmountMask
package compose.CurrencyAmountMask
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.LocalTextStyle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@alashow
alashow / guess-to-ignore.py
Created May 7, 2022 04:04
devil is in the details
import argparse
import json
from guessit import guessit
from guessit.jsonutils import GuessitEncoder
from pprint import pp, pprint
from tqdm import tqdm
from multiprocessing import cpu_count, Pool
import random
import logging
import sys
@alashow
alashow / api.py
Last active November 26, 2023 11:53
Deemix api endpoint
from os import environ
from deezer import Deezer
from pathlib import Path
from deemix import generateDownloadObject
from deemix.__main__ import LogListener
from deemix.utils import getBitrateNumberFromText
from deemix.settings import load as loadSettings
from deemix.downloader import Downloader
/*
* Copyright (C) 2021, Alashov Berkeli
* All rights reserved.
*/
package tm.alashow.common.compose.ui
import androidx.compose.animation.core.Animatable
import androidx.compose.foundation.gestures.detectTransformGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
@Composable
private fun App() {
val isDarkMode = isSystemInDarkTheme()
val (darkMode, setDarkMode) = remember { mutableStateOf(isDarkMode) }
AppTheme(darkTheme = darkMode) {
Switch(checked = darkMode, onCheckedChange = setDarkMode)
Text("${AppTheme.colors.onSurfaceInputBackground.toArgb()}")
}
}
@alashow
alashow / rclone.conf
Created June 4, 2021 22:32
Simple gdrive service account rotations with rclone
[driva-0-sa]
type = drive
scope = drive
team_drive = xyz0
root_folder_id = xyz0
service_account_file = path
[driva-1-sa]
type = drive
scope = drive
/**
* The T generic is unused for some classes but since it is sealed and useful for Success and Fail,
* it should be on all of them.
*
* Complete: Success, Fail
* ShouldLoad: Uninitialized, Fail
*/
sealed class Async<out T>(val complete: Boolean, val shouldLoad: Boolean) {
open operator fun invoke(): T? = null