Skip to content

Instantly share code, notes, and snippets.

View waliahimanshu's full-sized avatar

Himanshu Walia waliahimanshu

View GitHub Profile
@waliahimanshu
waliahimanshu / .kt
Created March 31, 2025 14:09
KTOR upload file to AWS S3
import io.ktor.client.plugins.onUpload
import io.ktor.client.request.forms.MultiPartFormDataContent
import io.ktor.client.request.forms.formData
import io.ktor.client.request.post
import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.bodyAsText
import io.ktor.http.Headers
import io.ktor.http.HttpHeaders
import kotlinx.coroutines.runBlocking
@waliahimanshu
waliahimanshu / SimplePrimaryTabsInsteadOfBottomBar.kt
Last active April 2, 2025 21:40
Primary Tabs (Instead of bottom navigation item)
@Composable
@OptIn(ExperimentalMaterial3Api::class)
fun HomeTabs(navController: NavHostController, modifier: Modifier = Modifier) {
val tabs = homeTabItems
var selectedTab: Int by rememberSaveable { mutableIntStateOf(0) }
Scaffold(
modifier = Modifier.fillMaxSize(),
floatingActionButton = {
// if (selectedTab == HomeTabItems.AccountFeed.ordinal) {
@waliahimanshu
waliahimanshu / .zshrc
Created March 22, 2024 11:14
set JAVA_HOME and ANDROID_HOME in mac using zshrc
Tip if you use bash just replace . zshrc with .bash_profile ?
Open Terminal and type in..
open ~/.zshrc
Add the below paths
The path should be where your android installation is located
// check in your android studio the JAVA path used
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home
@waliahimanshu
waliahimanshu / build.gradle.app.kts
Last active April 2, 2025 21:47
Android project dependencies
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.dagger.hilt.android)
}
dependencies {
@waliahimanshu
waliahimanshu / find_class_usage.sh
Last active February 28, 2023 14:12
Find class usages in other modules by searching the `import regex` - allows to exclude folders
#!/bin/bash
root_dir=""
find "$root_dir" -type d \( -path "*/network" -o -path "*/build" -o -path "*/backup" \) -prune -o -type f -name "*.kt" -exec grep -Hn "import com\.x\.android\.network\." {} \;
@waliahimanshu
waliahimanshu / crashlytics.md
Last active September 2, 2022 13:40
Missing upload crashlytics mapping file

v261.0

Screen Shot 2022-09-02 at 14 31 12

v262.0

Screen Shot 2022-09-02 at 14 31 45

v263.0

@waliahimanshu
waliahimanshu / build.gradle
Created August 1, 2021 19:41
MAD dependencies
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation "androidx.fragment:fragment-ktx:1.3.6"
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
find . -name "build" -type d -exec rm -rf "{}" \;
rm -rf ~/.gradle/caches/
fun requestWidgetPinning(context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val appWidgetManager = AppWidgetManager.getInstance(context)
val componentName = ComponentName(context, YourAppWidget::class.java)
if (appWidgetManager.isRequestPinAppWidgetSupported) {
val pinnedWidgetCallbackIntent = Intent(context, YourAppWidget::class.java)
val successCallback = PendingIntent.getBroadcast(
context, 0,
pinnedWidgetCallbackIntent, 0