I often spend lots of time on setting up the same software over and over again for different purposes. In order to save time, I decide to write down some useful procedures or hints here. Hope that they could be helpful to myself and others who visit here.

New Google Sites

posted Apr 18, 2019, 9:33 PM by Teng-Yok Lee

I did a quick test with the new Google Sites, but I decide to stay with the classic one because:

1. No complete history to rollback. This is the biggest reason.
2. Lose the banner in the left side (I used this to show weather of my current city).
3. The format of my publication list is destroyed.
4. Unsure whether I can post announcement, like what I am doing now.

A related question is: How to re-do the conversion? I created a draft but I disliked it.

The solution is in the page Manage Site/Convert to new site. After entering the stage Review and Publish, open the advanced pane, and choose to disconnect from the current page. Then it will restart from stage 1.

Save the subplot of matplotlib

posted Apr 18, 2019, 7:46 PM by Teng-Yok Lee   [ updated Apr 18, 2019, 7:47 PM ]


The solution is calling ax.get_tightbox() to get the entire region and converting per the figure's DPI. Based on the answer above, I wrote a short function to combine multiple axes:

def SaveAxes(fig, axes, fig_filepath):
    extents = [];
    for ax in axes:
    extent = Bbox.union(extents);
    plt.savefig(fig_filepath, bbox_inches = extent);

How to check a python module path before importing?

posted Jun 24, 2018, 7:01 PM by Teng-Yok Lee


Use imp. For instance,
import cv2 imp.find_module("cv2")

Enable OpenGL direct rendering over ssh after installing nVidia driver

posted Jun 23, 2018, 5:30 PM by Teng-Yok Lee   [ updated Jun 23, 2018, 8:29 PM ]

In my experience, nVidia driver will overwrite Mesa's in /usr/lib/x86_64-linux-gnu/mesa/. However, mesa's support direct rendering over ssh, while nVidia's can't.

A quick fix is copying the of /usr/lib/x86_64-linux-gnu/mesa/ from other host. Then once ssh to the host, set LD_LIBRARY_PATH as follows:

$ export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/mesa:${LD_LIBRARY_PATH}

Then the current session will use mesa's

More detailed explanation can be seen here:

FW: List the revision of a conda environment

posted Feb 12, 2018, 8:05 PM by Teng-Yok Lee

$ conda list --revisions


Git tips

posted Feb 4, 2018, 6:36 AM by Teng-Yok Lee   [ updated Feb 4, 2018, 6:37 AM ]

This is the collection for tips to fix common problems I have.

Ignore the change of file modes

$ git config core.fileMode false

Commonly used dpkg & apt-get options

posted Jan 24, 2018, 6:07 PM by Teng-Yok Lee   [ updated Jan 24, 2018, 6:09 PM ]

Given a file path, query the belonging package (REF):
$ dpkg -S <filepath>

Query files in a package:
$ dpkg -L <package>

List install packages (REF):
$ apt list --installed

FW: How to debug a release build

posted Jul 7, 2017, 6:38 AM by Teng-Yok Lee


With CMake, the same effect can be achieved by modifying the following CMake variables:


Tips for Bash Programming

posted Jun 25, 2017, 7:05 PM by Teng-Yok Lee   [ updated Jun 27, 2017, 8:02 AM ]

  • Add "set -o errexit" to exit when there are errors.
  • Add "set -o nounset" to exist when there are undefined variables.
  • Add readonly for constant variables.
How to enable the debug mode? (REF, REF)
  • -v: Run shell script in verbose mode.
  • -n: Read the command w/o execution.
  • -x: Show the executed commands & arguments

Test the slideshow of Google+ photo album

posted Oct 15, 2016, 5:53 AM by Teng-Yok Lee   [ updated Oct 15, 2016, 7:57 PM ]

This post is to test the slideshow feature of Google+ photo on Google Site. Unfortunately it does not work...

Maybe the easiest way is to insert an animated .gif? e.g.

With imagemagick, I can combine multiple images into a single GIF. The command is:

$ convert -delay 100 -loop 1 *.JPG firework.gif

A result is below:

1-10 of 111