Skip to content

Instantly share code, notes, and snippets.

View oliverspryn's full-sized avatar
☀️
Everyday is a great day!

Oliver Spryn oliverspryn

☀️
Everyday is a great day!
View GitHub Profile
@oliverspryn
oliverspryn / SemanticsNodeInteractionExtension.kt
Created September 5, 2025 14:34
A custom assertion to check the role of a composable
fun SemanticsNodeInteraction.assertHasRole(
role: Role
): SemanticsNodeInteraction = assert(
SemanticsMatcher("The element has a role of $role") {
it.config.getOrNull(SemanticsProperties.Role) == role
}
)
@oliverspryn
oliverspryn / SemanticsNodeInteractionExtension.kt
Created September 5, 2025 14:33
Custom assertions for testing Jetpack Compose custom action labels and callbacks
fun SemanticsNodeInteraction.assertHasCustomActionLabel(
label: String, // Assert the label matches
actionIndex: Int = 0 // Which action to verify, if you have more than one
): SemanticsNodeInteraction = assert(SemanticsMatcher("The custom accessibility action label is set to $label") {
it.config
.getOrNull(SemanticsActions.CustomActions)
?.get(actionIndex)?.label == label
})
fun SemanticsNodeInteraction.invokeCustomAction(
@oliverspryn
oliverspryn / bard-prompt.txt
Created April 25, 2023 22:49
A prompt for Google Bard used to build ToDo Bard for Android using Jetpack Compose
I am going to build an native Android app using Kotlin and Jetpack Compose. I already have a new project created in Android Studio but would like your help for the rest. I don't have any screens, just an empty activity with a setContext() function inside of it, ready for Jetpack Compose to take over. My next prompt will explain what the app is for and what I want it to do.
This app should be a todo list app. It should have the following features:
- One screen with a list of all of your tasks.
- That screen should have an empty state saying "No Tasks" when there aren't any tasks stored in the app.
- The screen should have a FAB that allows you to add a new task to that list.
@oliverspryn
oliverspryn / chatgpt-prompt.txt
Last active March 20, 2025 13:50
A prompt for ChatGPT used to build ToDo GPT for Android using Jetpack Compose
I am going to build an native Android app using Kotlin and Jetpack Compose. I already have a new project created in Android Studio but would like your help for the rest. I don't have any screens, just an empty activity with a setContext() function inside of it, ready for Jetpack Compose to take over. My next prompt will explain what the app is for and what I want it to do.
This app should be a todo list app. It should have the following features:
- One screen with a list of all of your tasks.
- That screen should have an empty state saying "No Tasks" when there aren't any tasks stored in the app.
- The screen should have a FAB that allows you to add a new task to that list.
@oliverspryn
oliverspryn / Kotest Unit Test (Describe Spec).kt
Last active September 7, 2022 16:44
A collection of file templates and Live templates for Android Studio
#set( $testName = $NAME )
#set( $uutLength = $testName.length() - 4 )
#set( $uut = $testName.substring(0, $uutLength) )
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME} #end
import io.kotest.core.spec.style.DescribeSpec
class $testName : DescribeSpec({
describe("The $uut") {
val uut: $uut = $uut()
@oliverspryn
oliverspryn / git-upstream.sh
Created February 18, 2022 15:59
Set a Git branch's upstream with a single command
git checkout origin branch_that_is_already_on_origin
git upstream
# To use, add this to your ~/.gitconfig file
[alias]
upstream = !git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`
@oliverspryn
oliverspryn / git-new-delete.sh
Created February 18, 2022 15:57
Two Git aliases for creating and deleting branches
git new my_branch
git del my_branch
# To use, add this to your ~/.gitconfig file
[alias]
del = branch -D
new = checkout -b
@oliverspryn
oliverspryn / git-checkout.sh
Created February 18, 2022 15:55
Git alias for checkout
git co my_branch
# To use, add this to your ~/.gitconfig file
[alias]
co = checkout
@oliverspryn
oliverspryn / git-commit-status.sh
Last active February 18, 2022 15:56
Two Git aliases in action showing the commit and status shortcuts
git c "Added a new file"
git s
# To use, add this to your ~/.gitconfig file
[alias]
c = !git add -A && git commit -m
s = status
@oliverspryn
oliverspryn / bash-git-tab-completion.sh
Created February 18, 2022 15:42
Adds support for tab completion in Bash
# Download the scripts
cd ~
curl -o .git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
# ...
# Create or edit your .bashrc file and add this somewhere inside of it:
source ~/.git-completion.bash