GNU screen in 256 colors on Mac

GNU screen that comes with Mac OS X does not support 256 colors. An easy way to get it have more colors:

brew install homebrew/dupes/screen
GNU screen in 256 colors on Mac

Ubuntu package management


sudo apt-get install <package_name>

search a package in the repo:

apt-cache search <pattern>

search an installed package:

dpkg --get-selections [<package_name>]


dpkg --get-selections | grep <pattern>

query the content of an installed package:

dpkg-query -L <package_name>
Ubuntu package management

Build PTAM on Ubuntu

Install TooN

git clone toon
cd toon
./configure --prefix=$HOME
make install

Install libCVD

Install the dependency first:

sudo apt-get install libdc1394-22-dev libv4l-dev
(cd /usr/include/linux && sudo ln -s ../libv4l1-videodev.h videodev.h)
git clone libcvd
cd libcvd
CXXFLAGS=-D_REENTRANT ./configure --without-ffmpeg --prefix=$HOME
# or CXXFLAGS=-D_REENTRANT ./configure --without-ffmpeg --prefix=$HOME --disable-fast7
vi cvd_src/image_io/jpeg.cxx
# at lines 160 and 189: replace `true' with `(boolean)1'
# at line 253: replace `true' with `(boolean)1'
# at line 339: replace `1' with `(boolean)1'
make -j8
make install

Install GVars

Install the dependency:

sudo apt-get install libreadline6-dev
git clone gvars
cd gvars
./configure --disable-widgets --prefix=$HOME
make -j8
make install

Build PTAM

Build it:

git clone ptam
cd ptam
git checkout Linuxmint15
cd Src
vi Makefile
# modify the include and lib paths in the Makefile
# make depend
make -j12

Run it:

# calibrate the camera
cp camera.cfg settings.cfg
# track!


Build PTAM on Ubuntu

Image sequence to a video clip on Linux

using ffmpeg in an essential form:

ffmpeg -start_number n -i test_%d.jpg -vcodec mpeg4 test.avi

with more control:

ffmpeg -f image2 -framerate 25 -pattern_type sequence -start_number 1234 -r 3 -i img_%04d.jpg -s 720x480 test.avi

using mkmpeg4 script, which requires mplayer on Linux:

mkmpeg4 -o output.avi -f 30 `ls *.png`


Image sequence to a video clip on Linux

tar: cannot mkdir permission denied

tar, by default, should handle the restoration of directory permissions correctly so that the files can be extracted within subdirectories as well as the original permissions of those subdirectories are restored as in the archive, but sometimes it fails. It might be when extracting from an incrementally created archive.

tar xf ../r2013b.tar
tar: r2013b/archives/common: Cannot mkdir: Permission denied
tar: r2013b/archives/common/3p/tablelayout_common_1372719204.xml: Cannot open: No such file or directory
tar: r2013b/archives/common: Cannot mkdir: Permission denied
tar: r2013b/archives/common/3p/._tex-archive_common_1360092817.enc: Cannot open: No such file or directory
tar: r2013b/archives/common: Cannot mkdir: Permission denied
tar: r2013b/archives/common/3p/tex-archive_common_1360092817.enc: Cannot open: No such file or directory

Then it’s required to have tar to delay the permission restoration after extracting all files by giving --delay-directory-restore option:

tar -x --delay-directory-restore -f ../r2013b.tar

See this for the default behaviour of tar.

tar: cannot mkdir permission denied

Multiple NVidia graphics cards in Ubuntu

Two NVidia GTX/GT graphics cards + two monitors + Intel motherboard + Ubuntu 12.04 + 64 bit Nvidia driver + CUDA installation

Disconnect the secondary one of the two monitors.

Select the primary video adaptor in BIOS setup. If the BIOS persists not to change the order, try to change it to automatic or something else, then to change it to manual with your favoured order in the next reboot.

This ensures that you have POST messages and tty1–6 consoles displayed in your primary graphics card correctly.

Update xorg.conf. nvidia-settings can do it for you. Ensure that:
you have a “Device” section which identifies correctly the graphics card you want to use for X11.
This will have your X11 server use the graphics card you want.

Install the graphics card driver in the following order.

Download the suitable graphics card driver and the CUDA toolkit in the following pages, both the .run installers.

EDIT: Check which version of gcc was used to build the kernel:

cat /proc/version

Set compiler version the same as that used to compile kernel:

sudo update-alternatives --config gcc


export CC=/usr/bin/gcc-x.x

If you’re in GUI environment, press ctrl-alt-F1 to change to a tty console.

Stop X server:

sudo service lightdm stop

Remove the old NVidia driver:

sudo apt-get remove nvidia-*

Remove the nouveau driver which causes problems with maya and potentially with other software:

sudo apt-get remove xserver-xorg-video-nouveau

If you installed the driver without using apt-get you may need:

sudo /usr/bin/nvidia-uninstall

Remove the NVidia kernel module:

sudo dkms remove -m nvidia -v <version> --all

To identify the kernel module that’s running:

lsmod | grep nvidia
find /lib/modules | grep nvidia

To get more info about the kernel module:

modinfo <module name>

nvidia apt-get uninstaller removes kernel modules, so better reboot before checking it.

Install the driver—run the downloaded graphics card driver (the .run file):

sudo sh ./NVIDIA-Linux-x86_64-<version>.run

After installing the driver, remove xorg.conf file:

sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

Set your gcc version back if you had to change it for the driver compilation:

sudo update-alternatives --config gcc


sudo reboot

Install CUDA—run the downloaded CUDA toolkit .run installer:

sudo sh ./cuda_<version>

During the installation, do not install the driver, but only the CUDA toolkit and sample code.

After the installation add path and library path.

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Connect the second monitor.

Failed to run `/usr/sbin/dkms add -m nvidia -v 331.20 -k 3.2.0-57-generic`: Error! DKMS tree already contains: nvidia-331.20 You cannot add the same module/version combo more than once.


Multiple NVidia graphics cards in Ubuntu