Skip to content

Instantly share code, notes, and snippets.

View bubenheimer's full-sized avatar

Uli Bubenheimer bubenheimer

View GitHub Profile
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@amal
amal / Tooltip.kt
Last active December 21, 2023 11:25
How to show a tooltip in AndroidX Jetpack Compose?
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
// Tooltip implementation for AndroidX Jetpack Compose
// See usage example in the next file
// Tested with Compose version **1.1.0-alpha06**
// Based on material DropdownMenu implementation.
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.animateFloat
@dev-niiaddy
dev-niiaddy / QRPainter.kt
Last active May 13, 2024 10:47
A function to encode text as a QR code using BitmapPainter and zxing-core for use in jetpack compose with Image composable.
@Composable
fun rememberQrBitmapPainter(
content: String,
size: Dp = 150.dp,
padding: Dp = 0.dp
): BitmapPainter {
val density = LocalDensity.current
val sizePx = with(density) { size.roundToPx() }
val paddingPx = with(density) { padding.roundToPx() }
@LennyLizowzskiy
LennyLizowzskiy / Bitmappable.kt
Created July 21, 2023 12:26
Jetpack Compose / Composable to Bitmap converter
import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import android.graphics.Bitmap
import android.os.Handler
import android.os.Looper
import android.view.PixelCopy
import android.view.View
import androidx.compose.foundation.Image
import androidx.compose.foundation.background

This gist provides a more flexible version of adb that exposes the functionality to select a device and then use that device's serial number in one or more adb commands. It expands on the initial implementation of the deeplinks.sh gist.

Companion blog post for usage is 🔗 here.

Companion posts for earlier versions of the script: Extending an Interactive ADB

@Mikkareem
Mikkareem / ODatePicker.kt
Created November 16, 2023 13:21
Custom Date Picker using Jetpack Compose in Android
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize