Skip to content

Instantly share code, notes, and snippets.

View ikovalyov's full-sized avatar

Illia Kovalov ikovalyov

View GitHub Profile
@ikovalyov
ikovalyov / block.txt
Created October 25, 2016 08:45
influx logs
--- contention:
cycles/second=3500003374
36366201471709872 346351 @ 0x441012 0x65c60e 0x463bc1
# 0x441012 runtime.selectgo+0x12 /usr/local/go/src/runtime/select.go:215
# 0x65c60e github.com/influxdata/influxdb/tsdb.(*Shard).monitorSize+0x28e /root/go/src/github.com/influxdata/influxdb/tsdb/shard.go:701
1478399522858787 704 @ 0x441012 0x636e39 0x463bc1
# 0x441012 runtime.selectgo+0x12 /usr/local/go/src/runtime/select.go:215
# 0x636e39 github.com/influxdata/influxdb/services/precreator.(*Service).runPrecreation+0x3f9 /root/go/src/github.com/influxdata/influxdb/services/precreator/service.go:77
<!DOCTYPE html>
<html>
<body>
<script>alert(1)</script>
</body>
var a = 0
fun counter() {
a++
println(a)
}
fun main() {
counter()
counter()
class TeaPotService {
fun turnOn() {
//do something
}
fun turnOff() {
//do something
}
}
fun main() {
if (turnOnTheTeaPot) {
// Turning teapot on
teaPotService.turnOn()
teaPotTurnedOn = true
} else {
// Turning teapot off
teaPotService.turnOff()
teaPotTurnedOn = false
}
fun turnOnTheTeaPot(teapotService: TeaPotService) : Boolean {
teaPotService.turnOn()
return true
}
fun turnOffTheTeaPot(teapotService: TeaPotService) : Boolean {
teaPotService.turnOff()
return false
}
val teaPotTurnedOn = if (turnOnTheTeaPot) {
// region Turning teapot on
teaPotService.turnOn()
true
// endregion
} else {
// region Turning teapot off
teaPotService.turnOff()
false
// endregion
sealed class State(val previousState: State?) {
class RequestReceived(val request: Int): State(null)
class RequestValidated(val validationResult: Boolean, previousState: RequestReceived): State(previousState)
class RequestProcessed(val response: Int, previousState: RequestValidated): State(previousState)
class ResponseValidated(val validationResult: Boolean, previousState: RequestProcessed): State(previousState)
}
abstract class Transition<InputState: State, OutputState: State> {
abstract fun invoke(state: InputState) : OutputState
}
class ValidateRequest: Transition<State.RequestReceived, State.RequestValidated>() {
override fun invoke(state: State.RequestReceived): State.RequestValidated {
// let's just check something here
return State.RequestValidated(state.request > 0, state)
}
}
fun List<Transition<State, State>>.fold(initial: State.RequestReceived): State.ResponseValidated {
var currentState: State = initial
forEach {
currentState = it.invoke(currentState)
}
if (currentState is State.ResponseValidated) {
return currentState as State.ResponseValidated
} else {
throw IllegalStateException("currentState is not of State.ResponseValidated type")
}