Skip to content

Instantly share code, notes, and snippets.

View alexstyl's full-sized avatar

Alex Styl alexstyl

View GitHub Profile
@amarland
amarland / SvgDsl.kt
Last active June 3, 2023 17:38
A (very) minimal SVG DSL for Jetpack Compose on Android (inspired by https://twitter.com/alexstyl/status/1659043650238844928).
package com.amarland.simplesvgdsl
import androidx.compose.foundation.Image
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
@alexstyl
alexstyl / MaterialColors.kt
Created May 15, 2023 10:05
All colors found in the 2014 Material Design color palette, ready to be used in Jetpack Compose.
/**
* Contains all color defined in the 2014 Material Design color palette.
*
*
*/
object MaterialColors {
val Red50 = Color(0xFFFFEBEE)
val Red100 = Color(0xFFFFCDD2)
val Red200 = Color(0xFFEF9A9A)
val Red300 = Color(0xFFE57373)
import androidx.compose.animation.core.EaseInOut
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
@alexstyl
alexstyl / MachineId.kt
Last active November 3, 2022 14:19
Get MacOS Machine ID
// Java version of node-machine-id. Used to identify a Mac, for software installation or licenses purposes.
// See the node project at https://github.com/automation-stack/node-machine-id
suspend fun machineId(): String {
val platformUUID = getPlatformUUID()
return DigestUtils.sha256Hex(platformUUID)
}
private fun expose(result: String): String {
val startIndex = result.substringAfter("IOPlatformUUID").substringBefore("\n")
@rock3r
rock3r / .gitignore
Last active April 13, 2024 12:52
A template .gitignore for Kotlin projects using Gradle (with additional content for Android projects)
## Seb's .gitignore template
# You can find the most up-to-date version at https://go.sebastiano.dev/gitignore
# Partly based on templates by https://plugins.jetbrains.com/plugin/7495--ignore
# Released under a CC-0 License https://creativecommons.org/share-your-work/public-domain/cc0/
### Windows template
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
@alexstyl
alexstyl / SafeContent.kt
Last active May 5, 2022 07:33
A Composable that will keep push its content so that they are not drawn behind the system bars. This is useful for when you want to work on a layout without having to worry about insets.
@Composable
fun SafeContent(
systemBarsColor: Color = Color(0xFF082A3A),
content: @Composable () -> Unit
) {
Box(
modifier = Modifier
.background(systemBarsColor)
.systemBarsPadding()
.background(MaterialTheme.colors.background)
@c5inco
c5inco / CollapsingTabBar.kt
Last active August 17, 2022 00:05
Jetpack Compose implementation of inspirational design https://twitter.com/philipcdavis/status/1486871621600104450
package des.c5inco.material3
import androidx.compose.animation.*
import androidx.compose.animation.core.*
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
@watabee
watabee / android-demo-mode.zsh
Last active November 6, 2023 09:28
Enter or exit demo mode for the Android System UI
function android-demo-mode() {
CMD=$1
if [[ $CMD != "on" && $CMD != "off" ]]; then
echo "Usage: $0 [on|off] [hhmm]" >&2
return 1
fi
if [[ "$2" != "" ]]; then
HHMM="$2"
<?
# MIT license, do whatever you want with it
#
# This is my invoice.php page which I use to make invoices that customers want,
# with their address on it and which are easily printable. I love Stripe but
# their invoices and receipts were too wild for my customers on Remote OK
#
require_once(__DIR__.'/../vendor/autoload.php');
@evdama
evdama / tailwind.css
Created August 4, 2019 11:04
tailwind colors for light and dark theme via CSS variables
@import "tailwindcss/base";
@import "tailwindcss/components";
@import './components';
@import "tailwindcss/utilities";
@import './edm-utilities';
:root {
--font-family-one: Montserrat, sans-serif;
--font-family-two: Roboto, sans-serif;