Skip to content

Instantly share code, notes, and snippets.

View Audhil's full-sized avatar
🎯
Focusing

Mohammed Audhil Audhil

🎯
Focusing
View GitHub Profile
@Audhil
Audhil / DaemonNonDaemon.java
Created August 20, 2025 12:52
All about Daemons!
import java.util.concurrent.Executor;
public class ExecutorsSample {
public static void main(String[] args) {
// Executor executor = new Executor() {
// @Override
// public void execute(Runnable command) {
// command.run();
// }
// };
@Audhil
Audhil / ExecutorsSample.java
Created August 20, 2025 12:51
All about Executors!
import java.util.concurrent.Executor;
public class ExecutorsSample {
public static void main(String[] args) {
// Executor executor = new Executor() {
// @Override
// public void execute(Runnable command) {
// command.run();
// }
// };
@Audhil
Audhil / Main.java
Created August 20, 2025 12:50
All about threads!
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
public class Main {
public static void main(String[] args) {
// BankAccount account = new BankAccount();
// Thread t1 = new Thread(() -> account.withdraw(80), "Person-1");
// Thread t2 = new Thread(() -> account.withdraw(80), "Person-2");
@Audhil
Audhil / _1basics.ts
Last active October 28, 2022 16:31
Angular Basics
DOM(https://youtu.be/ipkjfvl40s0) - Document Object Model
object as a tree structure
DOM is an object-oriented representation of web page
Component(https://youtu.be/16rQyEQtpyQ?list=PLC3y8-rFHvwhBRAgFinJR8KHIrCdTkZcZ):
Template(view/HTML) + Class(code/typescript/data&methods) + Metadata(information decorator)
3 ways of declaring selector
1 -> selector: 'app-badwords' -> <app-badwords></app-badwords> in html file
// https://youtu.be/VWlwkqmTLHc?list=PLQkwcJG4YTCQcFEPuYGuv54nYai_lwil_
// USING TRY-CATCH FOR EXCEPTION HANDLING
// wrong
lifecycleScope.launch {
try {
launch {
throw Exception("failed")
}
} catch (e: Exception) {
}
@Audhil
Audhil / activity.kt
Last active September 15, 2022 14:01
Android basic brush up - AtoF & FtoA communication
class DummyActivity : AppCompatActivity(R.layout.activity_dummy) {
private val btn by lazy {
findViewById<Button>(R.id.btn)
}
private val tv by lazy {
findViewById<TextView>(R.id.tv)
}
var aToFragCallback: ActivityToFragCallBack<String>? = null
// exploring funcs & props usage in gradle file
// below code is placed in app/build.gradle
// executed tasks as `$ ./gradlew showMagics`
// https://medium.com/@dmitriileonov/5-gradle-things-that-get-android-developers-confused-ed606b8e8c92
class Foo {
def name = ""
void name(String newString) {
name = newString
println "Foo.name() triggered: name: $newString"
@Audhil
Audhil / CoroutineMistakes.kt
Created February 18, 2022 11:50
5 coroutine mistakes to avoid
package com.bhnetwork.scanit.consumer
import kotlinx.coroutines.*
import kotlin.random.Random
// mistake 1 - getFirstName call happens one after another
suspend fun getUserFirstNames(userIds: List<String>): List<String> {
val firstNames = mutableListOf<String>()
userIds.forEach {
firstNames.add(getFirstName(it))
@Audhil
Audhil / rounded_corner_ripple_btn.xml
Created August 9, 2021 14:25
adding ripple in rounded corner btns - usage: android:background="@drawable/rounded_corner_ripple_btn"
<?xml version="1.0" encoding="UTF-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="@color/black_10"
tools:targetApi="lollipop"><!-- ripple effect color -->
<!-- background color -->
<item android:id="@android:id/background">
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
@Audhil
Audhil / AnyFrag.kt
Created June 30, 2021 17:08
Dynamically changing(Overriding) - color from colors.xml
class DynamicHomeFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val color2 = requireActivity().application.resources.getColor(R.color.your_special_color, null) // returns Color.GREEN
binding.content.ll3.setBackgroundColor(color2)
}
}