Skip to content

Instantly share code, notes, and snippets.

View Pooh3Mobi's full-sized avatar

Pooh3Mobi Pooh3Mobi

View GitHub Profile
package com.example
import org.apache.commons.math3.stat.inference.ChiSquareTest
import java.util.Random
/**
* カイ二乗検定のデモ
* https://github.com/komiya-atsushi/dbflute-fes-2014-demo/blob/master/src/main/java/biz/k11i/demo/stat/ChiSquareTestDemo.java
* Kotlin ver
*/
@Pooh3Mobi
Pooh3Mobi / Chapter3_5.kt
Last active September 5, 2018 15:25
Study of Kotlin Domain Modeling : Functional And Reactive Domain Modeling - ADT and Smart Constructor -
@file:Suppress("DataClassPrivateConstructor")
// ADT and Smart Constructor
package com.example.algebra
import java.math.BigDecimal
import java.util.*
// domain modeling part
@Pooh3Mobi
Pooh3Mobi / RepeatableProcess.kt
Last active October 9, 2019 15:32
失敗したらMAXまでリトライし、成功したら次の処理を行うKotlinコード、失敗の情報は保持する
package com.example.forloop
sealed class Result<T, E> {
data class Success<T, E>(val t: T) : Result<T, E>()
data class Failure<T, E>(val e: E) : Result<T, E>()
}
sealed class MultiResult<T, E> {
data class Success<T, E>(val t: T, val ers: List<E>?) : MultiResult<T, E>()
data class Failures<T, E>(val msg: String, val ers: List<E>) : MultiResult<T, E>()
package input.your.pkg
import android.graphics.Bitmap
import android.view.View
import com.google.firebase.ml.vision.FirebaseVision
import com.google.firebase.ml.vision.common.FirebaseVisionImage
import kotlinx.android.synthetic.main.activity_main.*
public fun MainActivity.detectTextOnCloud(bitmap: Bitmap) {
@Pooh3Mobi
Pooh3Mobi / BinHeapTree.kt
Last active July 19, 2018 15:29
The Fun of Programming with Kotlin
package mobi.pooh3.thefun.fp.bitree
import kotlin.test.assertFalse
import kotlin.test.assertTrue
/*
The Fun of Programming 1-1 [IFPH Section 6.3]
Q, 6つのjoinのうち2つは、そのどちらか一方だけを使うと、すべての木が線形になってしまう。どの二つか?
A, 1 & 5
@Pooh3Mobi
Pooh3Mobi / DiffProgramming01.kt
Created July 11, 2018 14:59
differential programming at kotlin
interface AFunctionExecutor {
fun execute(tag: String = "None", name: String = "Taro", age: Int=32)
}
class DefaultFunctionExecutor : AFunctionExecutor {
override fun execute(tag: String , name: String, age: Int) = println("[$tag] $name($age)")
}
class SoccerFunctionExecutor : AFunctionExecutor {
override fun execute(tag: String, name: String, age: Int) {
@Pooh3Mobi
Pooh3Mobi / Result.kt
Last active October 9, 2019 14:01
Kotlin Result utility
package mobi.pooh3..util
/*
Copyright (c) <2018> <PooheMobi@GitHub>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@Pooh3Mobi
Pooh3Mobi / FRPSeekBarMetronomeFragment.kt
Last active March 18, 2018 02:00
Kotlin-FRP Metronome sample code
import android.media.ToneGenerator
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.jakewharton.rxbinding2.widget.text
import com.jakewharton.rxbinding2.widget.userChanges
import io.reactivex.Observable
// Row.kt
sealed class Row {
data class Header(
val columns: List<String>
) : Row()
data class Item(
val id: Long,
val name: String,
val price: Long?
sealed class Row {
data class Header(
val columns: List<String>
) : Row()
data class Item(
val id: Long,
val name: String,
val price: Long?
) : Row()