Friday, October 7, 2011

p4 integrate says must refer to client

This can happen with other p4 commands such as changes. It happens because the path you used in your command is outside of your clientspec.

To fix this problem, check the path used in your command. It should match with one of the paths that you see in your clientspec shown by the p4 client command.

Solution: E567: no cscope connections

If you are getting this error:
E567: no cscope connections

It could be because of multiple reasons. A couple of things to check are:

1. In your .vimrc file check if you are pointing the csprg variable to the correct location of cscope.
In mine, I had to point it to /usr/bin/cscope. You can find this location by running the command
which cscope.

2. If the editor could find cscope, then you need to also ensure that it is able to access the cscope.out files which form the cscope database. If you are invoking vim from a directory that does not contain this file then you will still see the no connections error. One alternative is to start the vi editor from the place where you have the cscope.out file. Note that the cscope.out file is generated when you run the cscope -R command at least once - this is used to build the csope database. To remedy this solution, export the variable export CSCOPE_DB="/path/to/cscope.
out" in your .bashrc file. You will need to reload the .bashrc by running the command source .bashrc from your home directory.

These two things did the trick for me. I hope it works for you too, since cscope is awesome!

Monday, October 3, 2011

Convert eps to jpeg or jpg to eps on Linux (jpg to eps)

Simple technique, use the convert utility:
convert filename.jpg filename.eps

If you wish to convert from eps to jpeg use ghostscript:
gs -sDEVICE=jpeg -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r300 -sOutputFile=filename.jpg filename.eps
If your console says gs command not found, install ghostscript. On ubuntu/debain systems, this can be easily done by saying something like apt-get install ghostscript, or whatever is the name returned by searching for apt-cache search ghostscript.

This basic conversion can result in large file sizes though, so to have a smaller file, use any utility like mogrify to resize the image. Example:
mogrify -trim -resize 1280x1024 filename.jpg
Note that this command will change the size of the image and could possibly result in changing the aspect ratio.

== Update: jpg to eps ==

There is also another simpler way to change jpg to eps. Install the adobe postscript printer on your machine. Print using that postscript printer (while selecting options that allow you to optimize for eps). Finally, manually adjust the bounding box to make it a proper eps.

Sunday, October 2, 2011

Latex block comment

Introduce this one line at the beginning of the file:
\newcommand{\eat}[1]{}
Use the \eat tag around any block you want to comment out.
E.g. to comment out the following lines

\eat{
asda
adsada
ads
 }

will do it.

How to remove vi or vim line numbers

Sequence of keys: esc followed by:
 :set nonumber

The ":" is a part of the command.

Vim 'modifiable' is off

The error seen on screen is that when the file is opened, 
E21: Cannot make changes, 'modifiable' is off
You could use the -M argument to setup Vim to work in a viewer mode.  This is

only voluntary though, since these commands will remove the protection:

 :set modifiable
 :set write