Skip to content

Instantly share code, notes, and snippets.

View sellmair's full-sized avatar
🤪

Sebastian Sellmair sellmair

🤪
View GitHub Profile
@sellmair
sellmair / A_KN_1.kt
Last active March 15, 2019 20:22
A_K/N_1
interface LoginViewModel {
/* Inputs */
val userName: Subject<String>
val password: Subject<String>
val passwordRepetition: Subject<String>
val login: Trigger
/* Outputs */
@sellmair
sellmair / helpmeplease.js
Last active February 9, 2019 15:28
HEEELP
if (typeof kotlin === 'undefined') {
throw new Error("Error loading module 'output'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'output'.");
}
var output = function (_, Kotlin) {
'use strict';
var throwUPAE = Kotlin.throwUPAE;
var Unit = Kotlin.kotlin.Unit;
var IllegalStateException_init = Kotlin.kotlin.IllegalStateException_init;
var toString = Kotlin.toString;
var println = Kotlin.kotlin.io.println_s8jyv4$;
@sellmair
sellmair / Disposing on Android 3.kt
Created September 30, 2018 13:39
Disposing on Android 3
class MainActivity : AppCompatActivity() {
private lateinit var textView: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
textView = findViewById(R.id.text_view)
}
@sellmair
sellmair / Disposing on Android 2.kt
Created September 30, 2018 12:32
Disposing on Android 2.kt
class MyActivity: AppCompatActivity() {
private val lifecycleProvider = AndroidLifecycle.createLifecycleProvider(::getLifecycle)
fun onCreate() {
super.onCreate()
fetchData()
.flatMap(::prepareData)
.compose(lifecycleProvider.bindToLifecycle())
@sellmair
sellmair / Disposing on Android 1.kt
Last active October 1, 2018 06:36
Disposing on Android 1
class MyActivity {
var fetchDataDisposable: Disposable? = null
/* ... */
fun onCreate() {
super.onCreate()
/* stuff */
val patternDetector: PatternDetector = (TrendDownPatternDetector().combineWithoutOverlap(TrendUpPatternDetector()))
.combine(CheatDayPatternDetector().combineWithoutOverlap(SelfLyingPatternDetector())
.combine(DietPatternDetector())
.combine(MotivationBoostPatternDetector())
.combine(...)
...
fun PatternDetector.combineWithoutOverlap(other: PatternDetector): PatternDetector {
return OverlapFreePatternConnector(this, other)
}
class OverlapFreePatternDetectorConenctor (
private val first: PatternDetector,
private val second: PatternDetector): PatternDetector {
override fun findPatterns(data: List<Weight>): List<Pattern> {
val firstPatterns = first(data)
val secondPatterns = second(data)
val overlaps = overlaps(firstPatterns, secondPatterns)
val patternDetector: PatternDetector = TrendDownPatternDetector()
.combine(TrendUpPatternDetector())
.combine(CheatDayPatternDetector())
.combine(DietPatternDetector())
.combine(SelfLyingPatternDetector())
.combine(MotivationBoostPatternDetector())
.combine(...)
...
fun PatternDetector.combine(other: PatternDetector): PatternDetector {
return PatternDetectorConnector(this, other)
}