Tuesday, June 7, 2011

linux: check memory usage by 'free'

free -m -t

in MB. Note: since the memory is utilized by kernal than it is wasted. If you are curious how much memory you can use for your applications, you should check the 'free' column in the row of '-/+ buffers/cache'.

Monday, June 6, 2011

linux: sort

Use the command

sort -n -t. -k4

to sort strings like:
------------------------------
str1.str2.str3.1.txt
str1.str2.str3.10.txt
str1.str2.str3.2.txt
str1.str2.str3.21.txt
------------------------------

Use '-t' to define delimiter, '-n' for number sorting, '-k' for column number

Thursday, June 2, 2011

linux: how to generate an animated gif picture

gifsicle --loopcount --colors 256 --delay=50 1.gif 2.gif 3.gif > output.gif

'delay' is a parameter similar as 'frame rate', 50 means 50/100 seconds between frames.

linux: convert pictures (jpg) to avi movie

If you have pic files like:
drilldata00001.jpg
drilldata00002.jpg
drilldata00003.jpg

then you can use:

mencoder -speed 0.1 "mf://drilldata%05d.jpg" -o movie_drilldata.avi -ovc lavc -lavcopts vcodec=mjpeg

to generate an avi movie. The speed '0.1' is slower, '1' used the default frame rate. '1o' goes faster...

Tuesday, January 4, 2011

linux: merge pdf

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=firstANDsecond.pdf -dBATCH first.pdf second.pdf

Sunday, January 2, 2011

Thinkpad 410 brighness adjustment in ubuntu!

http://ubuntuforums.org/showthread.php?t=1515079#post9494941

Have to add

Code:

Option "RegistryDwords" "EnableBrightnessControl=1"

to your /etc/X11/xorg.conf under devices section. Make sure the quotation marks are the same as if you type them.

Wednesday, December 8, 2010

Linux: how to remove ^M at each line end

I got an acsii file from a Window's user. If it is a regular windows text file, then I can use a command 'dos2unix' to convert it in unix format. However, it doesn't work. I use 'less' to have a look at it, it looks like:

line1^M line2^M

. If I use emacs to view it, it looks okay like a regular file. In order to convert it to unix format, I use 'gedit' to do the conversion. A user will be reminded that you save as which format...

Saturday, October 30, 2010

linux: screen

screen is a useful command when you do not have other better choice like vnc, specially for background job running. One thing that bothered me is I cannot page up and down simply even specified by

screen -h 2000

So I have to enter copy/paste mode by: ctrl+a, esc, page down/up

Wednesday, August 25, 2010

linux: renice

from : http://linux.about.com/library/cmd/blcmdl8_renice.htm

Users other than the super-user may only alter the priority of processes they own, and can only monotonically increase their ``nice value'' within the range 0 to PRIO_MAX (20). (This prevents overriding administrative fiats.) The super-user may alter the priority of any process and set the priority to any value in the range PRIO_MIN (-20) to PRIO_MAX Useful priorities are: 20 (the affected processes will run only when nothing else in the system wants to), 0 (the ``base'' scheduling priority), anything negative (to make things go very fast).


Friday, May 28, 2010

linux: data transfter

This summary is not available. Please click here to view the post.

Sunday, April 11, 2010

ROOT: make plots more beautiful

http://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/

In ROOT, we can change its default to make plots more beautiful.

void
set_plot_style()
{
const Int_t NRGBs = 5;
const Int_t NCont = 255;

Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
gStyle->SetNumberContours(NCont);
}

Linux:bash:about "delete key"

When I use "delete key" in some bash terminal, the key sends a tilde "~" instead of deleting the char that is supposed to be deleted.

Find a solution:
1. In your $HOME directory, create or edit your keyboard-mapping file, $HOME/.inputrc
2. Add one mapping line:

"\M-[3~": delete-char

3. restart your terminal

Monday, March 29, 2010

Linux: how to reduce eps file size?

I have couples of eps files which have a large size (>10 MB). Thus when using them in Latex, the output files (either pdf or ps) become very large and very slow to view. So it is necessary to reduce them first. Here provided is an approch working in Linux.

  1. Create a new open office drawing file, past your large eps file to the canvas.
  2. Add your canvas hence it has no too much extra-space (magine)
  3. Export your drawing file to a PDF file. Here you can use low compress factors etc.
  4. Use "pdftops -eps YourFile.pdf" to get your small-size eps file
Note: You can use open office drawing to export your file to an eps file directly, however, the eps file is even larger than your original one, so this exporting is not useful.

Friday, January 29, 2010

Linux: overwrite

http://www.cyberciti.biz/tips/howto-keep-file-safe-from-overwriting.html

set -o noclobber
(no overwrite)

set +o
noclobber
(overwrite)

Linux: VNC

I use the following line to start up:

vncserver :1 -name kde -geometry 1250x760 -depth 24

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)

Locations of visitors to this page