Skip to content

Instantly share code, notes, and snippets.

View waliahimanshu's full-sized avatar

Himanshu Walia waliahimanshu

View GitHub Profile
@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.kts
Created November 1, 2023 10:07
Android project dependencies
Depdencies needed when spinning a new app from scrarch
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation "com.squareup.retrofit2:converter-moshi:2.5.0"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2"
// Moshi
implementation "com.squareup.moshi:moshi:1.8.0"
kapt "com.squareup.moshi:moshi-kotlin-codegen:1.8.0"
@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
private val appWidgetManager = AppWidgetManager.getInstance(context)
private val provider = ComponentName(context, YourAppWidget::class.java)
private val allWidgetIds = appWidgetManager.getAppWidgetIds(provider)
fun updateWigetView(type: ViewStateType) {
allWidgetIds.forEach { widgetId ->
appWidgetManager.updateAppWidget(widgetId, remoteViews)
}
}
class WidgetUpdateNotifierImpl : WidgetUpdateNotifier {
override fun refreshWidget(context: Context) {
val intent = Intent(context, YourWidgetClassName::class.java)
intent.action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
val componentName = ComponentName(context, YourWidgetClassName::class.java)
val ids: IntArray = AppWidgetManager.getInstance(context).getAppWidgetIds(componentName)
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
context.sendBroadcast(intent)
}
To copy all files from gcloud to your local machine
gsutil -m cp -r gs://bucket/xxxxx.com /Users/xxx/Documents/MyWebSite
Once you have uploaded the files from local to gsutil, deploy
gsutil rsync -r gs://xxx_bucket_name .
gcloud app deploy