Skip to content

Instantly share code, notes, and snippets.

View hannesstruss's full-sized avatar
🤖

Hannes Struß hannesstruss

🤖
View GitHub Profile
@ZacSweers
ZacSweers / kmp-new.sh
Last active April 7, 2026 09:26
kmp-new.sh
#!/usr/bin/env bash
set -euo pipefail
# KMP Project Generator
# Wraps https://github.com/Kotlin/kmp-wizard/ (AGP 9 templates)
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
cat <<'HELP'
Usage: kmp-new [--help]
@garriguv
garriguv / SKILL.md
Created March 13, 2026 11:04
Refactor Pass Skill
name refactor-pass
description Perform a refactor pass focused on simplicity after recent changes. Use when the user asks for a refactor/cleanup pass, simplification, or dead-code removal and expects build/tests to verify behavior.

Refactor Pass

Overview

Perform a cleanup pass after recent changes with a bias toward simpler code and verified behavior.

@ruanbekker
ruanbekker / promtail_docker_logs.md
Last active September 27, 2025 23:41
Docker Container Logging using Promtail
@chrisbanes
chrisbanes / CoroutineLifecycleObserver.kt
Last active September 9, 2022 14:07
LifecycleObserver which allows easy cancelling of coroutines
/*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@fvasco
fvasco / switchMap.kt
Created August 1, 2018 09:15
ReceiveChannel<E>.switchMap
fun <E : Any, R> ReceiveChannel<E>.switchMap(context: CoroutineContext = DefaultDispatcher,
transform: suspend (E) -> ReceiveChannel<R>): ReceiveChannel<R> =
produce(context) {
var originChannel: ReceiveChannel<E>? = this@switchMap
var itemChannel = this@switchMap.receiveOrNull()?.let { transform(it) } ?: return@produce
var itemToSend: R? = null
whileSelect {
originChannel?.onReceiveOrNull?.invoke { newItem ->
if (newItem == null) originChannel = null // origin closed
@streetsofboston
streetsofboston / TestCoroutineContext.kt
Last active May 28, 2018 11:42
Kotlin Unit Tests Util for having testable functions using Coroutines: TestCoroutineContext
@file:Suppress("PackageDirectoryMismatch")
/*
* Copyright (c) 2018 Intrepid Pursuits,Inc. All rights reserved.
*/
package kotlinx.coroutines.experimental.intrepid
import kotlinx.coroutines.experimental.*
import java.util.concurrent.PriorityBlockingQueue
import java.util.concurrent.TimeUnit
@EricKuck
EricKuck / ButterknifeConductor.kt
Last active May 9, 2019 20:30
Kotterknife(ish) view binding for Conductor controllers
// Largely borrowed from Jake Wharton's Kotterknife (https://github.com/JakeWharton/kotterknife)
// and paweljaneczek's PR for resetting cached views (https://github.com/JakeWharton/kotterknife/pull/37)
package com.bluelinelabs.conductor.butterknife
import android.view.View
import com.bluelinelabs.conductor.Controller
import java.util.Collections
import java.util.WeakHashMap
import kotlin.properties.ReadOnlyProperty
@lopspower
lopspower / README.md
Last active October 2, 2025 17:34
Material Animations

Material Animations

Android Arsenal

[Android Transition Framework][transition-framework] can be used for three main things:

  1. Animate activity layout content when transitioning from one activity to another.
  2. Animate shared elements (Hero views) in transitions between activities.
  3. Animate view changes within same activity.
@JakeWharton
JakeWharton / gist:f50f3b4d87e57d8e96e9
Created February 7, 2015 01:59
Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your `src/debug/` code and run it when the application or main activity starts. Apache 2.
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =