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.

March 9, 2024 路 2 min

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.

February 29, 2024 路 1 min

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.

December 16, 2023 路 2 min

How to setup Go packages under monorepo

Let鈥檚 say you want to have two Go packages pkg1 and pkg2 in a monorepo setup. Here鈥檚 what a good project structure would look like.

November 4, 2023 路 1 min

Android: Always show toasts on the background thread

I used to call Toast#show() on the UI thread. Then one day, I received notifications related to an ANR (Application Not Responding) error in one of my Android apps. at android.os.BinderProxy.transactNative(BinderProxy.java) at android.os.BinderProxy.transact(BinderProxy.java:605) at android.view.accessibility.IAccessibilityManager$Stub$Proxy.addClient(IAccessibilityManager.java:1207) at android.view.accessibility.AccessibilityManager.tryConnectToServiceLocked(AccessibilityManager.java:1804) at android.view.accessibility.AccessibilityManager.(AccessibilityManager.java:606) at android.widget.ToastPresenter.(ToastPresenter.java:138) at android.widget.Toast$TN.(Toast.java:1151) at android.widget.Toast.(Toast.java:259) at android.widget.Toast.makeText(Toast.java:891) at android.widget.Toast.makeText(Toast.java:879) at net.ashishb.androidmusicplayer.util.UiHelper.showToast(UiHelper.java:111) Programmers on StackOverflow are confused about whether it is OK to call Toasts on the background threads. Just like me, they think that Toast must be displayed from the UI thread....

October 21, 2023 路 1 min

How to deploy Docker images on Microsoft Azure

There are several ways to deploy Docker images on Microsoft Azure. My favorite one is Azure App Service/Web Application for Containers. This is the closest to Google Cloud Run.

September 2, 2023 路 1 min

End-to-end testing of mobile apps

Google released a new version of the Google Auth library. It had a bug that broke Google Login on Android for API 26 and earlier. This impacted my small but popular Music Player app in Google Play. It reveals the kind of problem, I have alluded to in end-to-end testing. The only way to avoid such problems is by end-to-end testing. However, I find all Android testing frameworks to be terrible....

August 1, 2023 路 2 min

API backend should use dataloaders

Data Loaders allow transparent batching of requests to a data provider (e.g. database). More often than not, this leads to reduced latency and better performance without forcing an explicit batching of requests for the API users, for example, your frontend developers. Many programmers relate data loaders to Graph QL for N+1 query patterns. I believe data loaders are a great idea any time you are building an API backend. Let me illustrate the concept with a simple example. And while I am using Go as an example, data loader implementations are available in many languages.

June 15, 2023 路 5 min

Nillion

Recently, I came across Nillion鈥檚 whitepaper. Nillion at its core is trying to be a new decentralized encrypted data-processing layer. Here鈥檚 how it works.

May 28, 2023 路 2 min

Generics in Go

Generics in Go were added about a year back in Go 1.18. In my experience they are great and they fix one of the biggest roadblocks in terms of writing reusable code in Go. I鈥檒l illustrate that with an example. First, do ensure that you have at least Go 1.18 $ go version go version go1.19.1 darwin/amd64 Let鈥檚 consider a simple case of implementing a Map function in Go that maps an array (well, a slice) to another array (again, actually, a slice)....

April 2, 2023 路 1 min