Skip to content

Instantly share code, notes, and snippets.

View PaulWoitaschek's full-sized avatar

Paul Woitaschek PaulWoitaschek

View GitHub Profile
#!/usr/bin/env kotlin
@file:DependsOn("com.github.ajalt.clikt:clikt-jvm:3.5.2")
@file:OptIn(ExperimentalTime::class)
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import java.io.File
import java.security.MessageDigest
import kotlin.time.ExperimentalTime
internal class EnumGenerator(
private val codeGenerator: CodeGenerator
) {
fun generate(classDeclaration: KSClassDeclaration) {
require(classDeclaration.classKind == ClassKind.ENUM_CLASS) {
"${classDeclaration.containingFile?.filePath} is no enum."
}
val enum = buildEnum(classDeclaration)
internal class SwiftGenProcessor(
private val environment: SymbolProcessorEnvironment
) : SymbolProcessor {
private var invoked = false
override fun process(resolver: Resolver): List<KSAnnotated> {
if (invoked) {
return emptyList()
}
#!/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 {
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
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
@PaulWoitaschek
PaulWoitaschek / selector.kt
Last active December 2, 2018 20:06
Comparable selector
import java.util.*
import kotlin.comparisons.compareValuesBy
/**
* Demonstration of how the compare selectors could be moved to the companion object to prevent object allocations.
* Else each call to compareTo would create n new objects
*
* @author Paul Woitaschek
*/
class Foo(val a: String, val b: Int, val c: Date) : Comparable<Foo> {
@PaulWoitaschek
PaulWoitaschek / .gitconfig
Created May 31, 2018 08:53
Git Daily Report
# 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 December 27, 2017 18:18
Reactive Repository
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) }