Skip to content

Instantly share code, notes, and snippets.

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),
@doole
doole / wine32_macos.org
Last active September 20, 2024 08:51
Use win32 binaries on macOS 10.15/11.0

macOS wine 32/64-bit Setup

Run 32-bit apps on macOS Catalina (10.15) and Big Sur (11.0).

Installation

Dependencies

First install homebrew brew.sh

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@Haoxiqiang
Haoxiqiang / KtorExtensions.kt
Created May 6, 2022 03:38
Ktor support request with gzip on the Android platform.
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 {