Skip to content

Instantly share code, notes, and snippets.

View XFY9326's full-sized avatar

逸雪飞扬 XFY9326

View GitHub Profile
@XFY9326
XFY9326 / GradleDigestUtils.java
Created November 28, 2021 19:57
Gradle download path digest calculation
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GradleDigestUtils {
private static final String MD5_DIGEST = "MD5";
private static final Pattern VERSION_PATTERN = Pattern.compile("^(.*?)-(src|bin|all)$");
private static final String GRADLE_DOWNLOAD_URL = "https://services.gradle.org/distributions/gradle-%s.zip";
@XFY9326
XFY9326 / build.gradle.kts
Last active January 24, 2023 02:34
Add Kotlin Symbol Processing (KSP) adaptation for Android Gradle Plugin (AGP) variants
extensions.getByType<AppExtension>().apply {
applicationVariants.all {
addJavaSourceFoldersToModel(file("$buildDir/generated/ksp/$name/kotlin"))
}
}
@XFY9326
XFY9326 / MeetInLeedsLogin.sh
Created March 4, 2022 18:11
'MeetInLeeds' Wi-Fi login script for 'University of Leeds'
#!/bin/sh
usage() {
if [ $1 == 1 ]; then
echo "MeetInLeeds Wi-Fi Login"
echo "Author: XFY9326"
echo "Website: https://xfy9326.github.io"
echo ""
fi
echo "Options:"
@XFY9326
XFY9326 / ComposeVerticalScrollBar.kt
Created March 25, 2022 11:59
Jetpack Compose VerticalScrollBar for Android
// Reference: https://stackoverflow.com/questions/66341823/jetpack-compose-scrollbars/68056586#68056586
// Modify: LazyListState -> ScrollState
fun Modifier.verticalScrollbar(
scrollState: ScrollState,
scrollBarWidth: Dp = 4.dp,
minScrollBarHeight: Dp = 5.dp,
scrollBarColor: Color = Color.Blue,
cornerRadius: Dp = 2.dp
): Modifier = composed {
@XFY9326
XFY9326 / dataclass_json_inherit.py
Created July 18, 2023 16:22
Example of using dataclass-json nested inheritance attributes
import dataclasses
import dataclasses_json
from dataclasses_json import DataClassJsonMixin
@dataclasses.dataclass(frozen=True)
class Value(DataClassJsonMixin):
value_type: str = dataclasses.field(init=False, default="unknown", metadata=dataclasses_json.config(field_name="type"))