Run 32-bit apps on macOS Catalina (10.15) and Big Sur (11.0).
First install homebrew brew.sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
ktorHttpClient.post("xxxx") { | |
tryCompress(this, json) | |
} | |
private fun tryCompress(httpRequestBuilder: HttpRequestBuilder, json: JSONObject) { | |
val stringBody = tryCreateRequestBody(json = json) | |
if (stringBody.length > 4096) { | |
httpRequestBuilder.body = stringBody.gzipCompress() | |
httpRequestBuilder.headers[HttpHeaders.ContentEncoding] = "gzip" | |
} else { |
Run 32-bit apps on macOS Catalina (10.15) and Big Sur (11.0).
First install homebrew brew.sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
import kotlinx.cinterop.memScoped | |
import kotlinx.cinterop.allocArrayOf | |
import kotlinx.cinterop.addressOf | |
import kotlinx.cinterop.usePinned | |
import platform.Foundation.NSData | |
import platform.Foundation.create | |
import platform.posix.memcpy | |
public fun ByteArray.toData(): NSData = memScoped { | |
NSData.create(bytes = allocArrayOf(this@toData), |
import com.google.gson.Gson | |
import com.google.gson.GsonBuilder | |
import com.google.gson.TypeAdapter | |
import com.google.gson.TypeAdapterFactory | |
import com.google.gson.reflect.TypeToken | |
import com.google.gson.stream.JsonReader | |
import com.google.gson.stream.JsonWriter | |
import kotlin.jvm.internal.Reflection | |
import kotlin.reflect.KClass |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Job | |
import kotlinx.coroutines.delay | |
import kotlinx.coroutines.launch | |
/* | |
This is free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled |
class ApiClientServiceImpl( | |
client: HttpClient, parser: JsonParser | |
) : BaseApiClientService(client, parser) { | |
override suspend fun getCategories() = | |
requestCatching(Category.serializer().list) { | |
get() | |
apiUrl("/api/product/live/category/list") | |
accessHeaders() |
Taken from StackExchange
Thanks to LangLangC
For temperature and other improvements see https://gist.github.com/cdleon/d16e7743e6f056fedbebc329333d79df
protocol DogBreed { | |
typealias Level = Int | |
var breedName: String { get set } | |
var size: Level { get set } | |
var health: Level { get set } | |
var adaptability: Level { get set } | |
var intelligence: Level { get set } | |
var dogType: DogType { get set } |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:roundIcon="@mipmap/ic_launcher_round" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme" | |
android:networkSecurityConfig="@xml/network_security_config"> |
class Number /* class cluser */ { | |
class Int8: Number { | |
var value: Swift.Int8 | |
init(_ value: Swift.Int8) { self.value = value } | |
} | |
class Int: Number { | |
var value: Swift.Int | |
init(_ value: Swift.Int) { self.value = value } | |
} |