Android: Don't use stale views

In MusicSync, one of the views became complex and too slow to be inflated on the UI thread. So, I decided to do some Pooling around it to inflate it on the background thread and use it on the UI thread. This made the UI snappier, reducing multiple-second load times when opening some folders. However, soon I ended up with an edge case where re-opening the activity (and not the app) led to a semi-functional app. This edge case is hard as it gets triggered only in particular scenarios where the user destroys the activity via swipe up. At the same time, the app keeps running due to the attached foreground service that鈥檚 playing the media. And on activity re-creation, I got stale views! ...

Repairing database on the fly for millions of users

This is a story of a messaging app used by billions of users. The app followed an extremely strong model of privacy. The app never persisted the user鈥檚 data on the servers. All the communication is end-to-end encrypted. A lot of users of this app, especially, on Android would regularly uninstall and reinstall the app. Now, to prevent these users from losing messages, the messages were backed up to the user鈥檚 SD card. In the Android security model, an SD card is a public storage space, accessible to all apps. So, to keep messages private, the backups were encrypted. ...

It is hard to recommend Google Cloud

Google Domains A year back, I had to migrate my domain after Google decided to shut down Google Domains. I had to, not only, painfully setup multiple side-projects sub-domain mappings again on a new domain registrar but also re-verify my domain and re-create those mappings on Google Cloud Run. Google Container Registry Google Container Registry is shutting down in 2025. It has been replaced with a new project called Artifact Registry. So, why is Container Registry being shut down? Probably because it 10X cheaper than Artifact Registry. ...

When to commit Generated code to version control

Generated code, ideally, should not be committed to version control. Committing generated code can sometimes speed up testing and code generation but it is a design smell. It is better to cache generated code via CI caching. Committing generated code to version control is the worst as it is hard to even detect the difference. However, there are a few specific circumstances where committing generated code/config/data to version control is worth it. ...

Use Makefile for Android

I use Makefile for Android just like I use Makefile for my non-Android side-projects.

Android Navigation: Up vs Back

Android has two distinct navigation guidelines as opposed to iOS. Getting them right is nuanced.

Always support compressed response in an API service

If you run any web service always enable support for serving compressed responses. It will save egress bandwidth costs for you. And, more importantly, for your users. Over time, the servers as well as client devices have become more powerful, so, compressing/decompressing data on the fly is cheap.

hugging-face-down

Hermetic docker images with Hugging Face machine learning models

Hugging Face is GitHub for machine learning models. Their on-the-fly model download scheme, however, is difficult from a DevOps perspective. Here鈥檚 how to disable it.

Using Python & Poetry inside Docker

Poetry is a great build system. And in 2023, I believe, no one should use the pip for a private Python codebase. Getting it right inside Docker is a different issue, however. Consider a simple Flask-based web server as an example Bash 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 # Install poetry $ pip3 install poetry==1.7.1 $ poetry --version Poetry (version 1.7.1) # Create a sample package $ poetry init --python=~3.10 --name=src --description='Flask Hello world' --dependency=Flask@3.0.0 --author='Ashish' --license='Apache 2.0' --no-interaction $ poetry install $ touch README.md $ mkdir src # Create a file src/server.py in your favorite editor $ cat src/server.py from flask import Flask app = Flask(__name__) @app.route("/") def hello_world(): return "<p>Hello, World!</p>" if __name__ == "__main__": app.run() Let鈥檚 finish the build process Now, let鈥檚 add a simple Dockerfile titled Dockerfile1 ...

How to add a new formula to homebrew package manager

I recently added adb-enhanced to the Homebrew package manager. Here are some of my learnings and future tips to smoothen up the process.