Skip to content

Instantly share code, notes, and snippets.

@Matikano
Matikano / LiveTemplates
Last active May 19, 2023 12:18
Android Studio usefull MVVM LiveTemplates
1. HiltViewModel (hiltvm) - it assumes you are using State and Event classes for ViewModel, as well as UiEvent class for handling one time UI events:
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.mssmk.cleanarchitecturetemplate.ui.utils.UiEvent
import kotlinx.coroutines.channels.Channel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
@pradhuman7d1
pradhuman7d1 / FAQ
Created November 26, 2021 12:37
Kotlin Collections
Q. What are some examples of collections ?
A. Lists, Arrays, Maps, Sets are collections.
Q. How many types of lists are there?
A. Lists are of two types : Mutable Lists and Immutable Lists.
Q. What is a map?
A. A map is a collection that holds and key and a value pair.
Q. What datatypes can be stored in collections?
@gmk57
gmk57 / CoroutineTimer.kt
Last active April 18, 2024 14:38
Coroutine-based solution for delayed and periodic work
/**
* Coroutine-based solution for delayed and periodic work. May fire once (if [interval] omitted)
* or periodically ([startDelay] defaults to [interval] in this case), replacing both
* `Observable.timer()` & `Observable.interval()` from RxJava.
*
* In contrast to RxJava, intervals are calculated since previous run completion; this is more
* convenient for potentially long work (prevents overlapping) and does not suffer from queueing
* multiple invocations in Doze mode on Android.
*
* Dispatcher is inherited from scope, may be overridden via [context] parameter.
@mitchtabian
mitchtabian / MainActivity.kt
Last active December 28, 2022 15:24
Basics #4: Dependencies that require dependencies (Concrete classes that you own)
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@Inject
@bradtraversy
bradtraversy / mongodb_cheat_sheet.md
Last active April 25, 2024 22:38
MongoDB Cheat Sheet

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@bradtraversy
bradtraversy / mysql_cheat_sheet.md
Last active April 26, 2024 06:57
MySQL Cheat Sheet

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@TWiStErRob
TWiStErRob / README.md
Last active June 12, 2023 00:21
Kotlin Script (kts) 1.3.21 with dependencies to call a JSON web endpoint, including tests
@felipecsl
felipecsl / extensions.kt
Last active September 12, 2021 18:55
Helpful Kotlin extension functions
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import org.gradle.api.Task
import org.gradle.api.Project
import org.gradle.api.UnknownTaskException
import org.gradle.api.GradleException
import org.gradle.api.plugins.ExtraPropertiesExtension
@SuppressWarnings("UNCHECKED_CAST")
fun <T> Project.ext(key: String): T {
@vxhviet
vxhviet / kotlinStandardLibrary.md
Last active September 12, 2021 18:52
Explore Kotlin Standard Library
package peterho.kotlintipstricks
import android.content.Context
import android.support.annotation.AttrRes
import android.support.annotation.StyleRes
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v7.app.AlertDialog
import android.support.v7.widget.RecyclerView
import android.text.TextUtils