Wednesday, August 24, 2005
Float spanning columns in LaTeX
Monday, August 08, 2005
diff/patch
Making Patches
To create a patch, you run a program called diff, and save its output to a file. For instance, if the original source tree is in directory "foobar.old", and your new sources are in directory "foobar.new", the commanddiff -Naur foobar.old foobar.new > blarg.patchwill create the file 'blarg.patch' containing your changes in 'unified context diff' format.
Using Patches
To use a patch -- that is, to automatically carry out the changes described in a patch file -- you run a program called patch. For instance, if you're trying to apply the patch 'blarg.patch' to a package called foobar-0.17, you might saycd foobar-0.17; patch -p1 < ../blarg.patchThat would merge the changes from blarg.patch into your source tree. (The -p1 tells patch to ignore the first directory in filenames in the patch; that way a patch generated against the directory foobar-0.11 will still apply properly.)
Thursday, August 04, 2005
indentations
So, you can either get rid of GNU emacs, or change it to use saner
values. To do the latter, you can stick the following in your .emacs file:
(defun linux-c-mode ()
"C mode with adjusted defaults for use with the Linux kernel."
(interactive)
(c-mode)
(c-set-style "K&R")
(setq c-basic-offset 8))
use -kr and -i8 options with indent
(stands for "K&R, 8 character indents").
Spacing in Math Mode (LaTeX)
n a math environment, LaTeX ignores the spaces you type and puts in the spacing that it thinks is best. LaTeX formats mathematics the way it's done in mathematics texts. If you want different spacing, LaTeX provides the following four commands for use in math mode:
1. \; - a thick space
2. \: - a medium space
3. \, - a thin space
4. \! - a negative thin space
Wednesday, July 20, 2005
calculating average using perl
to find the average of the first column in a file
Monday, June 20, 2005
search in Emacs [ word under the cursor]
Tuesday, June 14, 2005
\[ or $$ instead of displaymath
\begin{displaymath}
math formula
\end{display math}
this is particularlty useful if you dont want to write small formula and don't want to break the paragraph to type it.
Monday, June 13, 2005
Redirections in Bash
directs both standard output and standard error to the file filename
command 2>&1 > filename
directs only the standard output to file, filename because the standard error was duplicated as standard output before the standard output was redirected
Sunday, June 12, 2005
setting page ranges while printing
-P page-list
Specifies which pages to print in the document. The list can contain a list of numbers and ranges (#-#) separated by commas (e.g. 1,3-5,16).
Thursday, May 12, 2005
Monday, May 02, 2005
rectangle select in Emacs
Working with rows & columns (rectangles)
A "rectangle" is one or more columns of text in one or more rows. Commands are available to delete rectangles, fill them with spaces, or cut and paste them.
To delineate a rectangle for a command to work on, set a mark in the first row to the left of the first column (i.e., the top left of the rectangle).
Move the cursor to the last row, then to the right of the last column (i.e. the bottom right of the rectangle).
To delete the rectangle, type Esc-x delete-rectangle
To cut a rectangle, type Esc-x kill-rectangle
To paste a killed rectangle in a new location, move the cursor to wherever the rectangle is to go and type Esc-x yank-rectangle
To replace the contents of a rectangle with spaces, type Esc-x clear-rectangle
To fill the area of the rectangle with spaces and push the original rectangle right, type Esc-x open-rectangle
Thursday, April 28, 2005
script command
You start by typing script filename ( in the absence of filename the default filename is typescript)
The script command ends when you exit the forked shell by typing control-d.
more info on man script ofcourse ;)
Wednesday, April 13, 2005
commandline arguments in perl
$#ARGV is the subscript of the last element of the @ARGV array
Monday, April 11, 2005
latex row height in tabular
\renewcommand\arraystretch{MyValue}% (MyValue=1.0 is for standard spacing)
Thursday, March 17, 2005
Common C++ error
error:return type specification for constructor invalid
This mainly happens when you forget to end the class declaration with a ';'
Thursday, December 09, 2004
gengetopt
If an option is given multiple times
If an option is specified as multiple, then it can be specified multiple times at command line. In this case, say the option is called foo, the generated foo_given field in the args structure contains the number of times it was specified and the generated field foo_arg is an array containing all the values that were specified for this option.
Notice that if a default value is specified for a multiple option, that value is assigned to the option only if no other value is specified on the command line (and the corresponding _given field will be set to 1), i.e., a default value IS NOT always part of the values of a multiple option.
for (i = 0; i < args_info.string_given; ++i)
printf ("passed string: %s\n", args_info.string_arg[i]);
Sunday, December 05, 2004
C++
fs.open(filename.c_str());
The above line attempts to open the file with the given filename (searching in the current directory). Note that open member function takes in a char* argument and not a C++-style string, so you must use c_str to convert it. (Sigh, this is just a weird artifact of the stream libraries being completed before the string library). Opening the file may or may not succeed (depending on whether the named file exists, what permissions it has, etc.), so before you proceed, you should check the state of the stream.
if (fs.fail()) return;
The call to fail checks if the state of the stream is unhappy, in this case, it will determine if the file was properly opened. This is essential before we start trying to output to the stream (in the same way that we check if a FILE* is NULL in C).
Thursday, December 02, 2004
Emacs
M-/ autocompletion. It's based on the tokens in the currently open buffers.
ESC-u change a word into uppercase
ESC-c capitalise a word
C-x C-u upcase region
Sunday, November 28, 2004
GNU Build system
Makefile.am in the top directory should have the subdirs where Makefiles need to be created.
e.g Makefile.am for toplevel
+++++
SUBDIRS = src
+++++
and in the directory "src" you can possibly have the following Makefile.am
++++++++++++++++
bin_PROGRAMS = hello
hello_SOURCES = hello.cpp
++++++++++++++++++
Next you need to have a configure.in in your toplevel directory
following is just a template , read and understand on your own , i have no explanations
++++++++++++++++++
AC_INIT(src/hello.cpp)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(hello, 0.1)
AC_PROG_CXX
AC_PROG_INSTALL
AC_OUTPUT(Makefile src/Makefile)
++++++++++++++++
you are pretty much done with the files at this stage ,
$aclocal
$autoconf
$touch AUTHORS NEWS README ChangeLog
$autoheader
$automake --add-missing
Thursday, October 28, 2004
Installing perl modules
perl -MCPAN -e shell (to get an interactive CPAN shell)
perl -MCPAN -e 'install Time::JulianDay' (if you know the name of the module, you can install it directly without interacting with the CPAN shell)
Within the CPAN shell:
i /expression/ will search for a Perl module containing expression, and
install module will install the module.
Example:
perl -MCPAN -e shell
i /JulianDay/
install Time::JulianDay
Note: if you are behind a firewall, you may wish to use passive FTP with Perl's Net::FTP module. Set the environment variable FTP_PASSIVE 1 (or any non-zero value) to use passive FTP when downloading Perl modules through CPAN.
To manually install a Perl module:
1. Download the Perl module from CPAN or other site.
2. Extract the tarball.
3. Run perl Makefile.PL
4. Run make
5. Run make test
6. Run make install