Skip to content

Instantly share code, notes, and snippets.

View SurajBahadur's full-sized avatar
🎯
Focusing

Suraj Bahadur SurajBahadur

🎯
Focusing
View GitHub Profile
@SurajBahadur
SurajBahadur / FaceDetection.kt
Created July 15, 2024 07:10
Detect the people face from the image and crop only the face
var detector: FaceDetector? = null
val highAccuracyOpts =
FaceDetectorOptions.Builder()
.setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE)
.setLandmarkMode(FaceDetectorOptions.LANDMARK_MODE_NONE)
.setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_NONE)
.build()
detector = FaceDetection.getClient(highAccuracyOpts)
fun performFaceDetection(inputImage: Bitmap) {
val mutableBmp = inputImage.copy(Bitmap.Config.ARGB_8888, true)
@SurajBahadur
SurajBahadur / nav.xml
Created February 28, 2024 17:16
dtm nav graph
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/dtmNavigation"
app:startDestination="@id/chooseOption">
<fragment
android:id="@+id/splash"
android:name="com.dtm.views.splash.SplashFragment"
android:label="Splash">
@SurajBahadur
SurajBahadur / DashboardActivity.kt
Last active February 16, 2024 10:38
Custom bottom navigation view in kotlin
import android.annotation.SuppressLint
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.Menu
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.activity.viewModels
@SurajBahadur
SurajBahadur / RootUtil.kt
Created June 13, 2023 05:01
Code to check whether device is rooted or not in android
import android.animation.ObjectAnimator
import android.animation.PropertyValuesHolder
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.util.Log
import android.view.View
import android.view.animation.AccelerateDecelerateInterpolator
import com.prepladder.medical.prepladder.model.DataItem
@SurajBahadur
SurajBahadur / LeaderRankView.kt
Created April 10, 2023 06:55
Custom View Class In Kotlin with Style Attributes.
class LeaderRankView @JvmOverloads constructor(
context: Context,
val attrs: AttributeSet? = null
) : ConstraintLayout(context, attrs) {
var binding: ViewLeaderRankBinding
private var leaderIcon: Drawable? = null
set(value) {
@SurajBahadur
SurajBahadur / OnTrimMemoryActivity.java
Created January 16, 2023 04:55
During any stage of your app's lifecycle, the onTrimMemory() callback also tells you when the overall device memory is getting low. You should respond by further releasing resources based on the following memory levels delivered by onTrimMemory(), This gist allows you to log the different states.
@Override
public void onTrimMemory(int level) {
Map<Integer, String> constantMap = getConstantMap();
switch (level) {
case TRIM_MEMORY_RUNNING_MODERATE:
Log.e(TAG, getConstantName(constantMap, TRIM_MEMORY_RUNNING_MODERATE));
break;
case TRIM_MEMORY_RUNNING_LOW:
Log.e(TAG, getConstantName(constantMap, TRIM_MEMORY_RUNNING_LOW));
@SurajBahadur
SurajBahadur / gist:85448fafbdf5d098218aa10d8dbbdca5
Created January 8, 2023 07:46
in mac always getting zsh: command not found
Works on macOS :
You can manually edit .zshrc file and revert the changes you made to PATH.
Open TextEdit app.
Go to folder: cmd + shift + g
type: ~/
@SurajBahadur
SurajBahadur / MainActivity.kt
Created December 5, 2022 06:42
Check whether PIP is enable Or disable for the app in android
startActivity(Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Uri.parse("package:${packageName}")))
@SurajBahadur
SurajBahadur / YoutubeExtactor.kt
Created November 30, 2022 06:20
Fetch youtube URL for live stream
fun convertLinkToHls(youtubeLiveLink: String, activity: Activity) {
val hlsLink = arrayOf("")
val runnableCode = Runnable {
try {
val url = URL(youtubeLiveLink)
val con: HttpURLConnection = url.openConnection() as HttpURLConnection
con.requestMethod = "GET"
val `in` = BufferedReader(
InputStreamReader(con.inputStream)
@SurajBahadur
SurajBahadur / youtube_format_code_itag_list.md
Created November 15, 2022 11:11
YouTube Format Code iTag List

YouTube video stream format codes

Comprehensive list of YouTube format code itags

itag Code Container Content Resolution Bitrate Range VR / 3D
5 flv audio/video 240p - - -
6 flv audio/video 270p - - -
17 3gp audio/video 144p - - -
18 mp4 audio/video 360p - - -
22 mp4 audio/video 720p - - -