This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
case "$1" in | |
"live") | |
AWS_PROFILE="--profile live ";; | |
*) | |
AWS_PROFILE="";; | |
esac | |
aws $AWS_PROFILE ec2 describe-instances\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object IPUtil { | |
fun cidr2range(cidr: String): IntRange { | |
val parts = cidr.split('/') | |
val address = ip2int(parts[0]) | |
val mask = -0x1 shl (32 - (parts.getOrNull(1)?.toInt() ?: 0)) | |
return IntRange(address and mask, address or mask.inv()) | |
} | |
fun int2ip(ip: Int) = | |
String.format("%d.%d.%d.%d", ip shr 24 and 0xff, ip shr 16 and 0xff, ip shr 8 and 0xff, ip and 0xff) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.reflect.KClass | |
/** | |
* Bit-mask [Enum]. | |
* | |
* use bit-mask to store [Enum] as multiple boolean flag. | |
* | |
* usage: | |
* ```kotlin | |
* enum class MyEnum(override val pos: Int) : Bitnum { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ConcurrentHashMap | |
/** | |
* In-memory 초간단 캐시 | |
* @param defaultTtl 기본 캐시 시간. 단위: 1초 | |
* @param defaultIgnoreTtlOnFail 실패시 캐시가 만료됐더라도 값을 이용할지 여부. [get], [collect]에 한정. | |
*/ | |
class SimpleCache<K, V>( | |
private val defaultTtl: Int = 600, | |
private val defaultIgnoreTtlOnFail: Boolean = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ``` | |
* val ssb = SimpleSqlBuilder(logger) | |
* ssb.select("a.id, a.col1, b.col2, c.meta_val") | |
* .from("table_a as a") | |
* .join("table_b as b on b.id = a.id") // simple left join | |
* .join("table_c as c on c.parent = a.id and c.meta_key = ?", META_KEY) // condition on join clue | |
* .where("a.name = ?", "BOB") // simple clue | |
* .andIn("a.type in ?", listOf("A", "B", "C")) // translated to "a.id in ('A','B','C')" | |
* .andBetween("a.age", 20, 30) // a.age between 20 and 30 |