Skip to content

Instantly share code, notes, and snippets.

View hannesstruss's full-sized avatar
🤖

Hannes Struß hannesstruss

🤖
View GitHub Profile
@ruanbekker
ruanbekker / promtail_docker_logs.md
Last active April 29, 2024 22:18
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 December 24, 2023 13:01
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 =
@JakeWharton
JakeWharton / README.md
Last active April 17, 2023 14:07
A JUnit @rule which launches an activity when your test starts. Stop extending gross ActivityInstrumentationBarfCase2!
@JakeWharton
JakeWharton / README.md
Last active January 8, 2020 02:13
A special activity which facilitates restarting your application process.