Skip to content

Instantly share code, notes, and snippets.

@orochi663
orochi663 / eventflow.kt
Created February 7, 2024 23:53
Send Events in Flow Kotlin
import Event.NoneEvent
import kotlin.random.Random
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
/**
* You can edit, run, and share this code.
* play.kotlinlang.org
*/
@orochi663
orochi663 / testpvtpubenc.js
Created February 7, 2024 00:32
Public prviate encryption node js example
const {
generateKeyPairSync,
publicEncrypt,
publicDecrypt,
privateEncrypt,
privateDecrypt
} = require('crypto');
//generate a key pair RSA type encryption with a .pem format
const { publicKey, privateKey } = generateKeyPairSync('rsa', {
@orochi663
orochi663 / Reflection.kt
Last active February 8, 2024 17:38
Koltin Reflection Example
class A(val a: Int = 10){
fun getAValue(b: Int, c: Int): Int {
return a+b+c;
}
}
object Test{
inline fun <reified T> callMethod(obj: T, methodName: String, vararg params: Any?): Any? {
val method = T::class.java.methods.single{ it.name == methodName}
return method.invoke(obj, *params)
@orochi663
orochi663 / network-tweak.md
Created December 7, 2021 07:03 — forked from mustafaturan/network-tweak.md
Linux Network Tweak for 2 million web socket connections

Sample config for 2 million web socket connection

    sysctl -w fs.file-max=12000500
    sysctl -w fs.nr_open=20000500
    # Set the maximum number of open file descriptors
    ulimit -n 20000000

    # Set the memory size for TCP with minimum, default and maximum thresholds 
 sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'