This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.nio.ByteBuffer; | |
import okio.Buffer; | |
import okio.BufferedSink; | |
import okio.BufferedSource; | |
import okio.Okio; | |
import okio.Sink; | |
import okio.Source; | |
import okio.Timeout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Any?.toIndentString(): String { | |
val notFancy = toString() | |
return buildString(notFancy.length) { | |
var indent = 0 | |
fun StringBuilder.line() { | |
appendln() | |
repeat(2 * indent) { append(' ') } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.* | |
fun main(args: Array<String>) { | |
val i = DoubleMatrix.identity(4) | |
val a = DoubleMatrix.ofRows { | |
row(1.0, 2.0, 3.0, 4.0) | |
row(5.0, 6.0, 7.0, 8.0) | |
row(9.0, 10.0, 11.0, 12.0) | |
row(13.0, 14.0, 15.0, 16.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.reactivex.Maybe | |
import io.reactivex.Single | |
import kotlin.properties.ReadOnlyProperty | |
import kotlin.reflect.KProperty | |
operator fun <T> Single<T>.provideDelegate(thisRef: Any?, property: KProperty<*>): ReadOnlyProperty<Any?, T> { | |
return SingleDelegate(this) | |
} | |
private class SingleDelegate<out T>(single: Single<T>) : ReadOnlyProperty<Any?, T> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object OneToMany { | |
private class One<O, M, C : MutableCollection<M>>(initial: O?, private val rightProperty: KMutableProperty1<O, C>) : ReadWriteProperty<M, O?> { | |
var one: O? = initial | |
override fun getValue(thisRef: M, property: KProperty<*>): O? = one | |
override fun setValue(thisRef: M, property: KProperty<*>, value: O?) { | |
when { | |
value != null -> add(value, thisRef) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Try<out T> { | |
companion object { | |
operator fun <T> invoke(f: () -> T) = try { | |
Success(f()) | |
} catch (t: Throwable) { | |
Failure(t) | |
} | |
@JvmStatic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HexCharset extends Charset { | |
public static final HexCharset INSTANCE = new HexCharset(); | |
private HexCharset() { | |
super("hex", new String[0]); | |
} | |
@Override | |
public boolean contains(Charset cs) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedHashMap; | |
import java.util.LinkedList; | |
import java.util.Map; | |
import org.apache.commons.math3.geometry.euclidean.twod.Line; | |
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; | |
import com.ibm.coderally.agent.CRSFileLog; | |
import com.ibm.coderally.agent.DefaultCarAIAgent; | |
import com.ibm.coderally.api.agent.AIUtils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Grammar<T> { | |
private T last; | |
private int count; | |
private final StringJoiner joiner; | |
public Grammar() { | |
this.last = null; | |
this.count = 0; | |
this.joiner = new StringJoiner(", "); |