Skip to content

Instantly share code, notes, and snippets.

View hrach's full-sized avatar

Jan Škrášek hrach

View GitHub Profile
@NicolaVerbeeck
NicolaVerbeeck / EncryptedFileStorage.kt
Last active April 18, 2024 21:12
Encrypted file storage for data store
package com.a.b
import android.content.Context
import androidx.annotation.GuardedBy
import androidx.datastore.core.ReadScope
import androidx.datastore.core.Serializer
import androidx.datastore.core.Storage
import androidx.datastore.core.StorageConnection
import androidx.datastore.core.WriteScope
import androidx.datastore.core.use
@CanYumusak
CanYumusak / LabelLayoutModifier.kt
Last active September 22, 2023 19:54
LabelLayoutModifier which adjusts Android text placement to match Figma text placement
public class LabelLayoutModifier(
val context: Context,
val lineHeight: TextUnit,
val style: MyTextStyle,
) : LayoutModifier {
override fun MeasureScope.measure(
measurable: Measurable,
constraints: Constraints
): MeasureResult {
@Aidanvii7
Aidanvii7 / NavGraph.kt
Last active October 17, 2021 12:38
Navigate with Parcelable arguments in Jetpack Compose
composable(route = "screen_1") {
Button(
onClick = {
navController.navigate(
route = "screen_2",
args = parcelableArgs {
arg { MyParcelableArgument() }
arg("named") { MyParcelableArgument() }
},
)
import androidx.compose.animation.*
import androidx.compose.animation.core.tween
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.onCommit
import androidx.compose.ui.Modifier
@OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialApi::class)
@Composable
fun <T> AnimatedSwipeDismiss(
Moved to https://google.github.io/accompanist/insets/
@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@kokes
kokes / netflix-cs-audio.txt
Last active November 2, 2019 20:38
Filmy s českýma titulkama na Netflixu
Alexa & Katie
All or Nothing
Angel of the Lord 2
Another Life
Backstage
Barbie Dolphin Magic
Basketball or Nothing
Beats
Black Mirror
Captain Underpants: The First Epic Movie
@abdalin
abdalin / DividerItemDecorator.java
Created April 8, 2018 21:18
divider item decoration for recyclerview with space removed after last item
public class DividerItemDecorator extends ItemDecoration {
public static final int HORIZONTAL = LinearLayout.HORIZONTAL;
public static final int VERTICAL = LinearLayout.VERTICAL;
private Drawable mDivider;
private int mOrientation;
private final Rect mBounds = new Rect();
public DividerItemDecorator(Drawable divider, int orientation) {
const copyToClipboard = str => {
const el = document.createElement('textarea'); // Create a <textarea> element
el.value = str; // Set its value to the string that you want copied
el.setAttribute('readonly', ''); // Make it readonly to be tamper-proof
el.style.position = 'absolute';
el.style.left = '-9999px'; // Move outside the screen to make it invisible
document.body.appendChild(el); // Append the <textarea> element to the HTML document
const selected =
document.getSelection().rangeCount > 0 // Check if there is any content selected previously
? document.getSelection().getRangeAt(0) // Store selection if found
@JanTvrdik
JanTvrdik / uuid.php
Last active February 14, 2018 14:11
PHP Fast and simple UUID v4 generator
<?php
function generateUuidWithoutDashes(): string
{
$uuidBin = random_bytes(16);
$uuidBin &= "\xFF\xFF\xFF\xFF\xFF\xFF\x0F\xFF\x3F\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
$uuidBin |= "\x00\x00\x00\x00\x00\x00\x40\x00\x80\x00\x00\x00\x00\x00\x00\x00";
$uuidHex = bin2hex($uuidBin);
return $uuidHex;