Load Grep Results Into Vim

When coding, I often need to search for the references of a variable or a function across multiple files. Usually I enter command mode of vim and do a grep command, memorize the search results and open the files having hits. This common pattern could be dramatically accelerated by a user-defined vim command:
:command Gitgrep :lex system("git grep -n " . shellescape(getreg('/'))).

Read More

Makefile MAKEOVERRIDES

TL;DR The variable MAKEOVERRIDES passes the variables defined in the make command line to sub-makes (even those make invoked indirectly). Emptying MAKEOVERRIDES can prevent sub-makes from picking up variables unexpected.

Read More

Fix Broken Packages

A server machine failed at upgrading from Ubuntu14.04 to Ubuntu16.04, and many packages are left in half-installed status, even apt is not working. I struggled several days to fix those broken packages, and this post documents some tricks I learnt.

Read More

MPI Foundation

I attended MPI Foundation, a nice training given by TACC staff, at the end of March. This post briefly documents the basic MPI programming knowledge I learnt (😓 should have been written long ago, but did not even start until the day before follow-up training).

Read More

Git Empty Tree

4b825dc642cb6eb9a060e54bf8d69288fbee4904 is the hash code to index the “empty tree” (before your first commit) in git version control system.

Read More

TeX Live Install Package

After switched to use Linux, I use vim-latex to extand vim for LaTeX editing. However, sometimes I would encounter errors like package not found. I thought that is because vim-latex supports limited packages (under ~/.vim/ftplugin/latex-suite/packages/), but actually vim-latex is just the plugin to turn vim into a LaTeX editor, while the complier behind it is something else, for example TeX Live.
TeX Live has its own package manager called tlmgr. This post documents some issues I had to install absent package for TeX Live.

Read More

Start a Process in Suspended State

Under some circumstances, I would like to launch the process, then let other programs attach to it. No matter how fast can I type, it is impossible for me to bind the processes from the very beginning. The solution is let the script to launch the process but suspend it immediately.

#!/bin/bash
$@ &
PID=$!
kill -STOP $PID
echo $PID
wait $PID

The script earns enough time for you to do your operations in another terminal, then to resume the process:

kill -CONT $PID

Note: need to replace $PID with the number printed in the first terminal.

Read More

Delete Lines from Huge Files

With huge files, tasks that as simple as removing first or last several lines could become hard. If you try to open a huge file with vim, the chance is that the system gets stuck struggling to load the huge file into memory. This post has several alternative approaches to delete lines from huge files.

Read More

Tips to Find Predefines for Compilers

Two useful tips from TACC tips regarding compiler macro expanding.

Tip 120:
Want to know what MACROS are predefined by the GCC and Intel compilers? Do

gcc -dM -E - < /dev/null > gcc_defined_macros.txt
icc -dM -E - < /dev/null > icc_defined_macros.txt

The flag -E in the tip is telling the compiler to expand macros.

Tip 69:
Having trouble figuring out how a macro is being expanded? Try pasting the line into a terminal and adding a -E. For example try changing mpicc -DFOO -DBAR -c foo.c into mpicc -DFOO -DBAR -E foo.c > foo.i and look at the foo.i file.

Read More