Skip to content

Instantly share code, notes, and snippets.

View Damercy's full-sized avatar
:octocat:
Living a lie.

Dayamoy Adhikari Damercy

:octocat:
Living a lie.
View GitHub Profile
@manuelvicnt
manuelvicnt / ProvideViewModels.kt
Last active June 7, 2024 22:31
Scope ViewModels to Composables
// PLEASE, READ
//
// This is a way to scope ViewModels to the Composition.
// However, this doesn't survive configuration changes or procress death on its own.
// You can handle all config changes in compose by making the activity handle those in the Manifest file
// e.g. android:configChanges="colorMode|density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode">
//
// This is just an exploration to see what's possible in Compose. We don't encourage developers to copy-paste
// this code if they don't fully understand the implications of it and if this actually solves the use case to solve.
@danielballan
danielballan / patched_epics_motor.py
Created January 8, 2021 20:42
EpicsMotor alarm handling
from ophyd.epics_motor import EpicsMotor, required_for_connection, motor_done_move, AlarmSeverity
PatchedEpicsMotor(EpicsMotor):
@required_for_connection
@motor_done_move.sub_value
def _move_changed(self, timestamp=None, value=None, sub_type=None,
**kwargs):
'''Callback from EPICS, indicating that movement status has changed'''
was_moving = self._moving
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
fun EditText.onTextChanged(
@IntRange(from = 0, to = 10000) debounce: Int = 0,
cb: (String) -> Unit
) {
addTextChangedListener(object : TextWatcher {
val callbackRunner = Runnable {