Skip to content

Instantly share code, notes, and snippets.

View Priyansh-Kedia's full-sized avatar
🍄
Learning & Exploring

Priyansh Kedia Priyansh-Kedia

🍄
Learning & Exploring
View GitHub Profile
@Priyansh-Kedia
Priyansh-Kedia / data.csv
Created January 18, 2020 09:53
BarChartD3
country population
China 1415046
India 1354052
United States 326767
Indonesia 266795
Brazil 210868
Pakistan 200814
Nigeria 195875
Bangladesh 166368
Russia 143965
@Priyansh-Kedia
Priyansh-Kedia / sigmoid
Created May 19, 2021 10:03
Plot the sigmoid function along with its derivative
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def derivative(x, step):
return (sigmoid(x+step) - sigmoid(x)) / step
x = np.linspace(-10, 10, 1000)
@Priyansh-Kedia
Priyansh-Kedia / ReLu Activation plot
Created May 19, 2021 19:16
Code for ReLu activation plot using matplotlib
from matplotlib import pyplot
def rectified(x):
return max(0.0, x)
series_in = [x for x in range(-100, 101)]
series_out = [rectified(x) for x in series_in]
pyplot.plot(series_in, series_out)
pyplot.show()
@Priyansh-Kedia
Priyansh-Kedia / mutiny.py
Last active June 24, 2021 10:52
Code for importing mutiny dataset into Voxel51
import fiftyone as fo
import os
import xml.etree.ElementTree as ET
import cv2
name = "headsegmentation_dataset_ccncsa"
dataset_dir = "/home/priyansh-kedia/Documents/Datasets/headsegmentation_dataset_ccncsa/"
dataset = fo.Dataset()
@Priyansh-Kedia
Priyansh-Kedia / documentRepo.kt
Last active September 21, 2022 17:50
Document Repo for Pagination in MediaStore API
suspend fun getImages(count: Int, start: Int): Three<MutableList<Three<Uri?, String?, Date>>, Boolean, Int> {
val imagesList = mutableListOf<Three<Uri?, String?, Date>>()
var index = start
return withContext(Dispatchers.IO) {
while (imageCursor?.moveToPosition(i) == true) {
val id = imageIdColumn?.let { imageCursor.getLong(it) }
val dateModified = Date(TimeUnit.SECONDS.toMillis(imageCursor.getLong(imageDateModifiedColumn ?: 0)))
val displayName = imageDisplayNameColumn?.let { imageCursor.getString(it) }
@Priyansh-Kedia
Priyansh-Kedia / documentViewModel.kt
Created August 19, 2021 04:31
Document Viewmodel for MediaStore API
private val _imagesLiveData = MutableLiveData<MutableList<Three<Uri?, String?, Date>>>()
val imagesLiveData: LiveData<MutableList<Three<Uri?, String?, Date>>>
get() = _imagesLiveData
private var start = 0
private var areAllLoaded = false
fun getImages(count: Int) {
if (areAllLoaded)
return
@Priyansh-Kedia
Priyansh-Kedia / gist:a20c99d2b0ab37637ba3456576b01b65
Created August 19, 2021 04:33
Pagination in RecyclerView with GridLayoutManager
mediaRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
if ((gridLayoutManager.findLastVisibleItemPosition() == localDocumentsAdapter.itemCount - DOCUMENT_BUFFER) && dy > 0) {
documentViewModel.getImages(DOCUMENTS_COUNT)
}
}
})
@Priyansh-Kedia
Priyansh-Kedia / EMOJIS.kt
Created August 19, 2021 18:35
List of Emoji HTML codes
object EMOJIS {
private const val GRINNING_FACE = "&#128512;"
private const val BEAMING_FACE_WITH_SMILING_EYES = "&#128513;"
private const val GRINNING_SQUINTING_FACE = "&#128518;"
private const val GRINNING_FACE_WITH_SWEAT = "&#128517;"
const val FACE_WITH_TEARS_OF_JOY = "&#128514;"
private const val ROLLING_ON_THE_FLOOR_LAUGHING = "&#129315;"
private const val SLIGHTLY_SMILING_FACE = "&#128578;"
private const val UPSIDE_DOWN_FACE = "&#128579;"
@Priyansh-Kedia
Priyansh-Kedia / build.gradle
Created September 15, 2021 09:16
Build gradle for s3 upload and RxJava
// Aws SDK
implementation 'com.amazonaws:aws-android-sdk-core:2.6.+'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.2.+'
implementation 'com.amazonaws:aws-android-sdk-s3:2.6.+'
implementation 'com.amazonaws:aws-android-sdk-ddb:2.2.+'
// RxJava
implementation "io.reactivex.rxjava3:rxjava:3.0.4"
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
@Priyansh-Kedia
Priyansh-Kedia / UploadFileStatus.kt
Created September 15, 2021 09:43
Class for UploadFileStatus
sealed class UploadFileStatus{
data class FileStatus(val status: Int): UploadFileStatus()
data class Error(val exception: Throwable): UploadFileStatus()
data class Complete(val s3Url: String): UploadFileStatus()
data class Start(val start: Boolean): UploadFileStatus()
}