Skip to content

Instantly share code, notes, and snippets.

View Elvis10ten's full-sized avatar

Elvis Chidera Elvis10ten

View GitHub Profile
{
"todo_list": {
"type": "screen",
"children": [
{
"type": "text_field",
"key": "search_term",
"width": "match_parent",
"hint": "Search for stuff"
},
data class Contention(
val selfBlock: Block,
val peersApexBlock: Block?
)
val isConnected = bondSteadyState == PeripheralBond.State.CONNECTED
val hasPriority = priority != NO_PRIORITY
private val maxPossibleConnectionAndInteractiveScore = 4 + 2
// Any device with a higher priority should always rank higher.
private val priorityScore = (maxPossibleConnectionAndInteractiveScore + 1.0).pow(priority)
private val connectionScore: Int get() {
data class Ledger(
val self: HostInfo,
val blocks: Set<Block> = emptySet()
)
data class Block(
val serviceClass: ServiceClass,
val profile: PeripheralProfile,
val peripheral: Peripheral,
val priority: Int,
val timestamp: Long,
val bondSteadyState: PeripheralBond.State,
val owner: HostInfo,
val canStreamData: Boolean,
val canHandleDataStream: Boolean
internal interface MulticastChannel {
@Throws(Exception::class)
fun init(receiver: MessageReceiver)
@Throws(Exception::class)
fun send(message: ByteArray, size: Int)
fun close()
}
object TimerResolution {
@JvmStatic
fun main(args: Array<String>) {
val numRepeat = 10
var total = 0L
for(repeatIndex in 0 until numRepeat) {
val startTime = System.nanoTime()
var stopTime = System.nanoTime()
import kotlin.math.abs
typealias Duration = Long
typealias Sample = Long
object ThreadSleepStats {
@JvmStatic
fun main(args: Array<String>) {
val durations = listOf(1L, 10L, 100L, 1000L)
// Example 1: Prints falsehoods at roughly 10 Hz
while(true) {
Thread.sleep(100)
println("Ronaldo is better than Messi")
}
// Example 2: Prints truism at roughly 1 KHz
while(true) {
Thread.sleep(1)
println("Human beings are great")
@Serializable
class SessionPacket(
@ProtoId(1)
val payload: ByteArray,
@ProtoId(2)
val sequenceNumber: Int
)