android kotlin coroutines

import kotlinx.coroutines.*
fun main() {
   repeat(3) {
        GlobalScope.launch {
            println("Hi from ${Thread.currentThread()}")
        }
    }
}
  • 非同步
import kotlinx.coroutines.*
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

val formatter = DateTimeFormatter.ISO_LOCAL_TIME
val time = { formatter.format(LocalDateTime.now()) }

suspend fun getValue(): Double {
    println("entering getValue() at ${time()}")
    delay(3000)
    println("leaving getValue() at ${time()}")
    return Math.random()
}

fun main() {
    runBlocking {
        val num1 = getValue()
        val num2 = getValue()
        println("result of num1 + num2 is ${num1 + num2}")
    }
}

同步

import kotlinx.coroutines.*
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

val formatter = DateTimeFormatter.ISO_LOCAL_TIME
val time = { formatter.format(LocalDateTime.now()) }

suspend fun getValue(): Double {
    println("entering getValue() at ${time()}")
    delay(3000)
    println("leaving getValue() at ${time()}")
    return Math.random()
}

fun main() {
    runBlocking {
        val num1 = async { getValue() }
        val num2 = async { getValue() }
        println("result of num1 + num2 is ${num1.await() + num2.await()}")
    }
}

job

val job: Job = GlobalScope.launch(Dispatchers.Main) {
    // launch coroutine in the main thread
    for (i in 10 downTo 1) { // countdown from 10 to 1
        textView.text = "count down $i ..." // update text
        delay(1000) // wait half a second
    }
    textView.text = "Done!"
}
job.cancel()

找出當初docker 容器(container)執行的指令(非compose)

 docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro assaflavie/runlike  <容器名稱>
docker run --rm -i -v /var/run/docker.sock:/var/run/docker.sock nexdrew/rekcod <容器名稱>

但是這種方式屬於 reverse 方式, 跟原本會有一些失真,但真的沒留下當初執行的指令, 也只好使用這種方式了

Linux shell script 關於array陣列用法

定義一個陣列

declare -a source_dirs_weekly=("2-w3-portal" "2-w3-opt" "2-w3-jtrac" "200-printer" "194-easyflow" "229-fileserver")

也可以醬

declare -a source_dirs_weekly=(
"2-w3-portal" 
"2-w3-opt" 
"2-w3-jtrac" 
"200-printer" 
"194-easyflow" 
"229-fileserver"
)

要取出資料,可以參考以下的設定, 來源為這 https://opensource.com/article/18/5/you-dont-know-bash-intro-bash-arrays

centos 7 啟用NFS server

服務器端啟用nfs server

yum install nfs-utils

## 分享目錄
mkdir -p /mnt/docker
vi etc/exports
=================
#只讀ro,  10.192.130.4可使用
/mnt/docker      10.192.130.4(ro,sync,no_root_squash,no_all_squash)
#讀寫rw,  10.192.130.0/24網段可使用
/mnt/docker      10.192.130.0/24(rw,sync,no_root_squash,no_all_squash)
=================

#啟用
firewall-cmd --zone=public --add-service=nfs --permanent

## rockylinux
#firewall-cmd --add-service={nfs,nfs3,mountd,rpc-bind} --permanent

firewall-cmd --reload
systemctl enable nfs 
systemctl start nfs

## rockylinux
#systemctl enable nfs-server rpcbind
#systemctl start nfs-server rpcbind

#查看狀態(windows,linux通用)
showmount -e localhost

用戶端(linux)

mount -t nfs <server ip>:/mnt/docker  <本地要掛載的目錄>
或是
mount -t nfs4 <server ip>:/mnt/docker  <本地要掛載的目錄>

用戶端(windows)

mount -o anon  \\ip\mount_path  z:

nextcloud 上查詢支援onlyoffice的版本

https://apps.nextcloud.com/apps/onlyoffice/releases?platform=14

避免與不相容的版本起衝突

目前2022/5/13 我升級到nextcloud 22.2.7 , 但因為docker上面的onlyoffice 最新的是7.1.0,
onlyoffice 只有支援7.2以上才支援 nextcloud 23 , 所以我就無法升級到nextcloud 23囉

1 ... 13 14 15 16 17 ... 60