Skip to content

Instantly share code, notes, and snippets.

handstandsam /
Last active December 16, 2023 04:44
Google's Gemini AI Wrote me a Song
import pathlib
import google.generativeai as genai
import as glm
model = genai.GenerativeModel('gemini-pro')
prompt = "I want to record a song in the next 30 minutes. I am a good guitar player, and okay singer. Can you come up with a simple song and chord progression? Please provide me with the bpm of the song, and be sure to include the following sections: verse, chorus, verse, chorus, bridge, chorus. This song should be about 3 minutes in length. Ideally it will use power chords on guitar or common major and minor chords on a guitar that is tuned in standard."
handstandsam / intersection.txt
Last active November 7, 2023 19:20
Work in Progress (Not finished) : Kotlin Script to take an AAR file and then strip a list of Classes out of it.
fun runCmd(
cwd: File,
cmd: String
) = runCatching {
println("In cwd ${cwd.path}, Running cmd $cmd")
handstandsam / build.gradle.kts
Last active September 26, 2023 16:08
NOTE: Kinda works.... Print Inputs and Output Directories for All Tasks in Project. This filters out all inputs/outputs outside of the project, and only looks at the directories monitored.
val outputFile = File("output.txt")
if(outputFile.exists() {
afterEvaluate {
project.tasks.forEach { task ->
buildString {
handstandsam /
Last active December 14, 2022 10:06
Python Script to parse permissions from an AndroidManifest.xml file, and sort them alphabetically.
from xml.dom.minidom import parseString
# Documentation on Permissions in AndroidManifest.xml
data = '' # string data from file
with open('AndroidManifest.xml', 'r') as f:
data =
dom = parseString(data) # parse file contents to xml dom
handstandsam / InstallReferrerExt.kt
Created February 28, 2022 20:29
Install Referrer KTX - Kotlin Coroutine friendly wrapper for the Google Play's InstallReferrerClient API. This API is used to ask Google Play about where the installation originated.
import android.content.Context
import android.os.RemoteException
import kotlinx.coroutines.CompletableDeferred
handstandsam / PokeballCompose.kt
Created January 16, 2022 20:24
Draw a Pokeball on Canvas using Jetpack Compose
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
handstandsam / Actor.kt
Created December 14, 2021 14:20
There is no support for Actor in Kotlin Multiplatform, nor is it planned. More info: What are the flaws of this?
* JVM Implementation from KotlinX Coroutines
public fun <E>
context: CoroutineContext = EmptyCoroutineContext,
capacity: Int = 0, // todo: Maybe Channel.DEFAULT here?
start: CoroutineStart = CoroutineStart.DEFAULT,
onCompletion: CompletionHandler? = null,
handstandsam / Dropdown.kt
Created July 20, 2021 12:23
Jetpack Compose Snippets
fun DropdownComposable(items: List<String> = listOf("A", "B", "C"), onClick: (String) -> Unit) {
var expanded by remember { mutableStateOf(false) }
var selectedIndex by remember { mutableStateOf(0) }
modifier = Modifier
) {
text = state.value.eventName,
handstandsam / MyLifecycleOwner.kt
Last active May 19, 2024 02:18
Jetpack Compose OverlayService. You have to have all the correct permissions granted and in your manifest, but if you do, this this will show a green box with "Hello" in it!
import android.os.Bundle
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleRegistry
import androidx.savedstate.SavedStateRegistry
import androidx.savedstate.SavedStateRegistryController
import androidx.savedstate.SavedStateRegistryOwner
internal class MyLifecycleOwner : SavedStateRegistryOwner {
private var mLifecycleRegistry: LifecycleRegistry = LifecycleRegistry(this)
private var mSavedStateRegistryController: SavedStateRegistryController = SavedStateRegistryController.create(this)
package com.handstandsam.mutablestateflow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.runBlockingTest
import org.junit.Test
class UseImmutableDataWithMutableStateFlow {
data class SomePojo(var name: String = "placeholder")