Skip to content

Instantly share code, notes, and snippets.

View bennyhuo's full-sized avatar
🤔
Suspending.

Benny Huo bennyhuo

🤔
Suspending.
View GitHub Profile
@bennyhuo
bennyhuo / gist:63b8dd9194ab38cf9f10a19cf5ce7645
Last active December 29, 2023 01:59
外部工具开发鸿蒙 App 的 C++ 代码时,需要为 CMake 额外配置的变量,注意 $SDK_HOME 替换为 SDK 所在的目录,macOS 上一般为 ~/Library/Huawei/
-DOHOS_ARCH=arm64-v8a
-DCMAKE_BUILD_TYPE=Debug
-DOHOS_SDK_NATIVE=$SDK_HOME/Sdk/openharmony/10/native
-DCMAKE_SYSTEM_NAME=OHOS
-DCMAKE_OHOS_ARCH_ABI=arm64-v8a
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_TOOLCHAIN_FILE=$SDK_HOME/Sdk/hmscore/4.0.0/native/build/cmake/hmos.toolchain.cmake
-DCMAKE_MAKE_PROGRAM=$SDK_HOME/Sdk/openharmony/10/native/build-tools/cmake/bin/ninja
--no-warn-unused-cli
-DHMOS_SDK_NATIVE=$SDK_HOME/Sdk/hmscore/4.0.0/native
@bennyhuo
bennyhuo / init.gradle.kts
Last active April 29, 2024 15:53
How to config mirrors for repositories in Gradle without changing the source code of your project?
fun RepositoryHandler.enableMirror() {
all {
if (this is MavenArtifactRepository) {
val originalUrl = this.url.toString().removeSuffix("/")
urlMappings[originalUrl]?.let {
logger.lifecycle("Repository[$url] is mirrored to $it")
this.setUrl(it)
}
}
}
gradle.taskGraph.afterTask { task ->
StringBuffer taskDetails = new StringBuffer()
taskDetails << """"-------------
name:$task.name group:$task.group : $task.description
conv:$task.convention.plugins
"""
taskDetails << "inputs:\n"
task.inputs.files.each { it ->
taskDetails << "${it.absolutePath}\n"
}

The job2 will throw an ArithmaticException thus making the parent job cancelled. Normally we will get a CancellationException when calling the job2.join() but there is otherwise.

suspend fun main() = runBlocking {
    log(1)
    val job = launch(Dispatchers.Unconfined) {
        log(2)
        val job2 = launch(Dispatchers.Default) {
            log(3)
import com.squareup.javapoet.ClassName;
import java.util.HashMap;
/**
* Kotlin 和 Java 类型的映射关系,从 Kotlin 编译器中摘出来
* Created by benny on 2/5/18.
*/
public class TypesMap {
@bennyhuo
bennyhuo / README.md
Created October 10, 2015 14:49 — forked from agnoster/README.md
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark