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 / 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()
@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 / 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 / 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 / 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 / SystemBarColorChangeActivity.kt
Created September 29, 2023 11:36
This code shows how to change status bar color and navigation bar color in jetpack compose.
import android.app.Activity
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.tween
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
@vengateshm
vengateshm / EdgeToEdgeActivity.kt
Last active October 6, 2023 18:09
Enable edge to edge
import android.graphics.Color
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
@vengateshm
vengateshm / CoreJavaInterviewQuestions.md
Last active November 7, 2023 05:17
Core Java Interview questions
  1. OOPs concepts Encapsulation, Abstraction, Inheritance, Polymorphism and explain
  2. Exception hierarchy in inheritance
  3. Parent child override scenario
  4. Can we override static and private method?
  5. Difference between Java 7 and Java 8 interface (static methods and default methods introduced)
  6. Final, Finally, Finalize
  7. Equals and hashcode
  8. Why checked exception also called compile time exception, is it occurs in compile time?
  9. How to write custom exception?
  10. Throw and throws exception