This blog covers various topics from technical tweaks to latest in computational linguistics, Artificial Intelligence, Machine Learning and Wed Data Mining.
Saturday, November 27, 2010
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
- tar czvf filename.tgz directory/
- bunzip2 filename.bz2
- if it is tar.bz2 then do tar -xjvf filename.tar.bz2
- 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
(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.
file.flush() immediately writes the text that is in buffer. This is particularly useful when you are writing log files.
python -u myprogram.pyAlternatively, 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.
Thursday, September 9, 2010
emacs useful commands
Here are some useful tips from this site.
- C-s incremental search. Once you have reached the end of the buffer it will perform an overlap search from the start.
- Use fn+left arrow to move to the end of the current line.
- Use fn+right arrow to move to the start of the current line.
- Use fn+up arrow to move to the start of the buffer.
- Use fn+down arrow to move to the end of the buffer. (These are tested on Aquamacs)
- M-x grep is extremely useful. It will bring the grep -n -e command to which you must append the filename and the 'string to match' and hit return. The grepped results will be shown in a separate buffer which you can click to move to the appropriate position in the source file.
- M-x shell opens a remote/local shell on a separate buffer.
- If a file is in version control then emacs shows that in the bottom buffer bar. (e.g. SVN).
- C-x v = shows the modifications that you have done since the last commit to the current file.
- C-x v v will perform the next appropriate version control action to the current file. If it is a commit then you will get a buffer to write a commit note and then hit C-c C-c to make the commit.
- To enter/exit from full screen mode use: command+shift and return.
Thursday, September 2, 2010
bash script to convert encoding of all files in a directory
The following bash script calls iconv on each text file in the input directory and converts them from shift-jis (sjis) to Unicode UTF-8 (utf-8).
#! /bin/bash
inputDir="danu-summaries"
outputDir="danu"
for file in ../$inputDir/*; do
if [ -f $file ]; then
fname=`echo "$file" | cut -d '/' -f3`
echo $fname
iconv -f sjis -t utf-8 ../$inputDir/$fname > ./$outputDir/$fname
fi
done
#! /bin/bash
inputDir="danu-summaries"
outputDir="danu"
for file in ../$inputDir/*; do
if [ -f $file ]; then
fname=`echo "$file" | cut -d '/' -f3`
echo $fname
iconv -f sjis -t utf-8 ../$inputDir/$fname > ./$outputDir/$fname
fi
done
Subscribe to:
Posts (Atom)
Continuously monitor GPU usage
For nvidia GPUs do the follwing: nvidia-smi -l 1
-
If you used Adobe acrobat to annotate a PDF file and you had Acrobat crashed or had to restart the computer abruptly during the annotation p...
-
EXPLORING WEB SCALE LANGUAGE MODELS FOR SEARCH QUERY PROCESSING Jian Huang, Jiangbo Miao, Xiaolong Li, Jianfeng Gao and Kuansan Wang CROSS...
-
The following set of commands will plot two data series in a file using point markers and also write the output to a eps file and further co...