Skip to content

Instantly share code, notes, and snippets.

Alexey Soshin AlexeySoshin

Block or report user

Report or block AlexeySoshin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gRPC with Gradle and Bazel - build.gradle.kts
import com.google.protobuf.gradle.*
...
protobuf {
...
generatedFilesBaseDir = "$buildDir/generated-sources"
...
dependencies {
protobuf(files(project.properties["protoDir"].toString()))
}
generateProtoTasks {
View Kotlin ADT - sum of numbers.kt
fun Tree<Int>.sum(): Long = when (this) {
Empty -> 0
is Node -> value + left.sum() + right.sum()
}
View Kotlin ADT - tree node.kt
data class Node<T>(
val value: T,
val left: Tree<T> = Empty,
val right: Tree<T> = Empty
) : Tree<T>()
View Kotlin ADT - empty tree.kt
object Empty : Tree<Nothing>() {
override fun toString() = "Empty"
}
View Kotlin ADT - creation.kt
val tree = Node(
42,
Empty,
Node(62)
)
println(tree)
View Kotlin ADT - Tree.kt
sealed class Tree<out T>
object Empty : Tree<Nothing>() {
override fun toString() = "Empty"
}
data class Node<T>(
val value: T,
val left: Tree<T> = Empty,
val right: Tree<T> = Empty
View Vert.x and SQL - JDBCClientImpl.java
public SQLClient getConnection(Handler<AsyncResult<SQLConnection>> handler) {
Context ctx = vertx.getOrCreateContext();
getConnection(ctx, ar -> ctx.runOnContext(v -> handler.handle(ar)));
return this;
}
View Vert.x and SQL - AbstractJDBCAction.java
public void execute(Connection conn,
TaskQueue statementsQueue,
Handler<AsyncResult<T>> resultHandler) {
ctx.executeBlocking(future -> handle(conn, future),
statementsQueue, resultHandler);
}
You can’t perform that action at this time.