Sunday, January 30, 2011

How to change Figure and Table captions in LaTex

Usually figures and tables in LaTex get captions such as Figure 1 or Table 1. We can change these to other names as follows.

\renewcommand{\figurename}{Fig.}

OR to Japanese captions such as (with jarticle class)


¥renewcommand{¥figurename}{図}
¥renewcommand{¥tablename}{表}

Friday, December 10, 2010

2010 MacBook Air fan speed issue

After copying my data from the 15inch MBP to my new MBA, I found that the fan runs at full speed irrespective of what processes are running. So I decided to reset the System Management Controller (SMC) and this actually helped.

What you must do is switch off MBA while it is still plugged in to the power adapter and press
ctrl+option+shift and the power button (top left corner) just once. The light on the power adapter will
turn into green and after couple of seconds back to orange. Now switch the machine on.

Further info is here

Saturday, November 27, 2010

Spectral graph theory

Transfer learning for collective link prediction

Compressing and Decompressing Files

To decompress tar.gz (tgz) do (tar combines multiple files in a directory to a single file and gz compresses it)
  • tar xzvf filename
To compress to tar.gz do
  • tar czvf filename.tgz directory/
To decompress bz2 files do
  • bunzip2 filename.bz2
  • if it is tar.bz2 then do tar -xjvf filename.tar.bz2
To compress into tar.bz2 do
  • tar cjvf filename.tar.bz2 directory/

Thursday, November 11, 2010

How to link external libraries in C/C++

If you want to link /usr/local/lib/liblbfgs.so and compile quadratic.cpp then you have several options.
(include libbfgs.h in quadratic.cpp first)
g++  -Wall quadratic.cpp /usr/local/lib/liblbfgs.so -o quadratic

Or if this library is on your LD_LIBRARY_PATH, then you can simply do the following
g++ -Wall quadratic -llbfgs -o quadratic

Sunday, September 19, 2010

Flusing output in Python

When you use "print" statement to output messages to terminal during the execution of a python program, those messages might not get outputted promptly. This is true for time consuming programs that perform a lot of work in between print statements. To promptly flush the text to terminal invoke the python interpreter with "-u" option. For example, if your program is myprogram.py then do the following.

python -u myprogram.py
Alternatively, if you are using sys.stdout.write to print messages to the terminal, then you can do sys.stdout.flush() right after the sys.stdout.write() to do the same. This works even with file I/O.
file.flush() immediately writes the text that is in buffer. This is particularly useful when you are writing log files.

Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1