Skip to content

Instantly share code, notes, and snippets.

View ImaginativeShohag's full-sized avatar
🍟
Already hungry...

Md. Mahmudul Hasan Shohag ImaginativeShohag

🍟
Already hungry...
View GitHub Profile
@ImaginativeShohag
ImaginativeShohag / HomeIndexScreen.kt
Created December 25, 2023 10:18
Temp file (Delete later)
@Composable
fun HomeIndexScreen(
viewModel: HomeIndexViewModel,
goToBookDetailsScreen: (bookId: Long) -> Unit,
goToNoteDetailsScreen: (noteId: Long) -> Unit,
goToAddNewReadingScreen: () -> Unit,
goToAddNewBookScreen: () -> Unit,
goToAuthorsScreen: () -> Unit,
goToPublishersScreen: () -> Unit,
goToLendAddScreen: () -> Unit,
@ImaginativeShohag
ImaginativeShohag / ExtMoshi.kt
Last active March 31, 2022 06:32
Extension functions to convert object to json and json to object using Moshi. It also works with List, ArrayList, Collection etc.
object MoshiUtil {
fun getMoshi(): Moshi {
return Moshi.Builder()
.add(MutableCollectionJsonAdapter.FACTORY)
.build()
}
}
inline fun <reified T> String?.getObjFromJson(): T? {
if (this == null) return null
@ImaginativeShohag
ImaginativeShohag / AppSignatureHelper.java
Last active February 15, 2022 06:19
This is the helper class and the helper script to generate your message hash to be included in your SMS message.
package com.google.samples.smartlock.sms_verify;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.util.Base64;
import android.util.Log;
import java.nio.charset.StandardCharsets;
@ImaginativeShohag
ImaginativeShohag / LocationProviderUtilClient.kt
Created January 17, 2022 07:13
This component used FusedLocationProviderClient to provide location update.
/**
* This component used [FusedLocationProviderClient] to provide location update.
* This is a Lifecycle-Aware Component. So it automatically start and stop location monitoring.
*
* Version: 1.0.220105
*
* Documentation about Lifecycle-Aware Component:
* [Lifecycle-Aware Component](https://developer.android.com/topic/libraries/architecture/lifecycle)
*
* Notes:
@ImaginativeShohag
ImaginativeShohag / install_latest_phpmyadmin.sh
Last active December 24, 2023 05:26
Install latest version of phpMyAdmin to Ubuntu.
#!/bin/sh
# ----------------------------------------------------------------
# This script will fetch the latest version from the phpMyAdmin
# website and do all the basic configurations for you.
# Enjoy.
#
# Copyright (c) 2021 Md. Mahmudul Hasan Shohag (imaginativeworld.org)
# This free software comes with ABSOLUTELY NO WARRANTY and
# is distributed under GNU GPL v3 license.
@ImaginativeShohag
ImaginativeShohag / whynotimagecarousel-v2-customview.kt
Last active May 22, 2021 06:08
Why Not! Image Carousel! - V2 - Custom View
carousel.carouselListener = object : CarouselListener {
override fun onCreateViewHolder(
layoutInflater: LayoutInflater,
parent: ViewGroup
): ViewBinding? {
// Here, our XML layout file name is custom_item_layout.xml. So our view binding generated class name is CustomItemLayoutBinding.
return CustomItemLayoutBinding.inflate(layoutInflater, parent, false)
}
override fun onBindViewHolder(
@ImaginativeShohag
ImaginativeShohag / RealPathUtil.kt
Last active October 20, 2023 16:40
Real Path Utility class for Android. Tested till API 33. Java Version of this: https://gist.github.com/ImaginativeShohag/476a5ba87824f6e036f6bce10e229079
import android.content.ContentUris
import android.content.Context
import android.database.Cursor
import android.net.Uri
import android.os.Environment
import android.provider.DocumentsContract
import android.provider.MediaStore
/**
* Real Path Utility class for Android.