Skip to content

Instantly share code, notes, and snippets.

View itasyurt's full-sized avatar

Ibrahim Tasyurt itasyurt

View GitHub Profile
{
"took": 130,
"timed_out": false,
"_shards": {
"total": 8,
"successful": 8,
"failed": 0
},
"hits": {
"total": 1731,
@itasyurt
itasyurt / balanced.py
Created November 5, 2018 12:23
balanced
__author__ = 'itasyurt'
class BinaryTreeNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
"scbEnrollIds": [
{
"score": 0.9642999768257141,
"id": 1193132
},
{
"score": 0.9640020132064819,
"id": 1468176
},
{
"scbEnrollIds": [
{
"score": 0.9642999768257141,
"id": 1193132
},
{
"score": 0.9640020132064819,
"id": 1468176
},
{
package com.udemy.kotlin.misc
data class Bolt(val size: Int)
data class Nut(val size: Int)
var counter = 0
fun compare(bolt: Bolt, nut: Nut): Int {
counter += 1
@Cacheable("upper")
fun getUpper(param: String): String {
Thread.sleep(1000)
return param.toUpperCase()
}
@CachePut("upper")
fun setUpper(param: String): String {
return param.toUpperCase()
}
@CacheEvict("upper")
fun removeUpper(param: String) {
println("$param removed!")
}
class ListCacheManager : AbstractCacheManager() {
var caches = mutableListOf<Cache>()
var cacheMap = mutableMapOf<String, Cache>()
override fun loadCaches() = caches
override fun getCache(name: String): Cache {
if (name in cacheMap) {
return cacheMap[name]!!
} else {
@Bean
override fun cacheManager() = ListCacheManager()
class ListCache(private val cacheName: String) : Cache {
override fun getName() = this.cacheName
private val cacheItems = mutableListOf<Pair<String, Any?>>()
override fun get(key: Any): Cache.ValueWrapper? {
val value = cacheItems.firstOrNull { it.first == key }?.second
return if (value != null) SimpleValueWrapper(value) else null
}