Thursday, January 27, 2011

Perl: replace string over multiple files

perl -pi -w -e 's/search/replace/g;' *.cpp

Tuesday, January 25, 2011

Profiling C++

Use gprof:
Add -pg to compiler and linker flags and rebuild.
Call the program to collect profiling info.
Call the program with gprof yourprogram to see profiling info.

Use valgrind with the following options
valgrind --tool=callgrind ./(Your binary)
It will generate a file called callgrind.out.x. You can then use kcachegrind tool to read this file. It will give you a graphical analysis of things with results like which lines cost how much.

Thursday, January 20, 2011

Latex: Cropped PDFs from TikZ

Using the preview package. The package provides several ways of previewing parts of your document. For example, adding this to your document preamble:
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
will extract every tikzpicture environment. If you use pdflatex, every tikzpicture will be put on a separate page in the resulting pdf document. See the documentation for more details. To add a margin around the figure add:

Thursday, January 13, 2011

Doxygen code documentation tool

doxygen -g <config-file>
install doxygen-gui
doxywizard 

C++ code beautifier

linse@elektrobier:~/Documents/cloned/RNAforester2_refac_tmp$ astyle  --style=java --recursive  src/*.cpp  src/*.h
linse@elektrobier:~/Documents/cloned/RNAforester2_refac_tmp$ astyle  --style=java --recursive  src/*/*.cpp  src/*/*.h