Skip to content

Instantly share code, notes, and snippets.

View abdurahmanadilovic's full-sized avatar
🏠
Working from home

Abdurahman Adilovic abdurahmanadilovic

🏠
Working from home
View GitHub Profile
@gpeal
gpeal / ConflatedJob.kt
Last active September 5, 2023 19:10
Conflated Job
class MyClass(private val scope: CoroutineScope) {
private val job = ConflatedJob()
fun retry() {
retryJob += scope.launch {
delay(Long.MAX_VALUE)
}
}
}
@gpeal
gpeal / FragmentA.kt
Last active December 27, 2023 06:50
View Binding Delegates
class WifiNetworksFragment : TonalFragment(R.layout.wifi_networks_fragment) {
// This automatically creates and clears the binding in a lifecycle-aware way.
private val binding: WifiNetworksFragmentBinding by viewBinding()
...
}
class WifiNetworkView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
@gpeal
gpeal / fadeTo.kt
Last active August 19, 2023 21:22
Fade To
/**
* Fade a view to visible or gone. This function is idempotent - it can be called over and over again with the same
* value without affecting an in-progress animation.
*/
fun View.fadeTo(visible: Boolean, duration: Long = 500, startDelay: Long = 0, toAlpha: Float = 1f) {
// Make this idempotent.
val tagKey = "fadeTo".hashCode()
if (visible == isVisible && animation == null && getTag(tagKey) == null) return
if (getTag(tagKey) == visible) return
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers