git cheat-sheet: submodule

  • Add a submodule:

git submodule add RemoteRepositoryURL [LocalFolderName]

  • Clone a project with submodules:
    • Method 1:

git clone MainProjectURL
git submodule update –recursive –init

    • Method 2:

git clone –recursive MainProjectURL

  • Pull updates from the upstream:
    • Method 1:

git submodule update –recursive –remote –merge

  • Push submodules:

git push –recurse-submodules=on-demand

Repair GRUB2 for UEFI after Windows Installation



A windows installation wipe out your old GRUB2. You want to repair.


Suppose that /dev/sdaX is where your ubuntu was installed and /dev/sdaY is where you want to install GRUB2.

Boot with Ubuntu LiveCD. Open a terminal, then do the following:

# We call the Ubuntu from the LiveCD the Live Ubuntu
# We call the Ubuntu on our local partition /dev/sdaX the Local Ubuntu

sudo mount /dev/sdaX /mnt # mount the Local Ubuntu into the Live Ubuntu

sudo mount /dev/sdaY /mnt/boot/efi # mount the GRUB2 partition into the Local Ubuntu

for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
# This step is NECESSARY. It makes the Local Ubuntu see what the Live Ubuntu see. Then the update-grub can work correctly.

sudo chroot /mnt # Now we switch from the Live Ubuntu to the Local Ubuntu

sudo grub-install /dev/sdaY # Install GRUB2

sudo update-grub # Update GRUB2


Subequations in Lyx

Original post is here:

Subequation Numbering

If you want to group the equation numbers as, for example, (1a) and (1b), then you must do the following:

  1. Add \usepackage{amsmath} to the document preamble.
  2. Before the equation block, hit CTRL-L to add a LaTeX block, and type \begin{subequations}.
  3. After the equation block, hit CTRL-L to add a LaTeX block, and type \end{subequations}.

The document should now look like this:


and result in:


A sample document can be found here: MultilineEquationNumbering.lyx

Additional Options

If you want to add a cross-reference to the entire block of equations, e.g. (1) rather than (1a) or (1b) in the example above, you need to add a label to the subequations block. Just move your mouse immediately after the \begin{subequations} LaTeX block, then add a label. You can then add a Cross-Reference to this label as normal.

Build Your Own Cloud: Extra Comments

Alternatives to OwnCloud:

(1) Bittorrent Sync: Its P2P idea is very attractive, but currently it is not reliable even with its basic purpose: sync and update with the right version of a file.  Sometimes, it accidentally delete files;  Sometimes, it overwrites new files with way old files.  This happened to me just twos before I was going to submit my critical project deadline.  Many other users also reported similar data lose.  I will never use it before they have reliably implemented conflict management.

Secondly, Bittorrent Sync is closed source.  Its company is so money hungry that advertizes and charges for such beta software without conflict management, not caring about the damage it could bring to its users.  As closed source, it is not sure how secure their btsync is.  In their forum, they lock discussion on btsync’s alternatives and questions on its security.  Such attitude drives me away.

Third, btsync runs in background without telling the user with a task bar icon.  It is very sneaky.  If some one install on your computer, then it becomes a backdoor.  Your data is sent somewhere without telling you.  Damn!  Keep far away from this software and this irresponsible company until they prove they are trustful.

Do not use Bittorrent Sync until they have implemented conflict management, if you really care about your data safety.

(2) AeroFS: AeroFS runs on virtual machines.  This is both good and bad.  I eventually gave it up because on a Linux host machine with wireless connection, its guest machine cannot have a unique MAC, but must use the same as the host machine.  It may introduce many trouble in your LAN.  If you use a Windows as a host, it shall be fine.  By the way, their virtual machine appliance is really resource hungry.  In comparison, OwnCloud takes much less resource.