Skip to content

Instantly share code, notes, and snippets.

View AdnanHabibMirza's full-sized avatar
🏠
Remote

Adnan Habib AdnanHabibMirza

🏠
Remote
View GitHub Profile
@AdnanHabibMirza
AdnanHabibMirza / Android string-array of all countries name
Last active January 30, 2019 20:07
The updated android string-array of all countries name in the world.
<string-array name="countries_array">
<item>Afghanistan</item>
<item>Albania</item>
<item>Algeria</item>
<item>American Samoa</item>
<item>Andorra</item>
<item>Angola</item>
<item>Anguilla</item>
<item>Antarctica</item>
<item>Antigua and Barbuda</item>

FWIW: I'm not the author of the content presented here (which is an outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

# This is a basic workflow to help you get started with Actions
name: Publish to store
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.hilt.navigation.HiltViewModelFactory
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavBackStackEntry
@AdnanHabibMirza
AdnanHabibMirza / slope_vs_starting.md
Created May 26, 2023 03:31 — forked from gtallen1187/slope_vs_starting.md
A little bit of slope makes up for a lot of y-intercept

"A little bit of slope makes up for a lot of y-intercept"

01/13/2012. From a lecture by Professor John Ousterhout at Stanford, class CS140

Here's today's thought for the weekend. A little bit of slope makes up for a lot of Y-intercept.

[Laughter]

@AdnanHabibMirza
AdnanHabibMirza / NetworkMonitor.kt
Last active July 22, 2024 13:45
Monitor network connectivity in android using callbackFlow.
interface NetworkMonitor {
val isOnline: Flow<Boolean>
}
class NetworkMonitorImpl @Inject constructor(
@ApplicationContext private val context: Context,
@Dispatcher(IO) private val ioDispatcher: CoroutineDispatcher,
) : NetworkMonitor {
override val isOnline: Flow<Boolean>
get() = callbackFlow {
@AdnanHabibMirza
AdnanHabibMirza / SearchViewModel.kt
Last active July 31, 2024 23:58
Instant Search using Kotlin Coroutines/Flows with Single Source of Truth (SSOT)
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChanged
@AdnanHabibMirza
AdnanHabibMirza / Result.kt
Last active October 6, 2024 13:01
Streamlining State Management with a Generic Result Interface and Flow Mapper in Kotlin
sealed interface Result<out T> {
data class Success<T>(val data: T) : Result<T>
data class Error(val exception: Throwable) : Result<Nothing>
data object Loading : Result<Nothing>
}
fun <T> Flow<T>.asResult(): Flow<Result<T>> = map<T, Result<T>> { Result.Success(it) }
.onStart { emit(Result.Loading) }
.catch { emit(Result.Error(it)) }