Skip to content

Instantly share code, notes, and snippets.

View sriharshachilakapati's full-sized avatar
👨‍💻
Learning to code, as always!

Sri Harsha Chilakapati sriharshachilakapati

👨‍💻
Learning to code, as always!
View GitHub Profile
@sriharshachilakapati
sriharshachilakapati / 3waysort.c
Created February 7, 2020 08:12
Sort 3 different arrays into 1 array
#include <stdio.h>
#include <stdlib.h>
void merge_sort(int*, int*, int);
void merge2(int* dest, int* a, int* b, int lenA, int lenB) {
// Array indices
int dI = 0, aI = 0, bI = 0;
// Copy the values from all the arrays
@sriharshachilakapati
sriharshachilakapati / TransformationUtils.kt
Created November 10, 2020 16:40
Transforms.map but with a default value
package com.goharsha.android.utils
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.Transformations
/**
* A utility to create a [LiveData] which will be giving out a [source] value manipulated with a
* [mapper] function. The difference between this function and [Transformations.map] is that this
* function additionally allows to set a [defaultValue] until the source starts producing.
@sriharshachilakapati
sriharshachilakapati / FoodRatingsBenchmark.kt
Created December 17, 2023 16:23
Benchmark for performance in data class vs normal class and kotlin comparisons vs custom comparator
package com.goharsha.benchmarks
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.infra.Blackhole
import java.util.concurrent.TimeUnit
import java.util.PriorityQueue
import kotlin.comparisons.compareByDescending
import kotlin.comparisons.thenBy