Skip to content

Instantly share code, notes, and snippets.

View shibbirweb's full-sized avatar
Happy Coding

MD. Shibbir Ahmed shibbirweb

Happy Coding
View GitHub Profile
@shibbirweb
shibbirweb / Resource.kt
Last active October 25, 2022 07:05
Android: Kotlin Sealed Resource Class For API Request
package com.data.helpers
sealed class Resource<T, Y>(
val data: T? = null,
val error: Errors<Y>? = null
) {
class Success<T, Y>(data: T) : Resource<T, Y>(data)
class Error<T, Y>(error: Errors<Y>) : Resource<T, Y>(error = error)
}
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\sim-web.omp.json" | Invoke-Expression
Import-Module -Name Terminal-Icons
Import-Module -Name PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
# Import the Chocolatey Profile that contains the necessary code to enable
# tab-completions to function for `choco`.
@shibbirweb
shibbirweb / Binding.kt
Created August 4, 2022 06:29
Android: Dynamically set font for ASCII and UNICODE text
@BindingAdapter(value = ["android:fontFamilyByText"])
fun TextView.customFontFamilyByText(text: String?) {
val isAscii = Charsets.US_ASCII.newEncoder().canEncode(text)
val fontFamily = if (isAscii) {
ResourcesCompat.getFont(context, R.font.inter_variable_font_slnt_wght);
} else {
ResourcesCompat.getFont(context, R.font.noto_sans_bengali_variable_font_wdth_wght);
}
@shibbirweb
shibbirweb / Api.kt
Last active February 4, 2024 09:58
Android - Kotlin - Retrofit Authorization Token Interceptor
package com.***.data.apis
import android.content.Context
import com.****.data.apis.interceptor.ApiAcceptInterceptor
import com.****.data.apis.interceptor.AuthorizationTokenInterceptor
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit
@shibbirweb
shibbirweb / .htaccess
Created March 10, 2022 05:11
Force load .html page then rewrite extension. Best use for Static HTML Generation
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
@shibbirweb
shibbirweb / a.blade.php
Last active December 20, 2021 06:18
Laravel Regular Components
{{-- Anchor tag --}}
{{--
Usage Example::
<x-a class="nav-link" href="{{ route('dashboard') }}" exact>Dashboard</x-a>
<x-a class="nav-link" :href="route('dashboard')">Dashboard</x-a>
@shibbirweb
shibbirweb / MyImage.png
Last active November 9, 2021 09:23
My Image
data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAAQABAAD/7QCcUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAIAcAigAYkZCTUQwMTAwMGFhNTAxMDAwMDkxNjQwMDAwYjYwZjAxMDA1MTFmMDEwMDg2MzEwMTAwMjliMTAxMDBmNzliMDIwMDYxYWYwMjAwYWVjMzAyMDBhMmRhMDIwMGFlNGQwNDAwHAJnABQ1LUVvZ2pRbDJCYU55Vk9YUUlIav/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/CABEIBRAFEAMAIgABEQECEQH/xAAcAAABBQEBAQAAAAAAAAAAAAADAAECBAUGBwj/xAAaAQADAQEBAQAAAAAAAAAAAAAAAQIDBAUG/8QAGgEAAwEBAQEAAAAAAAAAAAAAAAECAwQFBv/aAAwDAAABEQIRAAAB20lpik6BmkwMkzGSYbNJgipRBmlEIxnAGhKIRjKIQGSACgQTGg8pc5tKWfiO28lFzhg9FR6LcK9z5PbrXAxZukrnd8H3BXoWjnaac5NIbupjUkmSdOJ5xlJMwypkjN5Yea6DGk4LYyLUb+j5uthRzegSjIFKMgfmemw0vNtWlcOUxadqYvAgRONLXy7tbeFslbD1rfLgXJ1czbSVa7W2Ixr3szYzFQzWvpZmi4iz5OWgMeR+uxZWhV0dLcpamN5yScVpmA9Y6Veo6NYSIa5UuJysCnlpcG9HDmz9GsTLvJCdbHuvdXxnV3xGjOPt8sYyfpUU8URZ3CUmfGlBLjaAbIzdTPeBLCsY9oUxrc0D51iZtFydVg68KgGLSttGlAQhSGQZkCxOyeMl1Jopw0WVSOKghJLq5UkwSUUyU
@shibbirweb
shibbirweb / Controller.php
Last active August 8, 2021 04:24
Build Large Query In Laravel
<?php
$recent_examinations = $examinationService->recentExaminationsResultByExamTypeId($user->exam_type_id, $user->id);
@shibbirweb
shibbirweb / DownloadProgressLiveData.kt
Created May 9, 2021 14:06
Android - Downlaod Progress - Download manager download progress tracker
import android.app.Application
import android.app.DownloadManager
import android.content.Context
import androidx.lifecycle.LiveData
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
data class DownloadItem(val bytesDownloadedSoFar: Long = -1, val totalSizeBytes: Long = -1, val status: Int)
@shibbirweb
shibbirweb / AnyFragment.kt
Created April 30, 2021 16:32
Android - Kotlin - Handle back pressed on Fragment
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// on back pressed call back
val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
// goto dashboard
val action =
SectionChooseRegistrationFragmentDirections.actionSectionChooseRegistrationFragmentToDashboardActivity()
findNavController().navigate(action)