I'm not a mobile app developer, but for my day-to-day job, I'm responsible for creating APIs that's consumed by mobile client. This means I often have both iOS and Android simulator running at the same time.

Normally, you would have to open both XCode and Android Studio respectively as that is how things are supposed to work: start each IDE, build the app in the IDE, and then run the app in the simulator through the IDE.

I don't like to do things this way, it is inefficient and will (most likely) consume lots of resources. Therefore, I developed my own scripts to do things efficiently in the command line. In this article, I will share some of the scripts I use when working with Android code, I believe these scripts are huge quality of life improvement for developers like me who need to run mobile apps in a simulator as part of their day-to-day job, but not necessarily modify or commit to the mobile code. Some of the things discussed in this article have already been mentioned briefly last year.

Read more »

Motivation: Slow and confusing web interface

Azure DevOps, probably one of the worst tools you can get for a your software team, I hated it with passion. The reason that company chooses it over any other software is probably because they can get a decent enough discount when bundled with the M$'s shitty Outlook, Teams, and office suite.
If I could, I would give Azure DevOps's web interface and overall experience a 0 out of 10: it is slow, difficult to navigate, and way behind what you would get from GitHub or GitLab.
Enough for the ranting, in short, I hate Azure DevOps' web interface, therefore, I prefer to use the CLI to interact with it.

Read more »

Motivation: Need to split text

I'm not a professional GO developer, but I do like GO, I have taught myself some Go by contributing to open source projects, and since then GO has become my language of choice for personal projects.

Recently, I have encountered an interesting problem when working on one of my personal projects. For this project, I need to split a long text by byte count. The eventual result is an array of strings in which each of element is less or equal to the byte size that's passed in.

Naive/Wrong approach: Split by number of characters

Read more »

This is the second article about NeoVim tips, if you are interested in the first one, please check here

Motivation: the need for a scratch pad within NeoVim

Quite often in my daily work, I need to check some response that are in JSON or XML format. I could open VSCode and paste in and format whatever I got to readable format, or I could also find an online formatter to format these things. But, as a VIM user, I want to do it in a VIM way. The answer comes down to scratch buffer.

Read more »

Background

I'm not an Android developer, but I do work with Android applications which means I have to work with Android Studio and Android emulator quite often. Recently, I encountered a quite interesting problem which prompt me to write this post and hopefully can help someone in the future.

Why?

Because I need to identify where the user of the mobile app is located and provide different content to the user based on their location.

How?

There are definitely several ways to do so, one obvious way is to use the IP address. However, with the growing use of VPN, this is definitely not the most reliable option.

The other option that comes up is to identify through the mobile carrier. If you are not familiar with telco or mobile networks, I will provide a brief background next.

MCCs and MNCs
Each mobile network operator (or carrier) can be uniquely identified by using a combination of MCC (mobile country code) and MNC(mobile network code). More information on this on Wikipedia. What this means is that, you can usually reliably identify where the user is from by looking at their mobile carrier's MCC code.

Usually, you would have to translate the MCC code to a country code on your own but it turns out in Android you don't have to do the translation yourself. Instead, you can directly use this API which will give you an ISO country code in 2 letters. You can then do whatever you want with this country code, pass this through a header to a server or the likes.

Once you have implemented this using getNetworkCountryIso, you will realize it is almost impossible to test or verify if this functionality will actually work as expected. One of the easiest way is to provide a debug menu within the app (in debug mode) and then mock different countries, this is the obviously the most efficient and cost effective way.

If in reality, a debug menu to mock countries is not something you can achieve, then you will have to use the emulator. This is what the rest of this post will be about, and hopefully this post can help you with your solution.

Read more »

It's been almost two years since I wrote the post on how to automate Zoom with Alfred and Apple Scripts. Sadly enough, the situation has not improved at all, you still have to click on the link for the Zoom meeting and then wait for it to launch your Zoom app.

The need for a simple way to join Zoom meetings (on Linux)

The goal is to open Zoom directly and join the meeting without going through the browser.

I have started using my Linux laptop to join a Zoom meeting regularly recently, and I simply can't tolerate having to click on the same link over and over again each time I want to join the meeting -- I just wish there is a simpler way to open Zoom with one click without going through the browser.

Read more »

As a long time Linux user, I have to admit sometimes it is not easy to achieve some of the things that can be easily done in other OS (like macOS or Windows), but that one of the things I enjoy about Linux as well -- you need to force yourself to learn something, and once you've achieved it, you will learn from it and then realize how powerful Linux is. Anyway, for me, this had been one of the problems that had me troubled for a while -- using dual monitors, and have Linux automatically detect and extend desktops automatically.

Problem

I use bspwm as my tiling window manager, and polybar as the 'bar'. The problem I'm trying to solve here is to have the laptop automatically detect monitor hot-plug and then extend the bars with different layout to the new monitor. And when I unplugged the external monitor, the system revert back to single monitor layout.

Read more »

As a developer, one of the most important things is to find the right tool to write code with. To me, that means this tool needs to be lightweight, portable, and most importantly reliable.

Why VSCode is not for me

VSCode, aka Visual Studio Code, is a code editor developed by Microsoft. It is based on top of the Atom editor that was previously developed by GitHub. As a full stack developer whose main language is JavaScript/TypeScript, I was told to use VSCode when I joined the company. However, as a long-time vim user, I still use the vim mappings when I am using VSCode. This is all done through plugin/extensions. This seems to be okay at first, but over time, I really find VSCode annoying to use and I simply can't tolerate it.

The first thing is that contrary to most popular belief, VSCode is NOT an open source product. Yes, part of the source of VSCode is open-sourced, but the VSCode you downloaded from Microsoft website is not. They have put some proprietary stuff into the end product and I'm not a big fan of that. There are ways to get around this, namely, there are several truly open source edition of VSCode, the one I used to use is called VSCodium, but then you will lose access to the extensions market provided by Microsoft.

Another thing that annoys me is that VSCode or any product that based on VSCode is just too slow and resource intensive -- they are just an electron app running on another Chromium based browser. Having one Chrome is enough for me, so thank you Microsoft (I tried to avoid electron based apps as much as possible, for example, I use web version of Teams, rather than the app one)

Read more »

Warning

⚠ Hiding phone numbers may not be legal in some places, and even if you hide your number, you mobile operator WILL (of course) see your number. Use the method described in this article at your own risk!

Read more »

Yesterday morning, when I woke up, I faced a serious issue on my laptop which has Manjaro Linux installed -- the X server can not be started.

Locating the problem

It took me some time to get my head around and locate the root cause. The first thing I tried is obviously force reboot several times, it turned out this did not help at all! Reboot will not solve everything.™
The next thing I tried was the fallback initramfs mode. I don't really understand what it does, but tried it anyway. And unfortunately, that does not work either.
At this point,the only option left for me to try is recovery mode. And it turned out to be working correctly. As root user in the recovery mode, I issued the following command systemctl set-default multi-user.target, this makes the tty the default target rather than the graphical interface. Another reboot, and I got into the terminal.
Once in terminal, I immediately tried startx, this failed due to some wired permission issue, and with sudo startx, the command failed as well. Looking at the Xorg log, I noticed that the start process stops at: (II) Initializing extension VNC.

Read more »
0%