Skip to content

Instantly share code, notes, and snippets.

View Renkai's full-sized avatar
🤓
提升姿势水平中

Renkai Ge Renkai

🤓
提升姿势水平中
View GitHub Profile
@Renkai
Renkai / resetkafka.scala
Created September 12, 2018 06:20
reset kafka offset to specific timestamp
import java.time.{Instant, ZoneId, ZonedDateTime}
import java.util.Properties
import org.apache.kafka.clients.consumer.KafkaConsumer
import org.apache.kafka.common.TopicPartition
import org.apache.kafka.common.serialization.StringDeserializer
import scala.collection.JavaConverters._
object KafkaResetSample {
@Renkai
Renkai / build.gradle.kts
Created August 22, 2018 08:17
create fat jar with gradle kotlin dsl
tasks.create<Jar>("fatJar") {
appendix = "fat"
setDuplicatesStrategy(DuplicatesStrategy.FAIL)
manifest {
attributes(mapOf("Main-Class" to "Main")) // replace it with your own
}
val sourceMain = java.sourceSets["main"]
from(sourceMain.output)
configurations.runtimeClasspath.filter {
import sys
import getpass
import os
import pexpect
hosts = ['']
user = raw_input("type in the username:")
password = getpass.getpass('type in the password:')
expect_list = ['(yes/no)', 'password:']
@Renkai
Renkai / sbt_repositories
Created January 5, 2017 09:23
put it to ~/.sbt/repositories
[repositories]
local
maven-local
aliyun: http://maven.aliyun.com/nexus/content/groups/public
maven-central
sbt-maven-releases: https://repo.scala-sbt.org/scalasbt/maven-releases/, bootOnly
sbt-maven-snapshots: https://repo.scala-sbt.org/scalasbt/maven-snapshots/, bootOnly
typesafe-ivy-releases: https://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sbt-ivy-snapshots: https://repo.scala-sbt.org/scalasbt/ivy-snapshots/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
@Renkai
Renkai / Main2.scala
Last active November 14, 2016 12:35
/**
* Created by renkai on 16/9/7.
*/
object Main2 {
def isSingleton[A](a: A)(implicit ev: A <:< Singleton = null) = {
Option(ev).isDefined
}