Skip to content

Instantly share code, notes, and snippets.

View AniketSK's full-sized avatar
😀
Available for consulting on Android, maybe fulltime for the right company!

Aniket Kadam AniketSK

😀
Available for consulting on Android, maybe fulltime for the right company!
View GitHub Profile
@AniketSK
AniketSK / CoroutineTestRule.kt
Last active April 14, 2023 18:56
A test rule to allow testing coroutines that use the main dispatcher. Without this you'd run into "java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize. For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used"
package com.aniketkadam.sharevideoshortcut
import org.junit.rules.TestWatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.runner.Description
package live.hms.video.media.tracks;
import android.content.Context;
import android.os.SystemClock;
import org.webrtc.CapturerObserver;
import org.webrtc.JavaI420Buffer;
import org.webrtc.Logging;
import org.webrtc.SurfaceTextureHelper;
import org.webrtc.VideoCapturer;
@AniketSK
AniketSK / settings.json
Last active July 23, 2021 11:35
Settings to turn off any kind of tooltip for vscode. This is particularly helpful if you're trying to write text and the constant tooltips are messing with you. By default it doesn't consider mdx markdown, so these settings make sure it also considers mdx, while applying the changes to markdown files.
{
"files.autoSave": "afterDelay",
"editor.suggest.snippetsPreventQuickSuggestions": false,
"files.associations": {
"*.mdx": "markdown",
"*.md":"markdown"
},
"[markdown]":{
"editor.wordWrap": "on",
"editor.quickSuggestions": false,
@AniketSK
AniketSK / firestore.rules
Created October 25, 2019 05:21
Some sample firebase rules.
rules_version = '2';
function isAuthenticated(request){
return request.auth != null && request.auth.uid != null
}
function isDocUidSameAsUserUid(request){
return request.auth.uid == request.resource.data.uid
}
@AniketSK
AniketSK / RealmModule.kt
Created December 30, 2020 10:29
A "module" in the Dependency Injection sense, which handles connecting to realm anonnymously for a given appid and prepares a synced realm instance for Android
package com.example.emojigarden
import android.app.Application
import android.util.Log
import io.realm.Realm
import io.realm.mongodb.App
import io.realm.mongodb.AppConfiguration
import io.realm.mongodb.Credentials
import io.realm.mongodb.User
@AniketSK
AniketSK / LceGeneric.kt
Created August 28, 2020 11:32
A way to define a generic kotlin lce.
sealed class Lce<T> {
class Loading<T> : Lce<T>() // Can't be an object since it wouldn't have the T otherwise.
data class Content<T>(val data : T) : Lce<T>()
data class Error<T>(val error : Throwable) : Lce<T>()
}
@AniketSK
AniketSK / MaxHeap.kt
Created August 9, 2020 05:34
Trying out MaxHeaps
package com.aniketkadam.heaps
import org.jetbrains.annotations.TestOnly
class MaxHeap<T : Comparable<T>> {
private val items: MutableList<T> = mutableListOf()
fun insertAll(items: List<T>): Unit = items.forEach(::insert)
fun insert(item: T): Unit {
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/placesRecyclerView"
@AniketSK
AniketSK / AttributeExtensions.kt
Created February 1, 2020 13:32
Used to make when clauses exhaustive
package com.aniketkadam.dogether.extensions
val <T> T.exhaustive: T
get() = this