Skip to content

Instantly share code, notes, and snippets.

View smallufo's full-sized avatar
🏠
Working from home

smallufo

🏠
Working from home
  • Taiwan
View GitHub Profile
2020-08-18 16:51:09.753 [main] INFO c.g.a.c.h.HttpRequest - curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: great36 Google-API-Java-Client/1.30.10 Google-HTTP-Java-Client/1.36.0 (gzip)' -H 'x-goog-api-client: gl-java/11.0.4 gdcl/1.30.10 mac-os-x/10.14.6' -H 'Content-Type: application/json; charset=UTF-8' -H 'Content-Encoding: gzip' -d '@-' -- 'https://www.googleapis.com/calendar/v3/calendars/3fxxxxxxxxxxxxxxxxxxxxdggc@group.calendar.google.com/events' << $$$
2020-08-18 16:51:09.754 [main] TRACE s.u.l.i.LoggingProviderImpl$JULWrapper - ProxySelector Request for https://www.googleapis.com/calendar/v3/calendars/3fxxxxxxxxxxxxxxxxxxxxdggc@group.calendar.google.com/events
2020-08-18 16:51:09.754 [main] TRACE s.u.l.i.LoggingProviderImpl$JULWrapper - Looking for HttpClient for URL https://www.googleapis.com/calendar/v3/calendars/3fxxxxxxxxxxxxxxxxxxxxdggc@group.calendar.google.com/events and proxy value of DIRECT
2020-08-18 16:51:09.755 [main] TRACE s.u.l.i.
package moshi
import com.squareup.moshi.*
interface IRunnable {
fun run()
}
class Cat : IRunnable {
interface IRunnable {
fun run()
}
class Horse : IRunnable {
override fun run() {
println("horse running")
}
}
interface IRunnable {
fun run()
}
class Horse : IRunnable {
override fun run() {
println("horse running")
}
}
@smallufo
smallufo / HedgingByOkHttp.kt
Created November 9, 2019 05:01
Hedging By OkHttp
package destiny
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.*
import mu.KotlinLogging
import okhttp3.OkHttpClient
import okhttp3.Request
/**
* ru.gildor.coroutines:kotlin-coroutines-okhttp:1.0
@smallufo
smallufo / HedgingTest.kt
Created November 8, 2019 15:48
Hedging with blocking http client
package destiny
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.*
import mu.KotlinLogging
import org.apache.http.client.fluent.Request
import java.net.URLEncoder
import kotlin.test.Test
@smallufo
smallufo / FlowOn.kt
Created November 8, 2019 14:58
flow on...
private suspend fun method1a(longUrl: String): String {
return impls.asSequence().asFlow().flatMapMerge(impls.size) { impl ->
flow {
impl.getShortUrl(longUrl)?.also {
emit(it)
}
}.flowOn(Dispatchers.IO)
}.first()
.also { Dispatchers.IO.cancelChildren() }
}
@smallufo
smallufo / SleepTest.kt
Created November 8, 2019 14:31
replace delay with sleep
class IsgdImpl : UrlShorter {
override suspend fun getShortUrl(longUrl: String): String? {
logger.info("running : {}", Thread.currentThread().name)
val url = "https://is.gd/create.php?format=simple&url=%s".format(URLEncoder.encode(longUrl, "UTF-8"))
return withContext(Dispatchers.IO) {
logger.info("running Dispatchers.IO : {}", Thread.currentThread().name)
Request.Get(url).also {
sleep(1000)
//delay(1000)
@smallufo
smallufo / Delay1.kt
Created November 8, 2019 12:07
Delay test
// delay ISGD more
class IsgdImpl : UrlShorter {
override suspend fun getShortUrl(longUrl: String): String? {
logger.info("running : {}", Thread.currentThread().name)
val url = "https://is.gd/create.php?format=simple&url=%s".format(URLEncoder.encode(longUrl, "UTF-8"))
return withContext(Dispatchers.IO) {
logger.info("running Dispatchers.IO : {}", Thread.currentThread().name)
Request.Get(url).also {
package destiny
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.*
import mu.KotlinLogging
import org.apache.http.client.fluent.Request
import java.net.URLEncoder
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors