Skip to content

Instantly share code, notes, and snippets.

View hardikm9850's full-sized avatar
🏠
Working from home

Hardik hardikm9850

🏠
Working from home
View GitHub Profile
@hardikm9850
hardikm9850 / .env
Created September 29, 2025 06:23 — forked from jitinsharma/.env
perfetto natural language query
GEMINI_API_KEY=
LOCAL_LLM_BASE_URL=
// Creating cache folder where our response will be cached
val cacheFolder = Cache(File(applicationContext.cacheDir, "http-cache"), 10L * 1024L * 1024L) // 10 MB Cache
// Creating the okhttp builder passing the CacheInterceptor that adds "Cache-Control" in server's header
val okHttpClient = OkHttpClient().newBuilder()
.cache(cacheFolder)
.addNetworkInterceptor(CacheInterceptor()) // Only intercepts network responses (i.e. responses fetched from the server, not the cache)
.build()
// The following code is referenced from the sources below. I encourage you to review + debug it yourself to get a better understanding.
// https://github.com/square/okhttp/issues/350#issuecomment-123105641
// https://github.com/square/okhttp/blob/f4ff4f4a8dce5f44596115f9564280e41d845f98/samples/guide/src/main/java/okhttp3/recipes/RequestBodyCompression.java#L73
private class GzipRequestInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val originalRequest = chain.request()
val body = originalRequest.body
if (body == null || originalRequest.header("Content-Encoding") != null
@hardikm9850
hardikm9850 / update-android-project.sh
Created November 18, 2024 12:59 — forked from bizz84/update-android-project.sh
Script to update Gradle, Java and other Android project settings in a Flutter project
#!/bin/bash
# Update Gradle, Java and other Android project settings in a Flutter project
# See: https://gradle.org/releases/
DESIRED_GRADLE_VERSION="8.9"
# Build errors often show the required Java version
DESIRED_JAVA_VERSION="17"
# See: https://developer.android.com/ndk/downloads
DESIRED_NDK_VERSION="27.0.12077973"
# The minimum Android SDK version
@hardikm9850
hardikm9850 / ThreadLikePathAnimation.kt
Created June 2, 2024 14:50 — forked from sagar-viradiya/ThreadLikePathAnimation.kt
An attampt to implement Threads app like path animation on pull to refresh in Jetpack Compose
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun PullToRefreshAnimation() {
val path = remember {
GitHubLogoPath.path.toPath()
}
val lines = remember {
path.asAndroidPath().flatten(error = 0.5f).toList()
}
@hardikm9850
hardikm9850 / kotlin-sealedclass-serialization.kt
Created November 22, 2023 17:03 — forked from krishnabhargav/kotlin-sealedclass-serialization.kt
Using GSON to support serialization and deserialization of Kotlin Sealed Classes.
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.gson.TypeAdapter
import com.google.gson.TypeAdapterFactory
import com.google.gson.reflect.TypeToken
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonWriter
import kotlin.jvm.internal.Reflection
import kotlin.reflect.KClass
@hardikm9850
hardikm9850 / Flutter Clean.md
Created April 19, 2023 08:28 — forked from minhcasi/Flutter Clean.md
These are common issues on Flutter and solutions to fix

Quick Clean Cache

  1. Open android studio Tools->Flutter->Clean
  2. Go to File -> Invalidate Caches / Restart
  3. Or open terminal run "flutter clean"
  4. Remove pubspec.lock
  5. Double check the Flutter SDK Path config correcty - https://tppr.me/qn6dP

Or open the terminal and try this script:

flutter clean
import 'dart:math';
void main() async {
var duration = _runCPUBoundTask();
print('The duration for CPU bound task is $duration');
}
Future<Duration> _runCPUBoundTask() async {
var startTime = DateTime.now();
print('Starting ...');