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 / CalendarDateRange.kt
Created April 17, 2019 00:16
Kotlin Calendar/Date utils
import java.util.Calendar
import java.util.Date
class CalendarRange(override val start: Calendar, override val endInclusive: Calendar, val field: Int = Calendar.DAY_OF_YEAR) :
ClosedRange<Calendar>, Iterable<Calendar> {
override fun iterator(): Iterator<Calendar> {
return CalendarIterator(start, endInclusive, field)
}
}
@alashow
alashow / OkHttp3Stack.java
Last active May 21, 2024 01:54 — forked from bryanstern/OkHttpStack.java
An OkHttp backed HttpStack for Volley (okhttp3 version)
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Circle Internet Financial
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
# run in "root" folder (e.g /home/datmusic/api.datmusic.xyz/)
chown -R datmusic:www-data storage .env
find storage -type f -exec chmod 664 {} \;
find storage -type d -exec chmod 775 {} \;
chgrp -R www-data storage .env
chmod -R ug+rwx storage .env
@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
@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
/*
* 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