tag:blogger.com,1999:blog-3420641947929469302024-02-07T13:06:54.982-08:00Sun lifeThe life is too short to be little.Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.comBlogger120125tag:blogger.com,1999:blog-342064194792946930.post-64471211072265619312011-06-07T10:48:00.000-07:002011-06-07T10:50:08.352-07:00linux: check memory usage by 'free'free -m -t<br /><br />in MB. <span style="color: rgb(255, 0, 0);">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'.</span>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com1tag:blogger.com,1999:blog-342064194792946930.post-9146196120340092772011-06-06T11:05:00.000-07:002011-06-06T11:09:17.285-07:00linux: sortUse the command<br /><br />sort -n -t. -k4<br /><br />to sort strings like:<br />------------------------------<br />str1.str2.str3.1.txt<br />str1.str2.str3.10.txt<br />str1.str2.str3.2.txt<br />str1.str2.str3.21.txt<br />------------------------------<br /><br />Use '-t' to define delimiter, '-n' for number sorting, '-k' for column numberSun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-45284787439947682532011-06-02T12:50:00.000-07:002011-06-02T12:52:42.820-07:00linux: how to generate an animated gif picture<span style="font-style: italic; font-weight: bold;">gifsicle --loopcount --colors 256 --delay=50 1.gif 2.gif 3.gif > output.gif</span><br /><br />'delay' is a parameter similar as 'frame rate', 50 means 50/100 seconds between frames.Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-55828265243022877512011-06-02T12:47:00.000-07:002011-06-02T12:50:23.162-07:00linux: convert pictures (jpg) to avi movieIf you have pic files like:<br />drilldata00001.jpg<br />drilldata00002.jpg<br />drilldata00003.jpg<br /><br />then you can use:<br /><br /><span style="font-weight: bold;">mencoder -speed 0.1 "mf://drilldata%05d.jpg" -o movie_drilldata.avi -ovc lavc -lavcopts vcodec=mjpeg</span><br /><br />to generate an avi movie. The speed '0.1' is slower, '1' used the default frame rate. '1o' goes faster...Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-1926485827403245492011-01-04T09:55:00.001-08:002011-01-04T09:55:26.445-08:00linux: merge pdf<div xmlns='http://www.w3.org/1999/xhtml'><p>gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=firstANDsecond.pdf -dBATCH first.pdf second.pdf</p><p/><p/></div>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-37590281655218297932011-01-02T21:03:00.001-08:002011-01-02T21:03:46.294-08:00Thinkpad 410 brighness adjustment in ubuntu!<div xmlns='http://www.w3.org/1999/xhtml'><p>http://ubuntuforums.org/showthread.php?t=1515079#post9494941</p><p/><p>Have to add</p><p>Code:</p><p/><p>Option "RegistryDwords" "EnableBrightnessControl=1"</p><p/><p>to your /etc/X11/xorg.conf under devices section. Make sure the quotation marks are the same as if you type them.</p></div>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-16560255995571253472010-12-08T12:57:00.001-08:002010-12-08T12:57:06.525-08:00Linux: how to remove ^M at each line end<div xmlns='http://www.w3.org/1999/xhtml'><p>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:</p><p>line1^M line2^M</p><p>. 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...</p><p><img height='1' width='1' src='https://blogger.googleusercontent.com/tracker/4462074143258065561-5180270152290160403?l=zyliulog.blogspot.com'/></p></div>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-66472968399926891332010-10-30T22:59:00.000-07:002010-10-30T23:02:23.145-07:00linux: screenscreen 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<br /><br />screen -h 2000<br /><br />So I have to enter copy/paste mode by: ctrl+a, esc, page down/upSun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-66852548973163167522010-08-25T15:55:00.000-07:002010-08-25T15:56:31.067-07:00linux: renicefrom : http://linux.about.com/library/cmd/blcmdl8_renice.htm<br /><br />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 <b>PRIO_MAX</b> (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 <b>PRIO_MIN</b> (-20) to <b>PRIO_MAX </b>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). <a name="lbAE"><br /><br /><br /></a>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-11737305428002872632010-05-28T20:59:00.000-07:002010-05-28T21:00:38.733-07:00linux: data transfterrsync -xval mycomp.xxx.com:/home/xxx .Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-39109001944658972352010-04-11T16:50:00.001-07:002010-04-11T16:52:23.931-07:00ROOT: make plots more beautifulhttp://ultrahigh.org/2007/08/20/making-pretty-root-color-palettes/<br /><br />In ROOT, we can change its default to make plots more beautiful.<br /><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;">void</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;">set_plot_style()</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;">{</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;"> const Int_t NRGBs = 5;</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;"> const Int_t NCont = 255;</span><br /><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;"> Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;"> Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;"> Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;"> Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;"> TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;"> gStyle->SetNumberContours(NCont);</span><br /><span style="font-weight: bold; color: rgb(255, 0, 0); font-family: courier new;">}</span>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-80688725620541843602010-04-11T10:14:00.000-07:002010-04-11T10:22:31.764-07:00Linux: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.<br /><br />Find a solution:<br />1. In your $HOME directory, create or edit your keyboard-mapping file, $HOME/.inputrc<br />2. Add one mapping line:<br /><br /> <span style="font-weight: bold;"> </span><span style="color: rgb(255, 0, 0); font-weight: bold;">"\M-[3~": delete-char<br /><br /></span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(255, 0, 0);"><span style="color: rgb(0, 0, 0);">. restart your terminal </span></span><span style="color: rgb(255, 0, 0); font-weight: bold;"><br /></span>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-17914713220071508132010-03-29T11:56:00.000-07:002010-03-29T12:02:46.684-07:00Linux: 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.<br /><br /><ol><li>Create a new open office drawing file, past your large eps file to the canvas.<br /></li><li>Add your canvas hence it has no too much extra-space (magine)<br /></li><li>Export your drawing file to a PDF file. Here you can use low compress factors etc.<br /></li><li>Use "<span style="font-family: courier new;font-size:130%;" ><span style="color: rgb(255, 0, 0); font-weight: bold;">pdftops -eps</span></span> YourFile.pdf" to get your small-size eps file</li></ol>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.Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com6tag:blogger.com,1999:blog-342064194792946930.post-17870079599286981172010-01-29T00:18:00.000-08:002010-01-29T00:19:46.427-08:00Linux: overwritehttp://www.cyberciti.biz/tips/howto-keep-file-safe-from-overwriting.html<br /><br /><code> set -o noclobber<br />(no overwrite)<br /><br />set +o </code><code>noclobber<br />(overwrite)<br /></code>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-83744410798644107272010-01-29T00:15:00.000-08:002010-01-29T00:16:54.382-08:00Linux: VNCI use the following line to start up:<br /><br />vncserver :1 -name kde -geometry 1250x760 -depth 24Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-55243162927301150822009-11-18T11:43:00.000-08:002009-11-18T12:56:24.210-08:00Use Fortran subroutines in C++<a href="http://wwwcompass.cern.ch/compass/software/offline/software/fandc/fandc.html">Good article</a><a href="http://arnholm.org/software/cppf77/cppf77.htm"><br /><br />Another one</a>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-82420373455248731542009-10-24T20:58:00.000-07:002009-10-24T21:02:55.520-07:00Linux: vnc via sshremind myself:<br />1. start '<span style="color: rgb(204, 0, 0);">vncserver -name X</span>' on server computer (that you try to connect by ssh)<br /> Note: X is a session name which is defined in the file: ~/vnc/xstartup<br />2. <span style="color: rgb(204, 0, 0);">ssh -L 5902:localhost:5901 YourAccountName@YourServerID</span>(or hostname) in one local terminal<br />3. <span style="color: rgb(204, 0, 0);">vncviewer localhost:5902</span> in your another local terminalSun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-80525400397721147312009-08-14T08:22:00.000-07:002009-09-18T16:48:23.512-07:00linux: how to insert an img to pdf filesIf 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:<br /><br /><ol><li>You have an image file (say, one lovely picture) and one pdf file (Orig.pdf) to which you want to insert your picture</li><li>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)<br /></li><li>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.</li><li>Save your modified pdf page as one "eps" file.<br /></li><li>In terminal, convert the eps file to a pdf file by "epstopdf MyPage.eps" to get MyPage.pdf<br /></li><li>Then, still in your terminal, use the tool "pdftk" to merge the 2 pdf files (Orig.pdf and MyPage.pdf): </li></ol><span style="font-weight: bold; color: rgb(255, 102, 102);font-family:courier new;" >pdftk A=Orig.pdf B=MyPage.pdf cat A1-4 B1 A6-11 output Combined.pdf</span><br />where we assume MyPage.pdf will be inserted as Page 5 while totoal pages in Orig.pdf are 11 pages.<br /><br />Merge pdf files:<br /><br /><span style="font-weight: bold; color: rgb(51, 204, 0);">pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf</span>Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com10tag:blogger.com,1999:blog-342064194792946930.post-6406576307121280562009-08-13T22:25:00.000-07:002009-08-13T22:27:03.509-07:00linux:command:pdf: a useful toolIn linux, there is a very useful PDF tool called pdftk<br /><br />http://www.accesspdf.com/pdftk/Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com1tag:blogger.com,1999:blog-342064194792946930.post-54184862374247229762009-07-02T16:33:00.000-07:002009-07-02T16:41:50.434-07:00Java:Compile ErrorsWhen 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:<br /><br /><span style="font-family: courier new;">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</span><br /><br /><pre style="font-family: courier new;">BUILD FAILED: /work/JaxoDraw-2.0-0/build.xml:xxx:<br />Unable to find a javac compiler;<br />com.sun.tools.javac.Main is not on the classpath.<br />Perhaps JAVA_HOME does not point to the JDK<br /></pre><span style="font-family: courier new;">/work/JaxoDraw-2.0-0/build.xml:191: Error starting modern compiler</span><br /><br /><br />My solution and checking are:<br />1. I do not have jdk installed. So I installed it first.<br />2. Set JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.07/" (which is one java location)<br />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)Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-10367766171544838732009-07-01T18:42:00.000-07:002009-07-01T18:47:59.579-07:00Linux:Shell:Bash: how to search slash or backslash by sedIt is tricky to search (or replace) signs slash '\' or backslash '/' by sed. By searching internet, I found 2 approaches:<br /><br />1. Put the command line of sed to a file called my.sed:<br /><br />/D\\O/p<br /><br />(this will print a line containing 'D\O')<br /><br />2. Another way is to use single quote instead of double one in your shell command line:<br /><br />sed -n '/D\\O/ p' myfile.txt<br /><br />(-n is prevent from printing)Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-57456094561306969702009-04-20T15:09:00.000-07:002009-04-20T15:14:13.228-07:00Linux: how to change background color of xdviIf 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: <span style="font-weight: bold; font-style: italic; color: rgb(255, 0, 0);">~/.Xdefaults</span> by<br /><br /><span style="color: rgb(51, 204, 0);">xdvi*background: white</span><br /><span style="color: rgb(51, 204, 0);">xdvi*foreground: black</span><br /><br />.<br /><br />Note: your changes will be starting after you log out and in.Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-38469905327715073222009-04-20T10:58:00.000-07:002009-04-20T11:01:11.927-07:00ROOT: how to set TGraph Xaxis range.It seems that I cannot set the x-axis range of TGraph by<br /><br />graph->GetXaxis()->SetRangeUser(0,1);<br /><br />. I have to use<br /><br /><span style="color: rgb(204, 0, 0);">graph->GetXaxis()->SetLimits(0,1);</span><br /><br />to do this task. But the former way is working for y-axis.Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com2tag:blogger.com,1999:blog-342064194792946930.post-19576340118699794282009-04-09T10:47:00.001-07:002009-04-09T10:50:39.828-07:00Linux:shell:BASH: How to delete one line by sedIf you want to delete one line containing one word "<span style="color: rgb(51, 204, 0);">ThisWord</span>" by sed, then you can do in the way:<br /><br /><span style="color: rgb(255, 0, 0);">sed -i "/<span style="color: rgb(51, 255, 51);">ThisWord</span>/d" YourTextFile.txt</span><br /><br />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.Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com0tag:blogger.com,1999:blog-342064194792946930.post-69321572720647546512008-12-18T09:48:00.000-08:002008-12-18T11:04:31.949-08:00Linux:shell:Bash: How to change color of your shell printout<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkDHnHOQNU8Ma2j8d8loxO4zSOtvnfSRxKxL8uZgFP0CBX_eXFlCtu0z3H3x5fbgOW9S3ef_OpCgWSNeS4jlYktcX70X9eo0tsRSmOh4xMnGO0X0shm1CPeTXAFipWWdSn2Df-5dtqpTsd/s1600-h/colortable.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 221px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkDHnHOQNU8Ma2j8d8loxO4zSOtvnfSRxKxL8uZgFP0CBX_eXFlCtu0z3H3x5fbgOW9S3ef_OpCgWSNeS4jlYktcX70X9eo0tsRSmOh4xMnGO0X0shm1CPeTXAFipWWdSn2Df-5dtqpTsd/s320/colortable.gif" alt="" id="BLOGGER_PHOTO_ID_5281192809503552834" border="0" /></a><br />You could use 'echo -e' to change your printout text and background color by some color variables. One of the easiest ways to use them is to define shell variable, for example, define those variables in your shell script:<br /><br /><span style="font-weight: bold;font-family:courier new;" >red='\e[0;31m'</span> <span style="font-weight: bold;font-family:courier new;" ><br />RED='\e[1;31m'</span> <span style="font-weight: bold;font-family:courier new;" ><br />blue='\e[0;34m'</span> <span style="font-weight: bold;font-family:courier new;" ><br />BLUE='\e[1;34m'</span> <span style="font-weight: bold;font-family:courier new;" ><br />cyan='\e[0;36m'</span><br /><span style="font-weight: bold;font-family:courier new;" >CYAN='\e[1;36m'</span> <span style="font-weight: bold;font-family:courier new;" ><br />NC='\e[0m' # No Color</span><br /><br />. <span style="font-weight: bold;font-family:courier new;" >'\e[0;36m'</span>: <span style="font-weight: bold;">0</span>'s place is the color of background (0, no effect, 1, bold, 4, underline) and <span style="font-weight: bold;">36</span> is the text color. You also can change background colors due to color values in the color table. For example, <span style="font-weight: bold;font-family:courier new;" >'\e[41;34m'</span> changes background color to red and text color to blue.<br /><br />How to print?<br /><br /><span style="font-weight: bold;font-family:courier new;" >echo -e "$red These texts are in red$NC"</span> #you must use '-e' to enable interpretation of the backslash-escaped characters, see echo's help.<br /><br />or if you want to use it in 'printf':<br /><br /><span style="font-weight: bold;font-family:courier new;" >printf "%s\n" "`echo -e $red`These texts are in red`echo -e $NC`"</span><br /><br />There is a table of color values attached (this table is from <a href="http://www.funtoo.org/en/articles/linux/tips/prompt/">the link</a>). You can find color values what you want.Sun lifehttp://www.blogger.com/profile/03771892899048949082noreply@blogger.com2