Skip to content

Instantly share code, notes, and snippets.

View vengateshm's full-sized avatar
🏠
Working from home

Vengatesh M vengateshm

🏠
Working from home
View GitHub Profile
@vengateshm
vengateshm / README.md
Created January 29, 2022 08:58 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@vengateshm
vengateshm / ReflectionUtils.java
Created October 22, 2021 06:06
Convert object to hashmap using reflection
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.function.IntFunction;
public class ReflectionUtils {
@vengateshm
vengateshm / MainActivity.kt
Last active September 24, 2021 17:48
Ktor client on Android
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import io.ktor.client.*
import io.ktor.client.engine.android.*
import io.ktor.client.features.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import io.ktor.client.features.logging.*
@vengateshm
vengateshm / ParallelExecution.kt
Created September 24, 2021 04:32
Execute coroutines in parallel and wait for result of all coroutines.
import kotlinx.coroutines.*
import kotlin.random.Random
import kotlin.system.measureTimeMillis
fun main(args: Array<String>) {
val time = measureTimeMillis {
runBlocking {
val coffeePowder = async {
println("Grinding coffee bean...")
grindCoffeeBeans()
@vengateshm
vengateshm / CoroutinesPractice.kt
Created September 23, 2021 17:28
This file has snippets of different coroutines concept
import kotlinx.coroutines.*
import kotlin.random.Random
import kotlin.system.measureTimeMillis
fun main(args: Array<String>) {
// measureCoroutineExecutionTime()
// catchExceptionOfLaunchCoroutineBuilder()
// catchExceptionOfAsyncCoroutineBuilder()
// fireAndForget()
// getReturnValueFromCoroutine()