Skip to content

Instantly share code, notes, and snippets.

View whitescent's full-sized avatar
😭
A proof of my faint existence

N3m whitescent

😭
A proof of my faint existence
View GitHub Profile
@iamcalledrob
iamcalledrob / CaptureComposable.kt
Last active June 12, 2025 10:06
Android headless composable capture
import android.app.Presentation
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Picture
import android.graphics.SurfaceTexture
import android.hardware.display.DisplayManager
import android.view.Display
import android.view.Surface
import android.view.ViewGroup
import androidx.compose.foundation.layout.Box
@JunkFood02
JunkFood02 / CarouselContainerTransformDemo.kt
Last active January 22, 2025 03:36
🐈 A demo showcasing the new shared element transition API in Jetpack Compose!
/*
* Copyright 2024 The Android Open Source Project, JunkFood02
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@KlassenKonstantin
KlassenKonstantin / Pull2Refresh.kt
Created March 26, 2024 11:23
Fitbit style Pull 2 Refresh
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
P2RTheme {
// A surface container using the 'background' color from the theme
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
CompositionLocalProvider(
LocalOverscrollConfiguration provides null // Disable overscroll otherwise it consumes the drag before we get the chance
/*
Copyright (c) 2025 Andrei Shikov
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
furnished to do so, subject to the following conditions:
@unixzii
unixzii / fuck-x.user.js
Last active September 27, 2024 05:18
Tampermonkey userscript to rescue your X (formerly Twitter) experience.
// ==UserScript==
// @name Fuck X
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Save your eyes while using X (formerly Twitter)
// @author Cyandev <[email protected]>
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
@tadfisher
tadfisher / PageLoadStates.kt
Last active January 9, 2024 10:28
Basic paging
sealed class PageLoadState(val endOfDataReached: Boolean) {
   data class Error(val error: Throwable: PageLoadState(false) {
       override fun toString(): String = "Error(error=$error"
   }
   sealed class NotLoading(endOfDataReached: Boolean: PageLoadState(endOfDataReached) {
       object Complete : NotLoading(true) {
           override fun toString(): String = "Complete"
       }
@Composable
fun AnimatedBorderCard(
modifier: Modifier,
contents: @Composable RowScope.() -> Unit
) {
val containerSize = 200.dp
var offsetFloat by remember { mutableStateOf(0f) }
LaunchedEffect(null) {
delay(100)
offsetFloat = containerSize.value * 10f
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.SpringSpec
import androidx.compose.animation.core.spring
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@mxalbert1996
mxalbert1996 / Scrollbar.kt
Last active June 1, 2025 16:19
Modifiers to draw scrollbars in Jetpack Compose
/*
* MIT License
*
* Copyright (c) 2022 Albert Chang
*
* 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
@apkelly
apkelly / Results.md
Last active August 6, 2024 06:58
Annotated String resources in Kotlin and for Jetpack Compose UI

The code below renders the following text in both Android Views and in Jetpack Compose UI.

Contact our team on 555 555 555 Opt 3 to activate.