IDD calls failing on Xiaomi Redmi Note 4


I use International Direct Dialing (IDD) to call numbers in India. My cellphone operator Starhub, provides the international call prefix 018 that can be prepended to Indian phone numbers to make the call. These IDD calls are far cheaper than ISD calls. This was working fine on my Xiaomi Redmi Note 4 phone until a recent software update. After that, it started prepending the Singapore country code +65 to the number that already has IDD prepended to it. Thus IDD 018 calls stopped working.


Open the Settings section of the dialer: Phone (📞) → hamburger menu (☰) → Settings (⚙). Go to Location and disable the Add country code option. I think this option was added recently in a software update and it was enabled by default. After turning this off, I was able to make IDD 018 calls without any problems like before.



XTerm is a classic terminal emulator for the X window system. It is so old that it is in fact a bit older than the X window system itself! Today it ships as one of the quintessential programs of the X window system. Here are some factoids I discovered about XTerm that may interest you to use it:

  • It was explicitly written to emulate the old DEC VT102 and Tektronix 4014 terminals.

  • It supports 256 colors. You may need to configure it to set the TERM environment variable correctly as xterm-256color. Terminal apps read this variable to decide how to show their colors, so this might be essential. See my config file below for how to do this.

  • Along with the classic xterm, there is also xterm with Unicode support that you can invoke as uxterm. The latter is what you almost always need.

  • Being one of those early X programs, it does not have a toolbar or scrollbar. Instead, you get three different menus if you hold down the Ctrl key and click any one of your 3 mouse buttons.

  • The 3 menus you get are: main options (left mouse button), VT options (center button) and font options (right button). All the menu options can also be set in its config file.

  • By default, xterm starts with white background and black foreground. Invoke it with the -rv (reverse video) option to get black background and white foreground. This can also be set in its config file (see below).

  • One keyboard shortcut I like in xterm is Alt + Enter which toggles the fullscreen mode.

  • Like any classic X application, XTerm copies and pastes from the PRIMARY clipboard. If you need the normal window manager clipboard behavior, choose Copy to clipboard in the VT menu.

  • A cool trick to select a large body of text in XTerm is to left-click at the beginning of the text and right-click at the end. The region in between the two clicks is copied to PRIMARY.

  • The main reason I like using xterm, other than its bare bones simplicity, is its keypress latency. Experiments seem to show that it has the lowest keypress latency among all terminal emulators on Linux. This may not be surprising considering the dinosaur age in which it was developed when every bit of speed mattered.

  • XTerm is a great program. Simple and fast. The only disadvantage for me is that its stdout speed is among the slowest in terminal apps. Only Terminator is slower than XTerm in my experience. This is a real deal killer if you frequently run commands that can throw thousands of lines to the terminal.

  • Being a classic X program, XTerm reads its config from a Xresources file. Here are some settings I use in my file to change foreground/background colors, set font size, enable font size increment/decrement and such settings:

Note that the settings are applied to the app only at the start of the X server. If you want to apply them right now, use the xrdb app as described here.



The .Xresources file in your home directory is where you store the configuration options for your X client applications. These are the classic X window apps, whose names usually begin with the letter x. Like XTerm for example.

  • This is a single file whose settings are applied to all the X apps when the X window system begins.

  • If you add or change some settings later and want them to be applied to the X server, that can be done using the xrdb (X server resources database utility) program.

  • To replace all current settings with the settings from the file:

$ xrdb ~/.Xresources
  • To merge settings in file into the currently active settings:
$ xrdb -merge ~/.Xresources
  • Each configuration option has this format: name.Class.resource. Usually, the class is the name of the program and class and resource provide 2 levels of suboptions.

  • Wildcard character can be used in the configuration option name. For example, to set something for all applications and so on.

  • Each configuration is specified in this format: name.Class.resource: value

  • Comments can be used in the file by beginning the line with a !

  • You can look up all the configuration options understood by your app in its man page. For classic apps like xterm, this can run into hundreds of options!

  • To view all the settings applied on a X application use the appres program. Its name looks weird, I remember it as the tool to view application resources. To view the settings of XTerm for example: appres XTerm. Note how the application (or class as X calls it) has to be specified correctly with the correct case.

dBm wireless signal strength

dBm signal strength of my wifi connection

You usually check the signal strength of your wireless connection on your phone or laptop by looking at how many bars or waves are highlighted in the GUI. This is a good approximation to know if your signal is weak or strong. However, if you need to measure the strength of your connection, for example at different locations in your home, then you need to know the actual metric.

  • dBm (decibel-milliwatts) is the commonly used metric to measure wifi signal strength or power.

  • If you check the technical specifications of your wireless router, you should find that it transmits at less than -20dBm. Note that this a negative value. So, a value that looks bigger, like -50dBm means a weaker signal.

  • If you put your phone or laptop right beside your wireless router, you should find the strength to be between -20dBm and -30dBm. This gives you an idea of the max strength you can realistically achieve with your home setup.

  • According to this page, you will need at least -70dBm for browsing and -80dBm is the farthest signal strength thats practically usable. At -90dBm the signal is basically indistinguishable from noise.

  • To view the dBm signal strength of your wifi connection on your Android device, I highly recommend the open-source WiFiAnalyzer app. You can see the dBm signal strength of your and all other wifi connections from your phone with this app.

  • To view the dBm signal strength of your wifi connection on your Linux computer, just type iwconfig and note the Signal level field in the output:

$ iwconfig
wlp4s0    IEEE 802.11  ESSID:"my_wifi_network"  
          Mode:Managed  Frequency:2.427 GHz  Access Point: xx:xx:xx:xx:xx:xx   
          Bit Rate=65 Mb/s   Tx-Power=22 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=42/70  Signal level=-68 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:96   Missed beacon:0

You can move around your laptop to different locations in your home and note the dBm values there. This can be useful if you want to decide on the optimal placement of your wifi router or if you are planning to get a wifi extender for your home.

How to set LMDB permissions in Caffe

Caffe can create, read and write images from an LMDB database. This is much faster than using the files from filesystem during training. However, I noticed that by default Caffe would not set write permissions for my group for the lmdb directory.

A quick investigation into src/caffe/util/db_lmdb.cpp showed that this was because new lmdb directory was being created with 0744 permissions. I changed this to 0774 in the code and recompiled Caffe.

Now comes the mystery: Caffe still created lmdb directories where my group did not have write permission!

Further investigation showed that the default umask in Linux is 0022. This umask does not allow the group write permissions to be set.

Ok, so then I set the umask at the shell to 0002 and tried to create the lmdb again. Found that lmdb directories still did not have group write permissions!

I was creating the lmdb databases from a script that ran the convert_imageset binary. Now the binary was run by using the exec command of the Bash shell. This replaces the currently running process with the convert_imageset binary. However, unlike a fork, the new process is not passed the umask of the parent process by the OS! This was the reason for the problem.

Once I knew this, the solution was easy. I modified the tools/convert_imageset.cpp code and added this code:

#include <sys/types.h>
#include <sys/stat.h>

// In the main function ...
// ....

This solved the problem perfectly! 🙂

How to set umask for Docker container


Once you run a Docker container using docker run and get a shell inside it, you can set the file creation mode mask there with the umask command of the shell. This is usually 0022 and you can set it to whatever you want. All consecutive operations at the shell and child processes forked from the shell will have with umask.

What if you don’t want to manually type this umask command, but want it set automatically in the container?


There is no way to do this directly in the Dockerfile. You can have a RUN umask 0002 in the Dockerfile, but that does not have any effect for when you run the container.

One solution is to create a shell script that sets this umask:

$ cat
umask 0002

To be able to run this script when the container is run, we first need to make this executable:

$ chmod +x

Next we add commands to the Dockerfile to copy this into the image and make the script as the entry point:


Build the container and run it and see your umask already enabled at the shell! 🙂

How to set user of Docker container


When you run a Docker container using docker run, everything inside the container is executed by the root user and root group. Its UID is 0 and GID is 0. This can sometimes be a problem.

For example, I had mounted a directory from the host filesystem into the Docker container using the --volume option. When root creates a new file or directory in this mounted directory, it appears as owned by the user nobody and group nogroup. This was a problem since I wanted these new files and directories to be created with my username or at least my group.


You can set what username or group you want to run as inside a container by using the --user option.

  • To run as user joe: --user joe. It is highly unlikely that the username joe exists in the Docker container. So this will likely fail unless you have added Dockerfile commands to make this so.

  • Instead, set the UID: --user 1005. Docker will warn that the UID does not have a corresponding username inside the container, but it will work. Files created on the mounted directory will have the UID 1005. There is a problem: many programs inside the container may not run if root is not running it. For example, you may find that you cannot create files or directories inside the container without being root.

  • Another option is to set the group or GID: --user :1005. Notice the colon. Files created on mounted volumes will have the group GID you set. This solution worked to solve my problem.

  • You can set both UID and GID too: --user 1005:9999

Tried with: Ubuntu 16.04

How to set encoder format for Python JSON

Python’s JSON module makes it very easy to dump data into a JSON file. However, I have found that the float values are encoded with a lot of decimal places or in scientific notation. There is no elegant method to set the formatting in the float encoder of the JSON module. The best solution seems to be to monkey patch its formatting option:

# Make json.dump() encode floats with 5 places of precision
import json
json.encoder.FLOAT_REPR = lambda x: format(x, '.5f')



Anki is a system to create, maintain and review flash cards. It can be used to create and store flash cards in separate decks. It is available as an offline program and also online at AnkiWeb. Probably my favorite feature is that I can create and store my decks in its online store and also sync them up to my offline Anki client.

  • I highly recommend creating a login at AnkiWeb and creating your decks and cards there.

  • To review on your computer, install the Anki tool:

$ sudo apt install anki
  • Open up Anki and click the Sync (⟳) icon. You will be asked for your AnkiWeb login and after that your decks will be synced.

  • In case you are curious, your decks are stored in a single SQLite database file named collection.anki2 in the Documents/Anki/User 1/ directory in your home.

Tried with: Anki 2.0.32 and Ubuntu 16.04

DB Browser for SQLite

SQLite is a popular database that is used by applications to store their information in a single file. Sometimes, you might need to quickly check on some information stored in such SQLite database files. That is where the DB Browser for SQLite is really useful. It is a GUI tool to open a SQLite database file and inspect its schema and data.

Installing is easy:

$ sudo apt install sqlitebrowser

If you want to install the latest version:

$ sudo add-apt-repository -y ppa:linuxgndu/sqlitebrowser
$ sudo apt update
$ sudo apt install sqlitebrowser

That is it! Open sqlitebrowser and inspect your files 🙂

Tried with: SQLiteBrowser 3.9 and Ubuntu 16.04