This file contains 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
mqtt: | |
sensor: | |
- name: "saturn_3_ultra_id" | |
state_topic: '/sdcp/status/{mainboardID}' | |
value_template: '{{ value_json.Id }}' | |
- name: "saturn_3_ultra_current_status" | |
state_topic: '/sdcp/status/{mainboardID}' | |
value_template: > | |
{% set status = value_json.Data.Status.CurrentStatus %} |
This file contains 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 socket | |
import time | |
import json | |
SATURN_UDP_PORT = 3000 | |
MQTT_PORT = 1883 | |
TIMEOUT = 2 | |
class SaturnPrinter: | |
def __init__(self, addr, data): |
This file contains 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
@RequiresApi(Build.VERSION_CODES.N) | |
class NetworkConnectivityObserver @Inject constructor( | |
context: Context | |
) { | |
enum class Status { | |
AVAILABLE, UNAVAILABLE, LOSING, LOST; | |
fun hasConnection(): Boolean = this == AVAILABLE || this == LOSING | |
} |
This file contains 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
data class NotFoundError(val message: String) : Result.Error.ErrorResponse() |
This file contains 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/sh | |
echo " " | |
echo " ################################################" | |
echo " ## Did you execute 1_format_extroot.sh first? ##" | |
echo " ################################################" | |
echo " " | |
read -p "Press [ENTER] if YES ...or [ctrl+c] to exit" | |
This file contains 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
class FlowResultCallAdapter<R>( | |
private val responseType: Type, | |
private val annotations: Array<out Annotation> | |
) : CallAdapter<R, Flow<Result<R>>> { | |
override fun adapt(call: Call<R>): Flow<Result<R>> { | |
return flow { | |
emit( | |
suspendCancellableCoroutine { continuation -> | |
call.clone().enqueue(object : Callback<R> { |
This file contains 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
@Target(AnnotationTarget.FUNCTION) | |
@Retention(AnnotationRetention.RUNTIME) | |
@Repeatable | |
annotation class ErrorType(val httpStatusCodeError: HttpStatusCodeError, val kClass: KClass<out Result.Error.ErrorResponse>) | |
fun parseError(statusCode: Int, responseBody: ResponseBody?, annotations: Array<out Annotation>): Result.Error.ErrorResponse? { | |
val errorBody = responseBody?.charStream()?.readText() ?: return null | |
val errorType: ErrorType = annotations.find { | |
it is ErrorType && it.httpStatusCodeError.statusCode == statusCode |
This file contains 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
enum class GameType(val xp: Int, val duration: Float) { | |
DisputaDaSpike(1000, 0.167F), | |
SemClassificacao(4000, 0.548F), | |
Disparada(800, 0.167F), | |
MataMata(900, 0.15F), | |
Replicacao(1700, 0.25F), | |
BatalhaNevada(825, 0.1F), | |
} |
This file contains 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
binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { | |
override fun onTabSelected(tab: TabLayout.Tab?) { | |
val position = tab?.position ?: 0 | |
val gameType: GameType = GameType.values()[position] | |
setListeners(gameType) | |
} | |
override fun onTabReselected(tab: TabLayout.Tab?) {} | |
override fun onTabUnselected(tab: TabLayout.Tab?) {} | |
}) |
This file contains 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
abstract class BaseListAdapter<T, U : ViewDataBinding>( | |
callback: DiffUtil.ItemCallback<T> | |
) : ListAdapter<T, BaseViewHolder<T, U>>(callback) { | |
abstract fun bindItem(item: T, viewBinding: U) | |
override fun onCreateViewHolder( | |
parent: ViewGroup, | |
viewType: Int | |
): BaseViewHolder<T, U> { |
NewerOlder