Skip to content

Instantly share code, notes, and snippets.

Avatar

Paul Woitaschek PaulWoitaschek

View GitHub Profile
View kill-daemons.main.kts
#!/usr/bin/env kotlin
@file:DependsOn("com.github.ajalt.clikt:clikt-jvm:3.0.1")
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.UsageError
import com.github.ajalt.clikt.output.TermUi
class App : CliktCommand() {
enum class DaemonType {
View transition-outline.kt
package com.example.outlinetransition
import android.graphics.Color
import android.graphics.Outline
import android.os.Bundle
import android.view.View
import android.view.ViewOutlineProvider
import android.widget.FrameLayout
import androidx.annotation.ColorInt
import androidx.annotation.Px
View StupidLintRule.kt
import com.android.tools.lint.client.api.UElementHandler
import com.android.tools.lint.detector.api.Category
import com.android.tools.lint.detector.api.Detector
import com.android.tools.lint.detector.api.Implementation
import com.android.tools.lint.detector.api.Issue
import com.android.tools.lint.detector.api.JavaContext
import com.android.tools.lint.detector.api.Scope
import com.android.tools.lint.detector.api.Severity
import com.android.tools.lint.detector.api.SourceCodeScanner
import org.jetbrains.uast.UClass
View .gitconfig
# git report 2018-05-31
[alias]
report = "!f() { git log --after=\""$1" 00:00\" --before=\""$1" 23:59\" --pretty=format:\"* %s\" --reverse; }; f"
@PaulWoitaschek
PaulWoitaschek / Repo.kt
Last active Dec 27, 2017
Reactive Repository
View Repo.kt
class Repo<in Key : Any, Value : Any>(
private val dataSource: DataSource<Key, Value>,
private val persister: Persister<Key, Value>
) {
private val cleared = PublishSubject.create<Key>()
private val cache = HashMap<Key, Flowable<Value>>()
fun stream(key: Key): Flowable<Value> =
cache.getOrPut(key) { newStream(key) }
@PaulWoitaschek
PaulWoitaschek / layout.xml
Created Oct 13, 2017
CL Bug 1.1.0-beta3
View layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/red"
android:layout_width="0dp"
View ParcelTester.kt
import android.os.Parcel
import android.os.Parcelable
import org.assertj.core.api.Assertions.assertThat
/**
* A test for parcelable implementations
*/
class ParcelTester<T : Parcelable>(klazz: Class<T>) {
// access the creator through reflection like android does
@PaulWoitaschek
PaulWoitaschek / ControllerArgumentDelegate.kt
Last active Jul 28, 2017
Controller Argument Delegation. An extensible mechanism for seriaizing values to the Controllers bundle.
View ControllerArgumentDelegate.kt
/**
* An abstract argument delegate that uses the property to infer the key name for the bundle.
*/
abstract class ControllerArgumentDelegate<T : Any> : ReadWriteProperty<Controller, T> {
private var value: T? = null
override final fun getValue(thisRef: Controller, property: KProperty<*>): T {
if (value == null) {
val key = property.name
@PaulWoitaschek
PaulWoitaschek / ActivityModule.kt
Last active Apr 13, 2017
Activity Composition
View ActivityModule.kt
/**
* A module that can be used to abstract logic from the activity
*
* @author Paul Woitaschek
*/
@Suppress("UNUSED_PARAMETER")
abstract class ActivityModule {
lateinit var activity: CompositionActivity
You can’t perform that action at this time.