Skip to content

Instantly share code, notes, and snippets.

View rock3r's full-sized avatar

Sebastiano Poggi rock3r

View GitHub Profile
@rock3r
rock3r / highlights.md
Created February 6, 2024 11:05
Malformed highlight blocks tests
@rock3r
rock3r / DrawText.kt
Created August 20, 2023 10:38
Draw text on a bitmap
@OptIn(ExperimentalAnimationApi::class)
@Composable
private fun DrawText(it: PaddingValues) {
Column(Modifier.padding(it)) {
var text by remember { mutableStateOf("Vel eum voluptatem nulla. Ut enim unde sit autem laboriosam consequatur ut. Quo eius veniam occaecati minima. Porro architecto et omnis. Et dolor qui non. Tempora et consequuntur ea quia iste qui ducimus cum.\n") }
OutlinedTextField(value = text, onValueChange = { text = it.trim() })
val baseFontSizePx = with(LocalDensity.current) { 24.sp.toPx() }
val context = LocalContext.current
var bitmap by remember { mutableStateOf<ImageBitmap?>(null) }
@rock3r
rock3r / hvac_toggle.yaml
Created August 6, 2023 11:33
Home Assistant blueprint to turn a HVAC on or off based on a binary sensor
blueprint:
name: HVAC automation
source_url: https://gist.github.com/rock3r/5954b87184c6536bb8f2ea922bc97f02
description: Turn a HVAC on or off based on a binary sensor
domain: automation
input:
opening_sensor:
name: Window/Door sensor
description: The window or door sensor to use to drive the Tado valve
selector:
@rock3r
rock3r / svg2icns.sh
Created July 17, 2023 16:43
A macOS Bash script to generate an icns file (macOS app icons) from an svg file
#! /bin/bash
#----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# Sebastiano Poggi wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return. Seb
# ----------------------------------------------------------------------------
# Inspired by http://www.spaziocurvo.com/2015/03/svg-to-icns-script-for-mac-os-x/
# and https://gist.github.com/plroebuck/af19a26c908838c7f9e363c571199deb
@rock3r
rock3r / LoadResource.kt
Created July 7, 2023 13:46
JVM (Desktop) resource loading, for resources living in a different classloader
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Sebastiano Poggi wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Seb
* ----------------------------------------------------------------------------
*/
/**
@rock3r
rock3r / privacy-policy.md
Created June 14, 2023 18:23
Weeeeeee privacy policy

Weeeeee(th the Italians) privacy policy

We don't collect any user data, period.

@rock3r
rock3r / EqualWidthComponentsRow.kt
Last active July 5, 2023 14:40
Compose Custom Layout: row of components, all made as wide as the widest one
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Sebastiano Poggi wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Seb
* ----------------------------------------------------------------------------
*/
package dev.sebastiano.bundel
@rock3r
rock3r / myalbum_downloader.py
Created October 11, 2022 18:38
A downloader for MyAlbum.com albums. YMMV.
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Sebastiano Poggi wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return.
* Inspired by https://github.com/Gertje823/myalbum-downloader (which is now broken)
* ----------------------------------------------------------------------------
*/
@rock3r
rock3r / MainActivity.kt
Created June 16, 2022 16:13
WebView Compose scroll example
package dev.sebastiano.webviewcompose
import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
@rock3r
rock3r / rms.xml
Created May 23, 2022 15:01
rms — live template to insert/surround with "val ... by remember { mutableStateOf(...) }"
<template name="rms" value="val $name$ by androidx.compose.runtime.remember { androidx.compose.runtime.mutableStateOf($SELECTION$$END$) }" description="Remember mutableState" toReformat="false" toShortenFQNames="true">
<variable name="name" expression="kotlinSuggestVariableName()" defaultValue="name" alwaysStopAt="true" />
<context>
<option name="KOTLIN_EXPRESSION" value="true" />
</context>
</template>