Sunday, December 4, 2022

Completing Removing a Git Submodule

This is a note about removing  a Git submodule completely.

  1. Revise the .gitmodules by removing the reference to the submodule Git repo;
  2. Revise the .git/config file by removing the reference to the submodule Git repo;
  3. Remove the submodule from Git index, e.g.,
        git rm --cached path_to_submodule
    
  4. Delelete the meta data from .git directory, by removing .git/module/path_to_submodule
  5. Stage the changes, and commit the changes, e.g.,
        git add -u
        git commit -m "removed the submodule"
        

Reference

The above is a summary from these references

Friday, December 2, 2022

Installing R Packages in User Space on Linux

On a Linux system, without running R as the root user, we can install R packages and libraries in the user space. By default, the installation directory is $HOME/R/library. What if we want to install it to a different directory without having to specifying it on the R command line? For this, we can set R_LIBS environment variables to point to the directory. For instance, if we wish to install the libraries to a hidden directory, e.g., the $HOME/.R/library directory, we can set it up in the user profile, such as, in the .profile or .bash_profile file,


if [ -n $R_LIBS ]; then
  R_LIBS="/home/hchen/.R/library":${R_LIBS}
else
  R_LIBS="/home/hchen/.R/library"
fi
export R_LIBS



Installing devtools and landmap in R

It took me several trial and error to install the devtools package and the landmap package from Github repo. This is a note about the installation procedure on Fedora Linux so that we don't have to repeat the trial and error process. 



sudo dnf install  \
		freetype-devel \
		libpng-devel \
        libtiff-devel \
        libjpeg-turbo-devel \
		gdal-devel \
		gdal-libs \
		proj-devel \
		geos-devel \
		udunits2-devel

Then in R,


install.packages('devtools')
library(devtools)
install_github('envirometrix/landmap')

Saturday, July 30, 2022

Windows 10 does not know some "devices" of a Dell Precision Workstation

I was installing Windows 10 on a Dell Precision T3620 Workstation. Although the systems worked well, it bothers me that the Windows Device Manager reported that some devices were not recognized, i.e., an yellow exclamation point on the devices, like the following screenshot shows,

In fact, these unrecognized devices are,

  • PCI Data Acquisition and Signal Processing Controller,
  • PCI Memory Controller, and
  • SM Bus Controller

It turns out that many users had similar problem, and the solution is to update some device drivers. However, I was slightly frustrated that the very driver that solved my problem (all three unrecognized devices) wasn't listed under "driver" on the Dell Support's website. Instead, it was listed under "Utility", and was the "Intel Chipset Device Software."

Friday, July 29, 2022

Oldest Recorded Supernova

Source: NASA

I was listening to the "Stuff you should know" podcast when I was driving to work, and heard the story about supernovae. The host of the podcast says that the oldest recorded supernova is Supernova 86. I looked it up on the Web, and yes, NASA has a Web page about it and states,

Chinese astronomers witnessed the event in 185 A.D., documenting a mysterious 'guest star' that remained in the sky for eight months.

The Wikipedia page about it (SN 185 about RCW 86) has the exactly the quote in the Chinese record, 

《後漢書·卷十二·天文下》:'中平二年十月癸亥,客星出南門中,大如半筵,五色喜怒稍小,至後年六月消。占曰:‘為兵。’至六年,司隸校尉袁紹 誅滅中官,大將軍 部曲將 吳匡 攻殺 車騎將軍 何苗,死者數千人。

and an English translation about the quote,

In the 2nd year of the epoch Zhongping, the 10th month, on the day Guihai (i.e., December 7, 185 AD), a 'guest star' appeared in the middle of the Southern Gate (i.e., an asterism consisting of ε Centauri and α Centauri), The size was half a bamboo mat. It displayed various colors, both pleasing and otherwise.It gradually lessened. In the 6th month of the succeeding year it disappeared.

Our Sun will eventually go "supernova" (although after a very long time (a billion years. Also stronomers think that our Sun is too small to go "supernova", but our Sun will die). It makes me wonder about the fate of the humanity. Well, perhaps, the humanity has long destroyed itself (by a nuclear war) before that; or perhaps, the humanity has found an eventual peace and has mastered the technology to find a new home ...

Wednesday, June 15, 2022

Cannot Safely Remove USB Drive on Windows 10? Use Diskpart

From time to time, I cannot safely remove or eject a USB drive. The reason is that one or more processes locks some files. For instance, I observed the following files were locked by a svchost.exe process on the USB drive F:,

F:\$Extended$
F:\System Volume Information\

The method that works consistently for me is to use Diskpart. Note this requires administrative privilege.   Below is an example to remove the external drive (shown as Disk 1),

C:> diskpart
DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          465 GB  1024 KB        *
  Disk 1    Online         1862 GB      0 B

DISKPART> select disk 1

Disk 1 is now the selected disk.

DISKPART> offline disk

DiskPart successfully offlined the selected disk.

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          465 GB  1024 KB        *
* Disk 1    Offline        1862 GB      0 B

To bring the disk back online without re-plugging it, we do the steps illustrated in the example below,
C:> diskpart
DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          465 GB  1024 KB        *
* Disk 1    Offline        1862 GB      0 B

DISKPART> select disk 1

Disk 1 is now the selected disk.

DISKPART> online disk

DiskPart successfully onlined the selected disk.

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online          465 GB  1024 KB        *
* Disk 1    Online         1862 GB      0 B

DISKPART>

Wednesday, June 1, 2022

Removing OpenVPN 2 Private Key Password

I wanted to remove the password protection for a OpenVPN 2 client private key. The solution is to use the ssh-keygen command. For instance, assuming the key file is client_private_key.key, we run

ssh-keygen -p -N "" -m pem -f client_private_key.key

The key file will be replaced by the key without the password protection.

Before I figured out this solution for OpenVPN 2, I ran into a problem. That is, I ran the following command instead,

ssh-keygen -p -N "" -f client_private_key.key

where there is no "-m" option to specify "pem" as the format of the key file and the key file is in the default PKCS 8 format. Then when I attempted to restart the OpenVPN 2 client, I saw in the log,

Error: private key password verification failed

The message is misleading in this case because the actual problem is that OpenVPN 2 does not recognize the PKCS 8 format. To correct the problem, we just need to run the ssh-keygen again and this time we specify the pem format as the file format, i.e.,

ssh-keygen -p -N "" -m pem -f client_private_key.key

Of course, in retrospective, I should have had run this command from the beginning with.