Skip to content

Instantly share code, notes, and snippets.

View HWilliamgo's full-sized avatar
πŸ₯³
to be happy when coding

HWilliamgo

πŸ₯³
to be happy when coding
View GitHub Profile
@HWilliamgo
HWilliamgo / Main.kt
Created May 20, 2022 03:43
[Kotlin elvis] #Kotlin
object StringProducer {
fun produce(): String? {
return "abc"
}
}
fun main() {
StringProducer.produce()?.let {
println(it)
} ?: run {
@HWilliamgo
HWilliamgo / main.cpp
Last active October 1, 2021 07:12
[CιšζœΊζ•°]#C
/**
* 在[range]θŒƒε›΄ε†…η”ŸζˆδΈ€δΈͺζ­£ηš„ιšζœΊζ•°
* @param range θŒƒε›΄
* @return ιšζœΊζ•°
*/
static int randomNum(int range) {
// η”¨ε½“ε‰ζ—Άι—΄ζˆ³η”ŸζˆιšζœΊζ•°η§ε­
time_t seed = time(0);
// ε°†ιšζœΊζ•°η§ε­ε‘«ε†™εˆ°ιšζœΊζ•°η”Ÿζˆε™¨ι‡Œι’
srand(seed);
@HWilliamgo
HWilliamgo / dynamic_cond_and_mutex.cpp
Last active October 2, 2021 06:40
[pthreadε€šηΊΏη¨‹]ζθΏ°η”ŸδΊ§θ€…ζΆˆθ΄Ήθ€…ζ¨‘εž‹ #C #ε€šηΊΏη¨‹
pthread_cond_t *condv = nullptr;
pthread_mutex_t *mlock = nullptr;
static data *phead = nullptr;
static void initLock() {
condv = new pthread_cond_t;
mlock = new pthread_mutex_t;
pthread_mutex_init(mlock, nullptr);
pthread_cond_init(condv, nullptr);
Java 29 hrs 6 mins β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–β–‘β–‘β–‘β–‘β–‘ 72.5%
Groovy 3 hrs 49 mins β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 9.5%
C 3 hrs 37 mins β–ˆβ–‰β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 9.0%
Text 1 hr 5 mins β–Œβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 2.7%
Bash 36 mins β–Žβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 1.5%