Skip to content

Instantly share code, notes, and snippets.

@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"
       }
@tadfisher
tadfisher / AndroidUpdaterState.kt
Created June 1, 2022 18:00
In-app updates for Jetpack Compose
package com.mercury.app.updater
import android.app.Activity
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.IntentSenderRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
@tadfisher
tadfisher / BottomSheet.kt
Created April 29, 2022 22:43
BottomSheetHost
object BottomSheetDefaults {
@Stable
val Elevation = 16.dp
@Stable
val OuterPadding: PaddingValues = PaddingValues(top = 48.dp)
@tadfisher
tadfisher / LinkedText.kt
Created June 12, 2021 20:51
LinkedText.kt
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.LocalContentColor
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.runtime.Composable
@tadfisher
tadfisher / BaselineText.kt
Created June 8, 2021 18:30
BaselineText.kt
/**
* Wrapper for the [Text] element which adds additional padding after the last baseline
* such that the height of the last line of text matches the style's
* [lineHeight][TextStyle.lineHeight].
*/
@Composable
fun BaselineText(
text: String,
modifier: Modifier = Modifier,
color: Color = Color.Unspecified,
@tadfisher
tadfisher / build.nix
Last active September 21, 2024 16:48
Simplified Nix integration with Gradle
{ lib
, stdenv
, jdk
, gradle
, mavenRepo
}:
stdenv.mkDerivation {
pname = "built-with-gradle";
version = "0.0";
@tadfisher
tadfisher / config.gz
Created October 28, 2020 19:52
reMarkable 2 linux configuration
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm 4.14.78 Kernel Configuration
#
CONFIG_ARM=y
CONFIG_ARM_HAS_SG_CHAIN=y
CONFIG_MIGHT_HAVE_PCI=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
CONFIG_HAVE_PROC_CPU=y
CONFIG_STACKTRACE_SUPPORT=y
@tadfisher
tadfisher / trace.2415
Created October 24, 2020 22:13
reMarkable 2 strace dumps
This file has been truncated, but you can view the full file.
execve("/usr/bin/xochitl", ["xochitl", "--system"], 0x7edd49b8 /* 27 vars */) = 0
brk(NULL) = 0x240c000
uname({sysname="Linux", nodename="reMarkable", ...}) = 0
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76fb8000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=6737, ...}) = 0
mmap2(NULL, 6737, PROT_READ, MAP_PRIVATE, 3, 0) = 0x76fb6000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/libpdfium.so", O_RDONLY|O_CLOEXEC) = 3
@tadfisher
tadfisher / default.nix
Created January 28, 2020 21:59
gradle2nix updateScript wrapper
{ callPackage, jre, makeWrapper }:
rec {
buildGradle = callPackage ./gradle-env.nix {};
gradle2nix = buildGradle {
envSpec = ./gradle-env.json;
src = import ./fetch-source.nix {};
gradleFlags = [ "installDist" ];
nativeBuildInputs = [ makeWrapper ];
@tadfisher
tadfisher / fwupd.txt
Created August 15, 2018 21:13
fwupd logs
-- Logs begin at Mon 2018-07-02 12:37:49 PDT, end at Wed 2018-08-15 14:11:36 PDT. --
Aug 15 14:09:44 curie systemd[1]: Starting Firmware update daemon...
Aug 15 14:09:44 curie fwupd[7025]: 21:09:44:0974 Fu Verbose debugging enabled (on console 0)
Aug 15 14:09:44 curie fwupd[7025]: 21:09:44:0975 As run FuEngine:load
Aug 15 14:09:44 curie fwupd[7025]: 21:09:44:0975 Fu Daemon configuration /nix/store/89w6y6kaimpdb86vs116dgkprgrvz3gj-fwupd-1.1.0/etc/fwupd/daemon.conf not found
Aug 15 14:09:44 curie fwupd[7025]: 21:09:44:0975 Fwupd looking for os-release at /etc/os-release
Aug 15 14:09:44 curie fwupd[7025]: 21:09:44:0975 As run AsStore:load-installed{/nix/store/89w6y6kaimpdb86vs116dgkprgrvz3gj-fwupd-1.1.0/share/fwupd/metainfo}
Aug 15 14:09:44 curie fwupd[7025]: 21:09:44:0975 As adding existing file: /nix/store/89w6y6kaimpdb86vs116dgkprgrvz3gj-fwupd-1.1.0/share/fwupd/metainfo/org.freedesktop.fwupd.remotes.lvfs-testing.metainfo.xml
Aug 15 14:09:44 curie fwupd[7025]: 21:09:44:0975 As adding existing file: /nix/