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 / .bash_aliases
Created August 5, 2017 06:21
A useful bash aliases file.
# Exits the terminal
alias e=exit
# Clears the window so you can see what's going on!
alias c=clear
# Uninstall your current app.
alias u='adb uninstall com.aniket'
# Clear data for the current app.
@AniketSK
AniketSK / dal-rice-recipe.txt
Last active June 20, 2018 15:39
A recipe for some nice spicy dal rice
Two medium length dark green chilis.
1 cup rice, 2 cups dal.
1 tsp: mustard seeds, asafoetida, cumin.
1 - 2 cloves of garlic
1 tbs or so of turmeric
Optional:
1 large tomato
1 small onion
@AniketSK
AniketSK / ExerciseJava.java
Last active July 5, 2018 08:03
A demonstration of setting and accessing time in a unit-safe way.
import java.util.concurrent.TimeUnit;
public class ExerciseJava {
private long duration;
public void setDuration(long duration, TimeUnit unit) {
this.duration = TimeUnit.MILLISECONDS.convert(duration, unit);
}
@AniketSK
AniketSK / build.gradle
Created November 14, 2018 18:58
Demonstration of how to extract dependencies from your build.gradle file.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
// Load dependencies
buildscript {
ext.kotlin_version = "1.3.0"
repositories {
google()
jcenter()
@AniketSK
AniketSK / ChannelIds.kt
Created December 1, 2018 17:52
Creating a list of and registering channels for notifications reliably.
package com.aniketkadam.premail.base.notifications
import android.app.NotificationManager
import androidx.annotation.StringRes
import com.aniketkadam.premail.R
enum class ChannelIds(
@StringRes val channelNameRes: Int, @StringRes val channelDescriptionRes: Int,
val importance: Int
) {
@AniketSK
AniketSK / ObservableBroadcastReceiver.kt
Created December 11, 2018 14:18
Generic Observable for turning BroadcastManagers into observable streams.
package com.aniketkadam.wifimanager.androidhelpers
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import io.reactivex.Observable
import io.reactivex.ObservableEmitter
import io.reactivex.ObservableOnSubscribe
import io.reactivex.disposables.Disposable
companion object {
/**
* Creates an intent for the TaskEditor state machine.
*
* Utility function to cut down on boilerplate.
*/
inline fun <reified S : TaskEditorState> editorIntent(
crossinline block: S.() -> TaskEditorState
): Intent<TaskEditorState> {
return intent {
¯\_(ツ)_/¯
@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
@AniketSK
AniketSK / Document.js
Created June 30, 2019 14:13
A higher order component to abstract away the connection to Firebase.
import React from 'react';
import firebase from 'firebase/app';
import { FormValidation } from '../../constants';
class Document extends React.Component {
constructor(props) {
super(props);
this.db = firebase.firestore();
this.db.settings({ timestampsInSnapshots: true });
this.willSubscribe = this.props.path != null;