<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6273406038634066436</id><updated>2012-01-16T06:27:02.099-08:00</updated><category term='Python'/><category term='TikZ'/><category term='Web Design'/><category term='Beamer'/><category term='GhostScript'/><category term='Linux'/><category term='Cpp'/><category term='Image'/><category term='Emacs'/><category term='Bash'/><category term='ubuntu'/><category term='Latex'/><category term='Google'/><category term='Programming'/><title type='text'>Haifeng's Technical Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>30</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-1569533681992887142</id><published>2011-05-22T06:16:00.000-07:00</published><updated>2011-05-22T06:27:35.699-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Latex'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>How to setup spell checking for Kile editor</title><content type='html'>&lt;div&gt;Spell checking in Kile will be very useful. Here is one way to setup it. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Install aspell&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;sudo apt-get install aspell aspell-en dictionaries-common hunspell-en-us&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;Goto Applications-&amp;gt;Other-&amp;gt;Spell Check&lt;br /&gt;In the client, choose Aspell.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;Restart Kile. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;You can open the file &lt;pre&gt;~/.aspell.en.pws&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;It stores the local dictionary for the spell checking. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-1569533681992887142?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/1569533681992887142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2011/05/how-to-setup-spell-checking-for-kile.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/1569533681992887142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/1569533681992887142'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2011/05/how-to-setup-spell-checking-for-kile.html' title='How to setup spell checking for Kile editor'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-1555334909396229775</id><published>2011-02-22T04:52:00.000-08:00</published><updated>2011-02-22T04:58:26.400-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>How to install and upgrade package in Ubuntu</title><content type='html'>Edit&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;vi /etc/apt/sources.list&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;deb http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main&lt;br /&gt;deb-src http://ppa.launchpad.net/chromium-daily/ppa/ubuntu karmic main&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;sudo apt-get update&lt;br /&gt;sudo apt-get install chromium-browser&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;sudo apt-get upgrade&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-1555334909396229775?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/1555334909396229775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2011/02/how-to-install-and-upgrade-package-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/1555334909396229775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/1555334909396229775'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2011/02/how-to-install-and-upgrade-package-in.html' title='How to install and upgrade package in Ubuntu'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-6889820332426555660</id><published>2011-02-11T14:01:00.000-08:00</published><updated>2011-02-11T14:05:04.988-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Latex'/><category scheme='http://www.blogger.com/atom/ns#' term='TikZ'/><title type='text'>Make a standalone plot using TikZ</title><content type='html'>&lt;pre name="code" class="Latex"&gt;&lt;br /&gt;\documentclass{minimal}&lt;br /&gt;&lt;br /&gt;\usepackage{tikz}&lt;br /&gt;&lt;br /&gt;\usepackage[active,tightpage]{preview}&lt;br /&gt;\PreviewEnvironment{tikzpicture}&lt;br /&gt;\setlength\PreviewBorder{5pt}%&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;\begin{document}&lt;br /&gt;&lt;br /&gt;\begin{tikzpicture}[scale=1.6]&lt;br /&gt;    \draw[-&gt;] (0,0) -- (4,0) coordinate (x axis);&lt;br /&gt;    \draw[-&gt;] (0,0) -- (0,3.5) coordinate (y axis);&lt;br /&gt;  \shadedraw [shading=axis,shading angle=90, left color=blue!70,right color=blue!30, draw=blue!50!black] (0.2,0) rectangle (3.8,3.3);&lt;br /&gt;    \shadedraw [shading=axis,shading angle=90] (0.6,0) rectangle (2.0,2.3);&lt;br /&gt; &lt;br /&gt; \node at(0.2,-0.2){{$20$}};&lt;br /&gt; \node at(0.6,-0.2){{$60$}};&lt;br /&gt; \node at(2.0, -0.2){{$600$}};&lt;br /&gt; \node at(3.8, -0.2){{$1400$}};&lt;br /&gt; \node at(4.5, 0){{$p_{T}$[GeV]}};&lt;br /&gt;&lt;br /&gt; \node at(-0.2, 2.3){{$2.8$}};&lt;br /&gt; \node at(-0.2, 3.3){{$4.4$}};&lt;br /&gt; \node at(-0.2, 3.7){{$|y|$}};&lt;br /&gt;&lt;br /&gt; %&lt;br /&gt; \node at(1.3, 1.3){{$17\,\,nb^{-1}$}};&lt;br /&gt; \node at(2.9, 2.6){{$40\,\,pb^{-1}$}};&lt;br /&gt;    \end{tikzpicture}&lt;br /&gt;&lt;br /&gt;\end{document}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-6889820332426555660?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/6889820332426555660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2011/02/make-standalone-plot-using-tikz.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6889820332426555660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6889820332426555660'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2011/02/make-standalone-plot-using-tikz.html' title='Make a standalone plot using TikZ'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-1102265387192967918</id><published>2011-02-09T04:02:00.001-08:00</published><updated>2011-02-09T04:44:53.073-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='GhostScript'/><title type='text'>Merge several EPS files to one file</title><content type='html'>&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;gs -sDEVICE=epswrite     -dNOPAUSE -dBATCH -dSAFER     -sOutputFile=merged.eps   *eps&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Merge EPS and convert EPS to PDF&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;gs -sDEVICE=pdfwrite     -dNOPAUSE -dBATCH -dSAFER     -sOutputFile=merged.pdf  *eps&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.linuxjournal.com/content/tech-tip-using-ghostscript-convert-and-combine-files"&gt;http://www.linuxjournal.com/content/tech-tip-using-ghostscript-convert-and-combine-files&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The best way to concert a bunch of eps file to a combined pdf file is,&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;for i in `ls *eps`&lt;br /&gt;do&lt;br /&gt;    ps2pdf -dEPSCrop ${i}&lt;br /&gt;done&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;gs -sDEVICE=pdfwrite     -dNOPAUSE -dBATCH -dSAFER     -sOutputFile=merged.pdf  *pdf&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-1102265387192967918?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/1102265387192967918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2011/02/merge-several-eps-files-to-one-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/1102265387192967918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/1102265387192967918'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2011/02/merge-several-eps-files-to-one-file.html' title='Merge several EPS files to one file'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-4181585491811553944</id><published>2010-09-26T01:58:00.000-07:00</published><updated>2010-09-26T02:21:28.118-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Latex'/><category scheme='http://www.blogger.com/atom/ns#' term='TikZ'/><title type='text'>How to update TikZ library</title><content type='html'>Sometime you need to update your TikZ library to contain new library files. Then you can do like this,&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Go to &lt;a href="http://www.texample.net/tikz/builds/"&gt;TikZ Build&lt;/a&gt; to find out the latest built version for TikZ.&lt;/li&gt;&lt;li&gt;Download the tar package and extract it to some temporary place.&lt;br /&gt;&lt;pre name="code" class="bash"&gt;&lt;br /&gt;ls pgfCVS2010-07-25_TDS.zip&lt;br /&gt;mkdir pgfInstallFile&lt;br /&gt;unzip pgfCVS2010-07-25_TDS.zip -d pgfInstallFile/&lt;br /&gt;doc/ tex/&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Go to &lt;span style="font-family: courier new;"&gt;/usr/share/texmf/tex/&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;You have to replace the old pgf package file with the new file. You can copy&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;cp -r $pgfInstallFile/tex/context/pgf/  /usr/share/texmf/tex/context/pgf/  ;&lt;br /&gt;cp -r $pgfInstallFile/tex/generic/pgf/  /usr/share/texmf/tex/generic/pgf/  ;&lt;br /&gt;cp -r $pgfInstallFile/tex/latex/pgf/    /usr/share/texmf/tex/latex/pgf/  ;&lt;br /&gt;cp -r $pgfInstallFile/tex/plain/pgf/    /usr/share/texmf/tex/plain/pgf/  ;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;After that, you can update the tex file configuration,&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;texhash ;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-4181585491811553944?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/4181585491811553944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2010/09/how-to-update-tikz-library.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/4181585491811553944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/4181585491811553944'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2010/09/how-to-update-tikz-library.html' title='How to update TikZ library'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-6848751101444464385</id><published>2010-07-22T06:41:00.000-07:00</published><updated>2010-07-22T06:45:22.248-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Beamer'/><category scheme='http://www.blogger.com/atom/ns#' term='Latex'/><title type='text'>Install a Latex style file on Linux</title><content type='html'>Take bbding as an example.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;$ wget http://www.tug.org/texlive/Contents/live/texmf-dist/tex/latex/bbding/bbding.sty # Get the style file from web site.&lt;br /&gt;$ mkdir /usr/share/texmf/tex/latex/bbding # Make a directory for bbding&lt;br /&gt;$ cp bbding.sty  /usr/share/texmf/tex/latex/bbding  # Copy bbding style file to this directory.&lt;br /&gt;$ texhash  # Update linux configuration&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-6848751101444464385?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/6848751101444464385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2010/07/install-latex-style-file-on-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6848751101444464385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6848751101444464385'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2010/07/install-latex-style-file-on-linux.html' title='Install a Latex style file on Linux'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-5336506691811634538</id><published>2010-03-21T04:51:00.000-07:00</published><updated>2010-03-21T04:55:39.338-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Latex'/><title type='text'>Tips for Latex usage</title><content type='html'>&lt;ol&gt;&lt;li&gt;&lt;a href="http://www.fauskes.net/nb/latextips/"&gt;Tips and tricks for Latex&lt;br /&gt;&lt;/a&gt;(TeX, LaTeX, BibTeX and friends, are a constant source of joy and     frustration. This growing collection of tips and tricks is an attempt to     document some of the things I have learned working with these wonderful     tools. This page is just one of many similar LaTeX tips and tricks pages on the net. Hopefully you'll find something useful   here.)&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-5336506691811634538?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/5336506691811634538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2010/03/tips-and-tricks-for-latex.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/5336506691811634538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/5336506691811634538'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2010/03/tips-and-tricks-for-latex.html' title='Tips for Latex usage'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-4588329333232911098</id><published>2010-03-08T08:56:00.000-08:00</published><updated>2010-03-16T07:02:27.872-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Cpp'/><title type='text'>How to prevent memory leak in C plusplus</title><content type='html'>&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;'delete' all variables defined by 'new'&lt;/span&gt;&lt;br /&gt;Unless you know what you are doing, you have to delete any variables which are defined by 'new'. so that you free the same memory you allocated.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;char* str = new char [30];&lt;br /&gt;delete [] str;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;Watch those pointer assignments&lt;br /&gt;&lt;span style="font-weight: normal;"&gt;Every dynamic variable (allocated memory on the heap) needs to be associated with a pointer. When a dynamic variable becomes disassociated from its pointer(s), it becomes impossible to erase. Again, this results in a memory leak&lt;/span&gt;.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;char* str1 = new char [30];&lt;br /&gt;char* str2 = new char [40];&lt;br /&gt;strcpy(str1, "Memory leak");&lt;br /&gt;str2 = str1; // Bad! Now the 40 bytes are impossible to free.&lt;br /&gt;delete [] str2; // This deletes the 30 bytes.&lt;br /&gt;delete [] str1; // Possible access violation.&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;Be careful with local pointers&lt;br /&gt;&lt;span style="font-weight: normal;"&gt;A pointer you declare in a function is allocated on the stack, but the dynamic variable it points to is allocated on the heap. If you don't delete it, it will persist after the program exits from the function&lt;/span&gt;.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;void Leak(int x){&lt;br /&gt;char* p = new char [x];&lt;br /&gt;// delete [] p; // Remove the first comment marking to correct.&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li style="font-weight: bold;"&gt;Pay attention to the square braces after "delete"&lt;br /&gt;&lt;span style="font-weight: normal;"&gt;Use "delete" by itself to free a single object. Use "delete" [] with square brackets to free a heap array. Don't do something like this&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;char* one = new char;&lt;br /&gt;delete [] one; // Wrong&lt;br /&gt;char* many = new char [30];&lt;br /&gt;delete many; // Wrong!&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-4588329333232911098?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/4588329333232911098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2010/03/how-to-prevent-memory-leak-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/4588329333232911098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/4588329333232911098'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2010/03/how-to-prevent-memory-leak-in-c.html' title='How to prevent memory leak in C plusplus'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-3864859079591894091</id><published>2010-03-08T07:51:00.000-08:00</published><updated>2010-10-15T06:18:21.107-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Cpp'/><title type='text'>Learning Cpp -- When to use 'new' -- Stack or Heap</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;br /&gt;Use new to define large large chunks of data&lt;span style="font-weight: normal;"&gt;More typically, you use new with larger chunks of data, such as arrays, strings, and structures. This is where new is useful. Suppose, for ample, you’re writing a program that might or might not need an array, ending on information given to the program while it is running. If you create an array by declaring it, the space is allocated when the program is compiled. Whether or not the program finally uses the array, the array is there, using up memory. Allocating the array during compile time is called static binding, meaning that the array is built in to the program at compile time. But with new, you can create an array during runtime if you need it and skip creating the array if you don’t need it.Or you can select an array size after the program is running. This is called dynamic binding, meaning that &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0); font-weight: normal;"&gt;the array is created while the program is running&lt;/span&gt;&lt;span style="font-weight: normal;"&gt;. Such an array is called a dynamic array. With static binding, you must specify the array size when you write the program. With dynamic binding, the program can decide on an array size while the program runs.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-3864859079591894091?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/3864859079591894091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2010/03/learning-c-plus-plus-some-tips.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/3864859079591894091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/3864859079591894091'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2010/03/learning-c-plus-plus-some-tips.html' title='Learning Cpp -- When to use &apos;new&apos; -- Stack or Heap'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-8301359357345277695</id><published>2010-03-04T14:51:00.000-08:00</published><updated>2010-03-05T00:54:37.776-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Emacs'/><title type='text'>use .emacs to configure emacs</title><content type='html'>My &lt;span style="font-weight: bold;"&gt;.emacs&lt;/span&gt; file&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;(setq frame-title-format&lt;br /&gt;     (concat  "%b - emacs@" (system-name)))&lt;br /&gt;&lt;br /&gt;;; default to unified diffs&lt;br /&gt;(setq diff-switches "-u")&lt;br /&gt;&lt;br /&gt;;; always end a file with a newline&lt;br /&gt;(setq require-final-newline nil)&lt;br /&gt;&lt;br /&gt;;;(put 'set-goal-column 'disabled nil)&lt;br /&gt;;; ====================&lt;br /&gt;(setq inhibit-default-init t)&lt;br /&gt;(setq inhibit-startup-message t)&lt;br /&gt;&lt;br /&gt;(custom-set-variables&lt;br /&gt; ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!&lt;br /&gt; ;; Your init file should contain only one such instance.&lt;br /&gt;'(auto-compression-mode t nil (jka-compr))&lt;br /&gt;'(case-fold-search t)&lt;br /&gt;'(current-language-environment "UTF-8")&lt;br /&gt;'(default-input-method "rfc1345")&lt;br /&gt;'(global-font-lock-mode t nil (font-lock)))&lt;br /&gt;&lt;br /&gt;(when window-system&lt;br /&gt;  ;; enable wheelmouse support by default&lt;br /&gt;  (mwheel-install)&lt;br /&gt;  ;; make switching frames works properly under the default click-to-focus&lt;br /&gt;  (setq focus-follows-mouse nil))&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-8301359357345277695?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/8301359357345277695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2010/03/use-emacs-to-configure-emacs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/8301359357345277695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/8301359357345277695'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2010/03/use-emacs-to-configure-emacs.html' title='use .emacs to configure emacs'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-1024003290028971505</id><published>2010-03-04T14:39:00.000-08:00</published><updated>2010-03-04T14:46:19.173-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Emacs'/><title type='text'>use Xdefaults to configure emacs</title><content type='html'>&lt;ul&gt;&lt;li&gt;Create a new .Xdefaults file in your home directory. This file can be used to configure your emacs.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;Emacs.Font: fontset-courier&lt;br /&gt;Emacs.Fontset-0:-*-courier-medium-r-normal-*-18-*-*-*-*-*-fontset-courier,\&lt;br /&gt;emacs.geometry:90x60+200+200&lt;br /&gt;emacsp.background:gray75&lt;br /&gt;&lt;br /&gt;Emacs.foreground:  gray&lt;br /&gt;Emacs.background:  black&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;Then you can do this to make it work. &lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;xrdb .Xdefaults&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-1024003290028971505?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/1024003290028971505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2010/03/use-xdefaults-configure-emacs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/1024003290028971505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/1024003290028971505'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2010/03/use-xdefaults-configure-emacs.html' title='use Xdefaults to configure emacs'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-7982626077883141278</id><published>2009-10-14T14:01:00.000-07:00</published><updated>2009-10-14T23:44:24.101-07:00</updated><title type='text'>How to add syntax highlighting to Blogger</title><content type='html'>For this topic, I have found some excellent bloggers.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html"&gt;Add syntax highlighting&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-7982626077883141278?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/7982626077883141278/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/10/how-to-add-syntax-highlighting-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/7982626077883141278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/7982626077883141278'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/10/how-to-add-syntax-highlighting-to.html' title='How to add syntax highlighting to Blogger'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-8130127083614733516</id><published>2009-08-25T02:54:00.000-07:00</published><updated>2009-10-07T02:24:48.937-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Cpp'/><title type='text'>gdb debugger introduction</title><content type='html'>&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Compile your program using debug&lt;/span&gt;. If you want to use gdb, you have to compile your code using '-g' flag. It will tell the compiler to store the debug information in object file. It describes the data type of each variable or function.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;g++ -g test.cxx -o test&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Run your program&lt;/span&gt;.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;gdb test&lt;br /&gt;&lt;/pre&gt;Quit your program.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;quit ;  or  Ctrl + D&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Set up break points&lt;/span&gt;.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;&gt; b 19  // break at line 19 at a file&lt;br /&gt;&gt; b func1 // break at func1&lt;br /&gt;&gt; b testClass::testFunc(int) //  C++ is polymorphic. you must tell break which version of the function you want to break on&lt;br /&gt;&gt; info breakpoints  // can print out all the break points&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Use backtrace&lt;/span&gt;.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;backtrace&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can see many frames related the point.&lt;br /&gt;&lt;pre name="code" class="Python"&gt;&lt;br /&gt;#0  std::string::assign (this=0xd3d704c, __str=@0xfd0d05)&lt;br /&gt;#1  0x00e4e524 in std::string::operator= (this=0xd3d704c, __str=@0xfd0d05)&lt;br /&gt;#2  0x065692d4 in IssueSeverity (this=0xd3d7048, rhs=@0xfd0d01)&lt;br /&gt;#3  0x0656831f in StatusCode::cloneSeverity (sev=0xfd0d01) at ../src/Lib/StatusCode.cpp:28&lt;br /&gt;#4  0x0317eb29 in StatusCode (this=0xbff07888, rhs=@0xbff077a4)&lt;br /&gt;#5  0xb7947250 in ?? ()&lt;br /&gt;#6  0xbff07888 in ?? ()&lt;br /&gt;#7  0xbff077a4 in ?? ()&lt;br /&gt;#8  0x00000000 in ?? ()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can take a look at the detail of one frame.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;frame 1&lt;br /&gt;info frame&lt;br /&gt;info locals&lt;br /&gt;info args&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;links&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://www.unknownroad.com/rtfm/gdbtut/gdbtoc.html"&gt;&lt;span style="font-family:Georgia,serif;"&gt;&lt;/span&gt;RMS's gdb Debugger Tutorial&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://sourceware.org/gdb/current/onlinedocs/gdb.html#SEC_Top"&gt;Debugging with GDB&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://valgrind.org/"&gt;Valgrind- memory management tool&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-8130127083614733516?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/8130127083614733516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/08/gdb-debugger.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/8130127083614733516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/8130127083614733516'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/08/gdb-debugger.html' title='gdb debugger introduction'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-3416351195024962939</id><published>2009-08-13T11:18:00.000-07:00</published><updated>2009-08-25T02:56:40.757-07:00</updated><title type='text'>Gmail : How to mark all the unread email to read</title><content type='html'>Maybe you have many emails you don't care. So you just want to mark these emails to read and don't want to read them. In Gmail, if you just click the button "unread" at the top of mail, it will just select the unread email in this page(less than 50 conversation). You have to go to next page to select unread and mark as read. That is not convenient. What you can do is to type"is:unread" in search email frame.&lt;br /&gt;&lt;br /&gt;Then you can see all the unread emails(not in one page). Now you can click "select All". In this case, you just select the unread emails in one page. Gmail will ask you whether you want to select all the unread emails. You choose yes. Then all your unread emails have been selected. The last step is click mark as read.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Type"is:unread" in search email frame.&lt;/li&gt;&lt;li&gt;Select All&lt;/li&gt;&lt;li&gt;Gmail will ask you whether you want to select all the unread emails. You choose yes.&lt;/li&gt;&lt;li&gt;Click "Mark as read".&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-3416351195024962939?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/3416351195024962939/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/08/how-to-mark-all-unread-email-to-read-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/3416351195024962939'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/3416351195024962939'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/08/how-to-mark-all-unread-email-to-read-in.html' title='Gmail : How to mark all the unread email to read'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-6143857141345168491</id><published>2009-08-10T15:16:00.001-07:00</published><updated>2009-08-13T11:33:53.988-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>xterm</title><content type='html'>If you use xmanager, maybe you need this setting to make your terminal look better.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;/usr/bin/X11/xterm   -bg black -fg gray  -fn  10x20   +cm +dc   -ls -display $DISPLAY&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-6143857141345168491?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/6143857141345168491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/08/xterm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6143857141345168491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6143857141345168491'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/08/xterm.html' title='xterm'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-2831621334485316163</id><published>2009-07-19T07:41:00.000-07:00</published><updated>2009-08-25T02:57:11.037-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Cpp'/><title type='text'>Cpp : My Test</title><content type='html'>&lt;span style="font-size:130%;"&gt;Integer &lt;/span&gt;&lt;br /&gt;If you use integer in C++, you should be careful. Because the integer width is limited. For example, an short int in Cpp is 16bits. An int is no shorter than short integer. A long integer is 32 bits.  I just do a test on i686 GNU/Linux.  Here is the result.&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;short  a ;&lt;br /&gt;&gt; a^14 = 16384&lt;br /&gt;&gt; a^15 = -32768&lt;br /&gt;&gt; a^16 = 0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;int  a ;&lt;br /&gt;&gt; a^30 = 1073741824&lt;br /&gt;&gt; a^31 = -2147483648&lt;br /&gt;&gt; a^32 = 0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;long a ;&lt;br /&gt;&gt; a^30 = 1073741824&lt;br /&gt;&gt; a^31 = -2147483648&lt;br /&gt;&gt; a^32 = 0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;unsigned short a ;&lt;br /&gt;&gt; a^14 = 16384&lt;br /&gt;&gt; a^15 = 32768&lt;br /&gt;&gt; a^16 = 0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;unsigned int a ;&lt;br /&gt;&gt; a^30 = 1073741824&lt;br /&gt;&gt; a^31 = 2147483648&lt;br /&gt;&gt; a^32 = 0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;unsigned long a ;&lt;br /&gt;&gt; a^30 = 1073741824&lt;br /&gt;&gt; a^31 = 2147483648&lt;br /&gt;&gt; a^32 = 0&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-2831621334485316163?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/2831621334485316163/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/07/cpp-my-test.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/2831621334485316163'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/2831621334485316163'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/07/cpp-my-test.html' title='Cpp : My Test'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-6272884021665207228</id><published>2009-05-12T08:21:00.000-07:00</published><updated>2009-05-12T09:20:04.459-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Cron on Linux</title><content type='html'>If you have many scripts running on a server machine(I have 6 scripts running on different machines). These scripts can be monitoring script or something important to the system. But sometime these script can crash due to some unknown reasons. At this time it's very dangerous to the system.  So setting up one mechanism to monitor the condition of these scripts is very important to the system and your work. The CRON job can do this job. CRON is part of Linux and can be used to run a script at some time you want.  You can use this to open the cron job setting.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;crontab -e&lt;br /&gt;&lt;/pre&gt;Add this to this file.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;*/5 * * * * /usr/local/bin/mcJobMonitor.py &gt;&gt; /dev/null&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If you want to know the meaning of this sentence, please go to &lt;a href="http://troy.jdmz.net/cron/"&gt;Cron on Linux&lt;/a&gt;.&lt;br /&gt;This  mcJobMonitor.py is&lt;br /&gt;&lt;pre name="code" class="Python"&gt;#!/usr/bin/python&lt;br /&gt;#//////////////////////////////////////////////////&lt;br /&gt;#  Haifeng Li&lt;br /&gt;#///////////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;import sys, os, time, commands, getopt&lt;br /&gt;&lt;br /&gt;def SendMailtoUser(ScriptName ):&lt;br /&gt;&lt;br /&gt;hostname = commands.getoutput("uname -n")&lt;br /&gt;timedate = commands.getoutput("date")&lt;br /&gt;pwd      = commands.getoutput("pwd")&lt;br /&gt;message = "Your script "+ScriptName+" in machine " +hostname+ " is dead.   \n"\&lt;br /&gt;         +"We have restarted this script. You can go to this machine to check the reason.  \n"&lt;br /&gt;email    = "xxxxxxx@gmail.com"&lt;br /&gt;command  ="".join(["echo \"", message, \&lt;br /&gt;                "\" | mail ", email, "  -s \"Cron Monitor for  ", ScriptName, "\""])&lt;br /&gt;os.system(command)&lt;br /&gt;&lt;br /&gt;if __name__=="__main__" :&lt;br /&gt;&lt;br /&gt;#________________________updatedatabase.py________________________________&lt;br /&gt;ScriptName = "/var/www/html/hpeng3/script/updatedatabase.py"&lt;br /&gt;status = commands.getoutput("ps -ef | grep 'updatedatabase.py' | grep -v grep")&lt;br /&gt;status = status.strip()&lt;br /&gt;if status == '' :&lt;br /&gt;   pushd     =  "pushd  /var/www/html/hpeng3/script"&lt;br /&gt;   restart   =  "./restart.sh"&lt;br /&gt;   popd      =  "popd"&lt;br /&gt;   command   = ";".join([pushd, restart, popd])&lt;br /&gt;   os.system(command)&lt;br /&gt;   SendMailtoUser(ScriptName )&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-6272884021665207228?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/6272884021665207228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/05/cron-on-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6272884021665207228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6272884021665207228'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/05/cron-on-linux.html' title='Cron on Linux'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-5003946448217850623</id><published>2009-05-04T09:59:00.001-07:00</published><updated>2009-05-04T10:00:12.396-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Latex'/><title type='text'>Beamer Usage</title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-5003946448217850623?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/5003946448217850623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/05/beamer-usage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/5003946448217850623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/5003946448217850623'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/05/beamer-usage.html' title='Beamer Usage'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-6975167908995106908</id><published>2009-04-20T01:53:00.000-07:00</published><updated>2009-04-20T05:11:58.072-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Initial process of Linux</title><content type='html'>Suppose you set up a sever or a administration machine, where there are many monitoring programs. If the machine reboots, then you have to restart all the programs manually. Maybe sometime you forget some processes. In that case, it's very danger to the system. So you should set up some initialization of Linux system. When the machine reboot, some processes will start automatically. This is what I have done.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;emacs -nw /etc/rc.d/rc.local&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You will see.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;#&lt;br /&gt;# This script will be executed *after* all the other init scripts.&lt;br /&gt;# You can put your own initialization stuff in here if you don't&lt;br /&gt;# want to do the full Sys V style init stuff.&lt;br /&gt;touch /var/lock/subsys/local&lt;br /&gt;/usr/sbin/ntpdate ntp1.cs.wisc.edu&lt;br /&gt;# define by Haifeng Li.  For the CHTC machine's jobs scanning&lt;br /&gt;/home/haifeng/chtcKillZombieJobs.py &amp;gt;&amp;gt /home/haifeng/chtcKillZombieJobs.log &amp;amp;&lt;br /&gt;# For the removing the old directory.&lt;br /&gt;/home/hpeng/chtcclean.py  &amp;gt;&amp;gt;  /home/hpeng/chtcclean.log &amp;amp;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;-----------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;a href="http://www.comptechdoc.org/os/linux/usersguide/linux_ugprocesses.html"&gt;&lt;span style="font-size:100%;"&gt;Linux Process Control&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://linux.chinaunix.net/techdoc/install/2008/07/16/1018213.shtml"&gt;Linux start scripts&lt;/a&gt;&lt;h1&gt;&lt;/h1&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-6975167908995106908?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/6975167908995106908/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/04/initial-process-of-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6975167908995106908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6975167908995106908'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/04/initial-process-of-linux.html' title='Initial process of Linux'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-6561197146943141446</id><published>2009-04-17T05:16:00.000-07:00</published><updated>2009-08-25T05:02:19.150-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Programming'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Cpp'/><title type='text'>Static library and dynamic library in Linux</title><content type='html'>A library is a package of code which can be used by other program. First, libraries are compiled. You don't have to compile them when you are using them. Second, because the complied libraries are in machine language, it can prevent other people to know the source code. This is important for business use. But it's not good for open source.&lt;br /&gt;-----------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;span style="font-size:130%;"&gt;What is library&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Actually, library is just a collection of header(C++) files or sub functions(maybe Fortran).&lt;br /&gt;&lt;br /&gt;There are two types library.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Static library&lt;/span&gt;(archive library). In linux, statics lib has a .a extension. When you compile a program using static library, the program will copy all the funcitonally to the program. So your executable file is very big.  One advantage of static library is the program does not have to find the lib when it's running. This is very convenient when you compile the code in one machine and run the program in another machine and you don't want to install the lib in that machine.&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Dynamic library&lt;/span&gt;(shared library).  Dynamic library has a .so extension in Linux. Dynamic lib will be linked when the program is running. So you don't have to copy all the libs to your executable file. That is a advantage. Because the library you are using may be very big(GB).  &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Generate library&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;To create a static library,&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;ar rcs my_library.a file1.o file2.o&lt;br /&gt;&lt;/pre&gt;  This command adds the objects files file1.o and file2.o to the static library.&lt;/li&gt;&lt;li&gt;Create a Shared library.  First , create the object files using the &lt;span style="color: rgb(0, 0, 153);"&gt;gcc -fPIC&lt;/span&gt; of &lt;span style="color: rgb(0, 0, 153);"&gt;-fpic&lt;/span&gt; flag. The -fPIC and -fpic option enable 'position independent code' generation.  Here is an example.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;gcc -fPIC -g -c -Wall a.c&lt;br /&gt;gcc -fPIC -g -c -Wall b.c&lt;br /&gt;gcc -shared -Wl,-soname,libmystuff.so.1  -o libmystuff.so.1.0.1 a.o b.o -lc&lt;br /&gt;&lt;/pre&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;-g &lt;/span&gt;means debugging information. &lt;span style="color: rgb(0, 0, 153);"&gt;-Wall&lt;/span&gt; will generate warnings. &lt;span style="color: rgb(0, 0, 153);"&gt;-c&lt;/span&gt; is compilation. &lt;/li&gt;&lt;/ol&gt;--------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Use Library&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;If you want to use the shared library, you have to tell the computer where the library is. Actually you have to how the Linux system to find lib.  &lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;Default shared lib directory. The default dir is /usr/lib, which means the system will first search the libs in /usr/lib. Then you have to run ldconfig. &lt;pre name="code" class="Bash"&gt;ldconfig -n directory_with_shared_libraries&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;You can use &lt;span style="color: rgb(0, 0, 153);"&gt;LD_LIBRARY_PATH&lt;/span&gt; to tell the system to find the shared libraries before the usual places. &lt;pre name="code" class="Bash"&gt;LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH  my_program&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;ldd can display the dependence of a shared library.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;ldd /usr/bin/mesg&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It will display&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt; libc.so.6 =&gt; /lib/tls/i686/cmov/libc.so.6 (0xb7eaf000)&lt;br /&gt;  /lib/ld-linux.so.2 =&gt; /lib/ld-linux.so.2 (0xb7feb000) &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;---------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;span style="font-size:130%;"&gt;My Makefile&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is a Makefile I am using.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;##################################&lt;br /&gt;# root variables&lt;br /&gt;ROOTCFLAGS   := $(shell root-config --cflags)&lt;br /&gt;ROOTLIBS     := $(shell root-config --libs) -lRooFit -lHtml -lCore -lCint -ldl -lTree \&lt;br /&gt;-lGpad -lGraf -lHist -lMatrix -lPostscript -lMinuit -lMinuit2 -lPhysics&lt;br /&gt;# Programs&lt;br /&gt;CXX          = g++&lt;br /&gt;F77          = f77&lt;br /&gt;CXXFLAGS     = -g -ggdb -Wall -fPIC -Wno-deprecated&lt;br /&gt;MY_CXXFLAGS  = -static&lt;br /&gt;LDFLAGS      = -g&lt;br /&gt;SOFLAGS      = -shared&lt;br /&gt;# do yourself a favor, use gcc for linking, and not ld&lt;br /&gt;LD           = CXX&lt;br /&gt;# local Includes&lt;br /&gt;INCDIR       = -Iinclude&lt;br /&gt;# Assign or Add variables&lt;br /&gt;CXXFLAGS    += $(ROOTCFLAGS)&lt;br /&gt;CXXFLAGS    += $(INCDIR)&lt;br /&gt;# Assigan or add variables&lt;br /&gt;LIBS        += $(ROOTLIBS)&lt;br /&gt;validation: src/validation.C clean&lt;br /&gt;$(CXX) $(CXXFLAGS) $(MY_CXXFLAGS) -c  src/validation.C -o lib/validation.o&lt;br /&gt;$(CXX) lib/validation.o -o bin/validation $(LDFLAGS) $(LIBS)&lt;br /&gt;clean:&lt;br /&gt;rm -rf bin/* lib/*&lt;br /&gt;&lt;/pre&gt;&lt;span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;$(shell root-config --libs) &lt;/span&gt; is &lt;/span&gt;a fantastic bash command.  When you run the executable file, this command will  be evaluated and will give the all the libs related to &lt;span style="color: rgb(0, 0, 102);"&gt;root&lt;/span&gt;(which is a analysis framework of high energy physic).  In my case, the result of this command is&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;-L/afs/cern.ch/sw/lcg/external/root/5.18.00/slc4_ia32_gcc34/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -pthread -lm -ldl -rdynamic&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;--------------------------------------------------------------------------------------------&lt;br /&gt;&lt;a href="http://www.dwheeler.com/program-library/Program-Library-HOWTO/x26.html"&gt;Program Library HOW TO&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.learncpp.com/cpp-tutorial/a1-static-and-dynamic-libraries/"&gt;Static and Dynamic Libraries &lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cublog.cn/u/17030/showart_337019.html"&gt;Analysis of static and shared library&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cppblog.com/jerysun0818/archive/2006/04/22/6065.html"&gt;Programming of static and shared library&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-6561197146943141446?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/6561197146943141446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/04/static-lib-and-dynamic-libraries-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6561197146943141446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/6561197146943141446'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/04/static-lib-and-dynamic-libraries-in.html' title='Static library and dynamic library in Linux'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-9097822563417645257</id><published>2009-04-16T12:57:00.000-07:00</published><updated>2009-04-18T03:38:31.789-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GhostScript'/><title type='text'>Page Size in ps2pdf</title><content type='html'>ps2pdf is a linux tool, which can convert ps(or eps) file to pdf file.  If you convert a ps file to a pdf, the default page size is letter. Some time you want to get different size plots. You can use&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;ps2pdf  -dEPSCrop  jet.eps&lt;br /&gt;&lt;/pre&gt;Or you can use &lt;span style="font-family:georgia;"&gt;epstopdf&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;epstopdf muonDetail.eps&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This command is working only for eps file, which has a bounding box. If you open a ps file, you can see the&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;%!PS-Adobe-2.0 EPSF-2.0&lt;br /&gt;%%BoundingBox:  0 0 567 552&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;There is no bounding box in ps file. So you can not get the special size pdf file from a ps file.&lt;br /&gt;&lt;br /&gt;You also can use ps2eps to convert ps file to eps. This program will calculate the boundary box for ps file and generate new eps file with a boundary box.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;ps2eps electron.ps&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr align="left" color="#c8c8c8" size="1" width="80%"&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://pages.cs.wisc.edu/%7Eghost/doc/cvs/Ps2pdf.htm"&gt;&lt;span style="font-size:100%;"&gt;PostScript-to-PDF converter&lt;/span&gt;&lt;/a&gt;&lt;h1 style="font-weight: normal;"&gt;&lt;/h1&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-9097822563417645257?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/9097822563417645257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/04/page-size-in-ps2pdf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/9097822563417645257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/9097822563417645257'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/04/page-size-in-ps2pdf.html' title='Page Size in ps2pdf'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-7025312455757342405</id><published>2009-04-14T12:31:00.000-07:00</published><updated>2009-04-23T04:38:13.697-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><category scheme='http://www.blogger.com/atom/ns#' term='Image'/><title type='text'>Image manipulation using Python</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1f1iVhfBjKs/SfBTIH9ZZSI/AAAAAAAAAjk/bpS0rWm1Guc/s1600-h/476px-Python_logo.svg.png"&gt;&lt;img style="cursor: pointer; width: 200px; height: 48px;" src="http://4.bp.blogspot.com/_1f1iVhfBjKs/SfBTIH9ZZSI/AAAAAAAAAjk/bpS0rWm1Guc/s200/476px-Python_logo.svg.png" alt="" id="BLOGGER_PHOTO_ID_5327849758219920674" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can use Python Image model to manipulate the image. It's interesting because you know that many pixels compose a picture. And the pixels are in different mode. For example, RGB.  This is a python script which can print a new image.&lt;br /&gt;&lt;pre name="code" class="Python"&gt;&lt;br /&gt;#!/usr/bin/python&lt;br /&gt;&lt;br /&gt;import sys&lt;br /&gt;import Image, ImageDraw&lt;br /&gt;&lt;br /&gt;newpic = Image.new("RGB", (300,300), color=(255,255,255))&lt;br /&gt;&lt;br /&gt;xsize, ysize = newpic.size&lt;br /&gt;&lt;br /&gt;for x in xrange(xsize) :&lt;br /&gt;for y in xrange(ysize) :&lt;br /&gt;newpic.putpixel((x,y), (int(255*(y/ysize)), int(255*x*y/(xsize*ysize)), int(255*(x/xsize))))&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;newpic.show()&lt;br /&gt;newpic.save("gen.jpg", "JPEG")&lt;br /&gt;&lt;/pre&gt;This is the picture we get.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1f1iVhfBjKs/SeTneVk9X7I/AAAAAAAAAfY/1rI90Iq11Mw/s1600-h/gen.jpg"&gt;&lt;img style="cursor: pointer; width: 200px; height: 200px;" src="http://1.bp.blogspot.com/_1f1iVhfBjKs/SeTneVk9X7I/AAAAAAAAAfY/1rI90Iq11Mw/s200/gen.jpg" alt="" id="BLOGGER_PHOTO_ID_5324635167833022386" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-7025312455757342405?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/7025312455757342405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/04/image-manipulation-using-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/7025312455757342405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/7025312455757342405'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/04/image-manipulation-using-python.html' title='Image manipulation using Python'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1f1iVhfBjKs/SfBTIH9ZZSI/AAAAAAAAAjk/bpS0rWm1Guc/s72-c/476px-Python_logo.svg.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-3394650972719060777</id><published>2009-04-08T07:05:00.000-07:00</published><updated>2010-10-06T04:09:12.615-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Bash'/><title type='text'>Tips for Bash</title><content type='html'>Bash is a kind of script language. It's not too formatted. But it's the language used by Linux system. So it's the most direct operation command for Linux. Other script languages, for example, python, perl, have to use bash sometimes. In my mind, if you want to write several lines script to finish your work, BASH is the best choice.  I just write down something, which is used by myself when I am working.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;tar. &lt;pre name="code" class="Bash"&gt; tar -cvzf filename.tgz filename&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;untar.  &lt;pre name="code" class="Bash"&gt; tar xvzf filename.tgz&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;check the space of some directorie. &lt;pre name="code" class="Bash"&gt;du -h --max-depth=1&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;process control.&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;for each in `ps -ef | grep ” | grep -v PID | awk ‘{ print $3 }’`;&lt;br /&gt;do&lt;br /&gt;for every in `ps -ef | grep $each | grep -v cron | awk ‘{ print $2 }’`;&lt;br /&gt;do kill -9 $every;&lt;br /&gt;done;&lt;br /&gt;done&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;sed. This command will look at the text in 2.txt and substitute the 'new2' to 'CERN'. The new text will be stored in 2.txt.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;sed  -i 's/new2/CERN/g' 2.txt&lt;br /&gt;&lt;/pre&gt;If you use &lt;pre name="code" class="Bash"&gt;sed  -e 's/new2/CERN/g' 2.txt&lt;/pre&gt;This command will just substitute the string, print the new text in monitor and will not be stored in file.&lt;br /&gt;You also can use &lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;line="x1.root y1.root x2.root y2.root" &lt;br /&gt;echo $line | sed  's/y[1-9].root//g'&lt;br /&gt;x1.root  x2.root&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;find.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;find ./work/   -mindepth 2 -maxdepth 2 | xargs chmod 744&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;awk. I don't recommend people to use this awk to get some system information, like the example. Because it's not a good programming way.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;ps -ef  | grep gnome |  grep -v grep   | awk '{print $7}'&lt;br /&gt;ps -ef | grep "slot"  | awk '{print $7}' | sed -e 's/-.*//g'  | grep -v ":"&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;refresh the desktop&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;killall nautilus&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-3394650972719060777?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/3394650972719060777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/04/tips-for-bash.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/3394650972719060777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/3394650972719060777'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/04/tips-for-bash.html' title='Tips for Bash'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-7361713991693937161</id><published>2009-04-06T06:31:00.001-07:00</published><updated>2010-03-21T05:19:15.442-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GhostScript'/><title type='text'>PS to image.</title><content type='html'>ps to png&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;gs -sDEVICE=png256 -o muon03.png -r800 -dBATCH -dNOPAUS muon.ps&lt;br /&gt;gs -sDEVICE=png256 -sOutputFile=muon03.png -r800 -dNOPAUSE    muon.ps -c quit&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;eps to png&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;gs -sDEVICE=png256 -dEPSCrop -sOutputFile=output.png -r800 -dNOPAUSE input.eps -c quit&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;pdf to png&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;gs -sDEVICE=png256 -o muon03.png -r800 -dBATCH -dNOPAUS muon.pdf&lt;br /&gt;gs -sDEVICE=png256 -sOutputFile=muon03.png -r800 -dNOPAUSE    muon.pdf -c quit&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;One bash script to do that&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;for i in `ls *.ps`;&lt;br /&gt;do gs -sDEVICE=png256 -sOutputFile=${i//.ps/.png} -r600 -dNOPAUSE  ${i} -c quit;&lt;br /&gt;done&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can convert a eps to pdf like this.&lt;br /&gt;&lt;pre name="code" class="Bash"&gt;&lt;br /&gt;gs -dEPSCrop -sDEVICE=pdfwrite -sOutputFile=out.pdf -dNOPAUSE&lt;br /&gt;-dBATCH -dAutoRotatePages=/None -c .setpdfwrite -f input.eps&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;----------------------------------------------------------------------------------------------------------&lt;br /&gt;Links&lt;br /&gt;&lt;a href="http://pages.cs.wisc.edu/%7Eghost/doc/gnu/5.50/Use.htm"&gt;How to use Ghostscript&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://pages.cs.wisc.edu/%7Eghost/doc/cvs/Devices.htm"&gt;Details of Ghostscript output devices&lt;/a&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-7361713991693937161?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/7361713991693937161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/04/ps-to-image.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/7361713991693937161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/7361713991693937161'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/04/ps-to-image.html' title='PS to image.'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-221444109090489103</id><published>2009-04-05T08:20:00.000-07:00</published><updated>2009-04-09T09:49:46.770-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web Design'/><title type='text'>CSS centralize problem</title><content type='html'>It's very difficult to centralize the web page because IE and Firefox have different explanation of CSS code. I wrote  a very simple web page these days. But I found my web page is central in Firefox and can not be centralized in IE. We don't like IE. But somebody likes it. So it's better to make it work at IE too.&lt;br /&gt;&lt;br /&gt;At first I used one div container.&lt;br /&gt;&lt;pre name="code" class="Css"&gt;&lt;br /&gt;div.body{&lt;br /&gt;  width: 32cm;&lt;br /&gt;  float: center ;&lt;br /&gt;  margin: 0 auto ;&lt;br /&gt;  padding: 0px;&lt;br /&gt;  text-align: center;&lt;br /&gt;  border: 0px groove;&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This setting is working in Firefox because the "margin : 0 auto".  But IE can not know this setting. So I looked through the web to get some information. There is one method which is almost good.&lt;br /&gt;&lt;pre name="code" class="Css"&gt;&lt;br /&gt;div.body{&lt;br /&gt;position:absolute;&lt;br /&gt;top:50%;&lt;br /&gt;left:50%;&lt;br /&gt;margin-top:-240px;&lt;br /&gt;margin-left:-320px;&lt;br /&gt;width:640px;&lt;br /&gt;height:480px;&lt;br /&gt;background:#ECECEC;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Actually this is a good setting if you want to get a fixed width web page. But for my case, this is not very good because I don't want to get a fixed width but a unfixed width. I felt upset about the uncompatibility between IE and Firefox. Then I want to give up. Suddenly I got an idea when I was sitting in a meeting. My idea is this. &lt;span style="font-size:130%;"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;I use two containers. One of them has 100% width using the first method. Then I use a another container in the first container, which has 88% width.&lt;/span&gt;&lt;/span&gt; When I reload my web page, it looks great.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1f1iVhfBjKs/SdjrnxqpdGI/AAAAAAAAAfQ/uV_sqCuyMDM/s1600-h/search.jpg"&gt;&lt;img style="cursor: pointer; width: 200px; height: 127px;" src="http://3.bp.blogspot.com/_1f1iVhfBjKs/SdjrnxqpdGI/AAAAAAAAAfQ/uV_sqCuyMDM/s200/search.jpg" alt="" id="BLOGGER_PHOTO_ID_5321262028317881442" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-221444109090489103?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/221444109090489103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/04/css-middle-display.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/221444109090489103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/221444109090489103'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/04/css-middle-display.html' title='CSS centralize problem'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1f1iVhfBjKs/SdjrnxqpdGI/AAAAAAAAAfQ/uV_sqCuyMDM/s72-c/search.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-2218830114049409919</id><published>2009-03-31T02:26:00.000-07:00</published><updated>2009-04-17T07:20:16.232-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Emacs'/><title type='text'>Emacs Usage</title><content type='html'>&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;Emacs&lt;/span&gt; is the bese editor I have ever used. It's very good at speed and language format.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;.emacs setting&lt;/span&gt;&lt;span style="font-size:0;"&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;.emacs is a configure file for emacs. When emacs starts, it will run .emacs first. Usually .emacs is at ~/.emacs. Actually .emacs is something like LISP language.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;(setq inhibit-startup-message t) &lt;/span&gt;is used to shut down the welcome massage when you open emacs. its boring to see a welcome page every time you use emacs.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;t&lt;/span&gt; means true.&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;nil&lt;/span&gt; means false.&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;(setq-default make-backup-files nil) &lt;/span&gt;is used to shut down the backup automatically. But I recommend you open this function. &lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;(setq require-final-newline nil)&lt;/span&gt; will not require a new line in the end of file.&lt;/li&gt;&lt;li&gt;But sometime, (setq require-final-newline nil) does not work. Because /usr/share/emacs/site-lisp/default.el will run after .emacs. At this time, you should switch off the default.el by using &lt;span style="color: rgb(0, 0, 153);"&gt;(setq inhibit-default-init t). &lt;/span&gt;I spent plenty of time on this stupid new line query. Now I can shut it down. But you have to open one thing[7] in .emacs. &lt;span style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;div style="text-align: left;"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;(w&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;hen window-system&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;;; enable wheelmouse support by default&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;(mwheel-install)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;;; make switching frames works properly under the default click- to-focus&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;(setq focus-follows-mouse nil) )&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;span style="font-size:0;"&gt;&lt;span style="font-size:100%;"&gt;-----------------------------------------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;Find and Replace&lt;/span&gt;&lt;span style="font-size:0;"&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Find a string : &lt;span style="color: rgb(0, 0, 153);"&gt;C-s &lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Find backward : &lt;span style="color: rgb(0, 0, 153);"&gt;C-r&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Find forward : &lt;span style="color: rgb(0, 0, 153);"&gt;C-s&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;How to replace a string. &lt;span style="color: rgb(0, 0, 153);"&gt;M-x replace-string&lt;/span&gt;&lt;/li&gt;&lt;li&gt;How to do query replace. &lt;span style="color: rgb(0, 0, 153);"&gt;M-x query-replace.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;You also can do query replace by. &lt;span style="color: rgb(0, 0, 153);"&gt;M-% &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;----------------------------------------------------------------------------------------------------------&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Rectangular Operations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sometimes it's very convenient to use the rectangular selection in emacs. When you are learning how to do it, it's painful. But after you get it, it will save you much more time.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Select a rectangular area and copy(cut) it to another place&lt;/span&gt;. Go to the left-top of the rectangular you want to select. Hit &lt;span style="color: rgb(0, 0, 153);"&gt;C-space&lt;/span&gt;. Then this point is mark set. Then go to the right-bottom of your rectangular area, and click &lt;span style="color: rgb(0, 0, 153);"&gt;C-x r r&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 153);"&gt;C-x r k&lt;/span&gt; for cut) and &lt;span style="color: rgb(0, 0, 153);"&gt;Enter&lt;/span&gt;. This rectangular area has been copied to register. Move your cursor to the place where you want to put this area, and click &lt;span style="color: rgb(0, 0, 153);"&gt;C-x r i&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 153);"&gt;Enter&lt;/span&gt;. After click enter, the content in register will be copied to the new place.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Select a rectangular area and insert some strings&lt;/span&gt;. Hit &lt;span style="color: rgb(0, 0, 153);"&gt;C-space &lt;/span&gt;and click &lt;span style="color: rgb(0, 0, 153);"&gt;C-x r t &lt;/span&gt;and&lt;span style="color: rgb(0, 0, 153);"&gt; Enter&lt;/span&gt;. Then you will enter the text you want insert this area. After hit enter, you will see the text has been inserted.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="post hentry"&gt;&lt;a name="2055235708383968586"&gt;&lt;/a&gt;&lt;/div&gt;----------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Cursor Movement&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Move cursor to the beginning of a line : &lt;span style="color: rgb(0, 0, 153);"&gt;C-a&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Move cursor to the and of a line : &lt;span style="color: rgb(0, 0, 153);"&gt;C-e&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Move cursor to the beginning of this file: &lt;span style="color: rgb(0, 0, 153);"&gt;C-x [&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Move cursor to the end of this file: &lt;span style="color: rgb(0, 0, 153);"&gt;C-x ] &lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;----------------------------------------------------------------------------------------------------------&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Multi-Windows &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In emacs, you can split the window in to several windows.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;C-x 3&lt;/span&gt; will split the window in two columns.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;C-x 2&lt;/span&gt; will split the window horizontally. &lt;span style="font-size:0;"&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;C-x 0&lt;/span&gt; will shut down one window. &lt;/li&gt;&lt;li&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;C-x o&lt;/span&gt; will change the cursor between different windows.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;----------------------------------------------------------------------------------------------------------&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-size:100%;"&gt;Some very useful links&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://ted.is-programmer.com/categories/1598/posts"&gt;Ted's Blog for emacs&lt;/a&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://www.engr.uvic.ca/%7Edastone/emacs-keys.html"&gt;Emacs Keyboard Shortcuts&lt;/a&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;a href="http://jwadmin.blogspot.com/2008/10/emacs-example-tutorial-insert-block-of.html"&gt;JW's Tips and Notes: Emacs Example Tutorial: insert a block of text&lt;/a&gt;&lt;br /&gt;&lt;a href="http://emacs-fu.blogspot.com/2008/12/working-with-rectangular-selections.html"&gt;emacs-fu: working with rectangular selections&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;&lt;br /&gt;&lt;/h1&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-2218830114049409919?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/2218830114049409919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/03/emacs-usage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/2218830114049409919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/2218830114049409919'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/03/emacs-usage.html' title='Emacs Usage'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-4893089729872120543</id><published>2009-03-24T03:12:00.000-07:00</published><updated>2009-04-23T04:36:24.496-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Python'/><title type='text'>A Python function which can combine a list to a string</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_1f1iVhfBjKs/SfBSsKdycZI/AAAAAAAAAjc/MOfpoo2kR-M/s1600-h/476px-Python_logo.svg.png"&gt;&lt;img style="cursor: pointer; width: 200px; height: 48px;" src="http://1.bp.blogspot.com/_1f1iVhfBjKs/SfBSsKdycZI/AAAAAAAAAjc/MOfpoo2kR-M/s200/476px-Python_logo.svg.png" alt="" id="BLOGGER_PHOTO_ID_5327849277856313746" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Sometime you can use str.split(".") to split a string to a list. It's very easy to operate on this list. But sometime you want to combine the list to a string again after the list operation. I just write a simple python function.&lt;br /&gt;&lt;br /&gt;ListName      :   the name of list which you want to combine&lt;br /&gt;StrInsert      :   the string which you want to insert to this list&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="Python"&gt;&lt;br /&gt;def combineStr( ListName , StrInsert  ):&lt;br /&gt;out_str = ListName[0]&lt;br /&gt;for item  in  range(1, len(ListName)):&lt;br /&gt;   out_str +=StrInsert+ListName[item]                                                       &lt;br /&gt;return out_str&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-4893089729872120543?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/4893089729872120543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/03/python-script.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/4893089729872120543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/4893089729872120543'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/03/python-script.html' title='A Python function which can combine a list to a string'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_1f1iVhfBjKs/SfBSsKdycZI/AAAAAAAAAjc/MOfpoo2kR-M/s72-c/476px-Python_logo.svg.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-140239075768918736</id><published>2009-03-23T10:00:00.001-07:00</published><updated>2009-04-17T11:30:43.929-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Image'/><title type='text'>How to take a screenshot in your computer</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1f1iVhfBjKs/ScfNRW6hLHI/AAAAAAAAAcU/8GWND3aoUSM/s1600-h/Screenshot-GIMP.png"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 114px; height: 400px;" src="http://4.bp.blogspot.com/_1f1iVhfBjKs/ScfNRW6hLHI/AAAAAAAAAcU/8GWND3aoUSM/s400/Screenshot-GIMP.png" alt="" id="BLOGGER_PHOTO_ID_5316443583226653810" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:130%;"&gt;Using GIMP&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;To take a screen&lt;/span&gt;&lt;span style="font-size:85%;"&gt;shot with the GIMP, find the following menu option: &lt;strong&gt;File —&gt; Acquire —&gt; Screen Shot&lt;/strong&gt;. You will then be offered some options for the screenshot such as length of delay and whether you want to take a screenshot of the entire screen, or just a window.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;PrintScreen Button&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This method is easy. Put the button in you keyboard.  Normally, the &lt;span style="font-weight: bold;"&gt;PrintScrn &lt;/span&gt;is at&lt;/span&gt;&lt;span style="font-size:85%;"&gt; the right side of &lt;span style="font-weight: bold;"&gt;F12.  &lt;/span&gt;After you put this button, there will be one window to ask you how to store this picture.&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1f1iVhfBjKs/ScfXr8KO-UI/AAAAAAAAAdo/ltlMMX-5zmw/s1600-h/Screenshot-Save+Screenshot.png"&gt;&lt;img style="cursor: pointer; width: 320px; height: 146px;" src="http://3.bp.blogspot.com/_1f1iVhfBjKs/ScfXr8KO-UI/AAAAAAAAAdo/ltlMMX-5zmw/s320/Screenshot-Save+Screenshot.png" alt="" id="BLOGGER_PHOTO_ID_5316455035017558338" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:130%;"&gt;Use Ubuntu(GNOME)&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;You can open &lt;span style="font-weight: bold;"&gt;Applications-&gt;Accessories-&gt;Take Screenshot&lt;/span&gt;.&lt;br /&gt;You will see a window which can help you to take a screenshot.&lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-140239075768918736?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/140239075768918736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/03/how-to-take-screenshot-in-your-computer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/140239075768918736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/140239075768918736'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/03/how-to-take-screenshot-in-your-computer.html' title='How to take a screenshot in your computer'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1f1iVhfBjKs/ScfNRW6hLHI/AAAAAAAAAcU/8GWND3aoUSM/s72-c/Screenshot-GIMP.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-5325645348059372910</id><published>2009-03-23T09:44:00.001-07:00</published><updated>2010-03-09T05:38:30.530-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google'/><title type='text'>How to add a public calendar to Google Calendar</title><content type='html'>If you need to print out the meeting schedule, you can just add the public calendar of the meeting to Google Calendar.  Google Calender will update the time schedule automatically and I don't need to worry about whether the schedule is the latest.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;First you should get the link of the public calender. For example, &lt;span style="font-family:trebuchet ms;"&gt;http://indico.cern.ch/categoryDisplay.py/ical?categId=3l94 &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family:trebuchet ms;"&gt;Then you can go to your google calender.&lt;/span&gt;Click the &lt;span style="font-weight: bold;"&gt;Add-&gt;Add by &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;URL.  &lt;/span&gt;Then you can type the link of you calendar.  Enjoy your own calendar.&lt;/li&gt;&lt;/ol&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_1f1iVhfBjKs/ScflvMPVEDI/AAAAAAAAAdw/4PK72K-OPdQ/s1600-h/googleCa.png"&gt;&lt;img style="cursor: pointer; width: 249px; height: 189px;" src="http://3.bp.blogspot.com/_1f1iVhfBjKs/ScflvMPVEDI/AAAAAAAAAdw/4PK72K-OPdQ/s320/googleCa.png" alt="" id="BLOGGER_PHOTO_ID_5316470484036292658" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I have tested the update rate of Google calender. Normally, it will be updated every 24 hours.&lt;br /&gt;&lt;br /&gt;If you are familiar with &lt;a href="http://www.python.org/doc/current/tutorial/"&gt;Python&lt;/a&gt; script, you can also use the &lt;a href="http://code.google.com/p/gcalcli/"&gt;gcalcli&lt;/a&gt;.&lt;br /&gt;gcalcli can connect with google calendar by python. First you can get the public calendar by '&lt;span style="font-weight: bold;"&gt;wget&lt;/span&gt;'.  Then you can edit the calendar file and add these files in to google calendar by gcalcli. It's powerful and useful. But in my case, the first method is enough. So I did't dig out  the second method.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-5325645348059372910?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/5325645348059372910/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/03/how-to-add-public-calendar-to-google.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/5325645348059372910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/5325645348059372910'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/03/how-to-add-public-calendar-to-google.html' title='How to add a public calendar to Google Calendar'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_1f1iVhfBjKs/ScflvMPVEDI/AAAAAAAAAdw/4PK72K-OPdQ/s72-c/googleCa.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6273406038634066436.post-2033336108172133168</id><published>2009-03-23T09:36:00.000-07:00</published><updated>2009-03-24T09:14:12.251-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google'/><title type='text'>Delete the contents of your search toolbar</title><content type='html'>Sometime if you are using a public computer, you maybe want to delete  the search record of your google toolbar.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_1f1iVhfBjKs/Scf07sU0QrI/AAAAAAAAAd4/mJqUviDO32o/s1600-h/clear.png"&gt;&lt;img style="cursor: pointer; width: 200px; height: 194px;" src="http://4.bp.blogspot.com/_1f1iVhfBjKs/Scf07sU0QrI/AAAAAAAAAd4/mJqUviDO32o/s200/clear.png" alt="" id="BLOGGER_PHOTO_ID_5316487191482090162" border="0" /&gt;&lt;/a&gt;&lt;ul&gt;&lt;li&gt; If you are using firefox,you can open&lt;span style="font-weight: bold;"&gt;Edit-&gt;Preferences-&gt;Privacy-&gt;Clear Now&lt;/span&gt;.&lt;/li&gt;&lt;/ul&gt; &lt;ul&gt;&lt;li&gt;You also can delete the contents directly. You just click the contents of search bar and &lt;span style="font-weight: bold;"&gt;shift+delete&lt;/span&gt;. &lt;/li&gt;&lt;/ul&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_1f1iVhfBjKs/Scf3Ap1SnYI/AAAAAAAAAeA/cVCzpxXgPIQ/s1600-h/newde.png"&gt;&lt;img style="cursor: pointer; width: 200px; height: 143px;" src="http://2.bp.blogspot.com/_1f1iVhfBjKs/Scf3Ap1SnYI/AAAAAAAAAeA/cVCzpxXgPIQ/s200/newde.png" alt="" id="BLOGGER_PHOTO_ID_5316489475735592322" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I like the second way. It's more easier and quick.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6273406038634066436-2033336108172133168?l=haifenghep.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://haifenghep.blogspot.com/feeds/2033336108172133168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://haifenghep.blogspot.com/2009/03/delete-contents-of-your-search-toolbar.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/2033336108172133168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6273406038634066436/posts/default/2033336108172133168'/><link rel='alternate' type='text/html' href='http://haifenghep.blogspot.com/2009/03/delete-contents-of-your-search-toolbar.html' title='Delete the contents of your search toolbar'/><author><name>Haifeng's Technical Blog</name><uri>http://www.blogger.com/profile/11167414017598391258</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://lh5.ggpht.com/_1f1iVhfBjKs/Sce4kYLUbRI/AAAAAAAAAbg/C4OhDhtZSQU/00.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_1f1iVhfBjKs/Scf07sU0QrI/AAAAAAAAAd4/mJqUviDO32o/s72-c/clear.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
