Saturday, October 24, 2009

Linux: vnc via ssh

remind myself:
1. start 'vncserver -name X' on server computer (that you try to connect by ssh)
Note: X is a session name which is defined in the file: ~/vnc/xstartup
2. ssh -L 5902:localhost:5901 YourAccountName@YourServerID(or hostname) in one local terminal
3. vncviewer localhost:5902 in your another local terminal

Friday, August 14, 2009

linux: how to insert an img to pdf files

If you want to insert an image (like your picture, signature etc.) to an existing pdf file and you don't have acrobat professional version (that allows you to edit a pdf file within the software). Then you may be able to use the following steps with combination of different tools that are available in linux:

  1. You have an image file (say, one lovely picture) and one pdf file (Orig.pdf) to which you want to insert your picture
  2. Use "gimp" to open them. For the pdf file, you have to select which page that you want to insert your picture to, and then open the page (NOTE: in order to have good quality and same size as the original page, you may have to set "resolution" as 320. I tried 300 and 400, and realized that 320 is the proper value)
  3. In "gimp", copy your picture on the pdf page. You can use the menu "Layer -> Scale Layer ..." to scale your picture to fit your requirement.
  4. Save your modified pdf page as one "eps" file.
  5. In terminal, convert the eps file to a pdf file by "epstopdf MyPage.eps" to get MyPage.pdf
  6. Then, still in your terminal, use the tool "pdftk" to merge the 2 pdf files (Orig.pdf and MyPage.pdf):
pdftk A=Orig.pdf B=MyPage.pdf cat A1-4 B1 A6-11 output Combined.pdf
where we assume MyPage.pdf will be inserted as Page 5 while totoal pages in Orig.pdf are 11 pages.

Merge pdf files:

pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

Thursday, August 13, 2009

linux:command:pdf: a useful tool

In linux, there is a very useful PDF tool called pdftk

http://www.accesspdf.com/pdftk/

Thursday, July 2, 2009

Java:Compile Errors

When I try to install a java program (JaxoDraw) by ant that draws Feynman diagram, I met some errors with my laptop settings. Here are 3 errors that printed on the screen:

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.5.0-gcj-4.2-1.5.0.0/lib/tools.jar

BUILD FAILED: /work/JaxoDraw-2.0-0/build.xml:xxx:
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
/work/JaxoDraw-2.0-0/build.xml:191: Error starting modern compiler


My solution and checking are:
1. I do not have jdk installed. So I installed it first.
2. Set JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.07/" (which is one java location)
3. compile by ant -lib /usr/lib/jvm/java-6-sun-1.6.0.07/lib/tools.jar (maybe, -lib ... won't be needed any more, I don't know)

Wednesday, July 1, 2009

Linux:Shell:Bash: how to search slash or backslash by sed

It is tricky to search (or replace) signs slash '\' or backslash '/' by sed. By searching internet, I found 2 approaches:

1. Put the command line of sed to a file called my.sed:

/D\\O/p

(this will print a line containing 'D\O')

2. Another way is to use single quote instead of double one in your shell command line:

sed -n '/D\\O/ p' myfile.txt

(-n is prevent from printing)

Monday, April 20, 2009

Linux: how to change background color of xdvi

If you want to change background color or whatever other settings of one application under X windows, for example, xdvi, you could set it in your file: ~/.Xdefaults by

xdvi*background: white
xdvi*foreground: black

.

Note: your changes will be starting after you log out and in.

ROOT: how to set TGraph Xaxis range.

It seems that I cannot set the x-axis range of TGraph by

graph->GetXaxis()->SetRangeUser(0,1);

. I have to use

graph->GetXaxis()->SetLimits(0,1);

to do this task. But the former way is working for y-axis.

Thursday, April 9, 2009

Linux:shell:BASH: How to delete one line by sed

If you want to delete one line containing one word "ThisWord" by sed, then you can do in the way:

sed -i "/ThisWord/d" YourTextFile.txt

Note, here '-i' is to delete it from the original file. Without it, sed only prints the file on screen. So before using '-i', make sure you are doing correct things.

Locations of visitors to this page