Skip to content

Instantly share code, notes, and snippets.

View CanerPatir's full-sized avatar
🚀

Caner Patır CanerPatir

🚀
View GitHub Profile
@CanerPatir
CanerPatir / remove-untracking-remote-for-all.sh
Created April 5, 2021 11:01
remove-untracking-remote-for-all
#!/bin/zsh
for i in */.git;
do ( echo $i; cd $i/..; git pull; git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done );
done
package com.trendyol.inventorycenterapi.helper
import com.trendyol.inventorycenterapi.domain.inventory.CurrencyCode
import java.lang.reflect.*
import java.time.Instant
import kotlin.random.Random
import kotlin.reflect.full.createType
import kotlin.reflect.KClass
import kotlin.reflect.KType
import kotlin.reflect.KTypeProjection
namespace StockDomain
{
class Stock // aggregate root = nosql doc optimistic lock etc.
{
/*
*
* noSql document like this
* {
fun json(init: Json.() -> Unit): Json {
val json = Json()
json.init()
return json
}
open class Json {
private val entries: LinkedHashMap<String, Any> = linkedMapOf()
infix fun String.to(value: Any): Unit {
fun main(){
launch(Dispatchers.IO) {
val user = api.fetchUserInfoAsync(id).await()
withContext(Dispatchers.Default) {
val hash = user.username.hash()
}
}
}
fun String.md5(): String {
fun concurrencyTest(){
val time1 = measureTimeMillis {
runBlocking {
val listOfDeferred: List<Deferred<Int>> = (1..50).map { i ->
async {
delay(100)
Int.MIN_VALUE
}
}
}
fun main() = runBlocking {
GlobalScope.launch {
delay(1000L)
print("World!")
}
print("Hello")
}
fun main() {
runBlocking {
val deferred1 = async { operation1() }
val deferred2 = async { operation2() }
println("[${(SimpleDateFormat("hh:mm:ss")).format(Date())}] Awaiting computations...")
val result = deferred1.await() + deferred2.await()
println("[${(SimpleDateFormat("hh:mm:ss")).format(Date())}] The result is $result")
}
}
fun main() {
runBlocking {
val deferred1 = async { operation1() }
val deferred2 = async { operation2() }
println("[${(SimpleDateFormat("hh:mm:ss")).format(Date())}] Awaiting computations...")
val result = deferred1.await() + deferred2.await()
println("[${(SimpleDateFormat("hh:mm:ss")).format(Date())}] The result is $result")
}
}
suspend fun doOperation1() {
delay(1000L)
}
suspend fun getSomeResult(): String {
delay(2000L)
return "hello"
}
fun main(){