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
/** | |
* Created by renkai on 16/9/7. | |
*/ | |
object Main2 { | |
def isSingleton[A](a: A)(implicit ev: A <:< Singleton = null) = { | |
Option(ev).isDefined | |
} |
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
[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 |
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 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:'] |
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
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 { |
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.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 { |
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
/* | |
* This file was generated by the Gradle 'init' task. | |
* | |
* This generated file contains a sample Java project to get you started. | |
* For more details take a look at the Java Quickstart chapter in the Gradle | |
* User Manual available at https://docs.gradle.org/5.5.1/userguide/tutorial_java_projects.html | |
*/ | |
plugins { | |
// Apply the java plugin to add support for Java |
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
def compress(input: Array[Byte]): Array[Byte] = { | |
val bos = new ByteArrayOutputStream(input.length) | |
val gzip = new GZIPOutputStream(bos) | |
gzip.write(input) | |
gzip.close() | |
val compressed = bos.toByteArray | |
bos.close() | |
compressed | |
} |
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
val pool = Executors.newFixedThreadPool(16) | |
implicit val ec = ExecutionContext.fromExecutor(pool) | |
pool.shutdown() |
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
struct Foo { | |
x: u32, | |
y: f64, | |
} | |
fn main() { | |
let foo = Foo { | |
x: 1, | |
y: 1.024, | |
}; |
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
fn encode_spans(rx : CollectorRx) -> impl Iterator<Item = spanpb::Span> { | |
let finished_spans = rx.collect(); | |
let spans = finished_spans.into_iter().map(|span| { | |
let mut s = spanpb::Span::default(); | |
s.set_id(span.id.into()); | |
s.set_start(span.elapsed_start); | |
s.set_end(span.elapsed_end); | |
s.set_event_id(span.tag); |
OlderNewer