<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Xitong Liu Blog</title>
 <link href="http://xliu.org/atom.xml" rel="self"/>
 <link href="http://xliu.org"/>
 <updated>2012-01-18T15:10:09-05:00</updated>
 <id>http://xliu.org</id>
 <author>
   <name>Xitong Liu</name>
   <email>me@xliu.org</email>
 </author>

 
 <entry>
   <title>Xitong Liu in Google Suggestion</title>
   <link href="http://xliu.org/blog/2010/06/xitongliu-google.html"/>
   <updated>2010-06-24T00:00:00-04:00</updated>
   <id>http://xliu.org/blog/2010/06/xitongliu-google.html</id>
   <content type="html">&lt;h1&gt;Xitong Liu in Google Suggestion&lt;/h1&gt;
&lt;p class=&quot;meta&quot;&gt;June 14 2010 &amp;#8211; Newark&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s amazing that I found my name appeared in the 1st place of Google Suggestion on Google&amp;#8217;s homepage when you just type &amp;#8220;Xito&amp;#8221;. Here is the screenshot.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/blog/static/2010/xitongliu-google-search.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;To make it&amp;#8217;s clear that that&amp;#8217;s not provided by Google personalized search based on user&amp;#8217;s search history or cookies, I tested it on a new Google Chrome&amp;#8217;s incognito window&lt;sup class=&quot;footnote&quot;&gt;&lt;a href=&quot;#fn1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; which means I&amp;#8217;m not a signed-in user and there is no cookies neither.&lt;/p&gt;
&lt;p&gt;As Google Suggestion comes from the queries which have a certain high search volume, I guess it&amp;#8217;s the same for my name. I&amp;#8217;ve made a deep study about it, and found that a lot of results come from webpages which have high occurrence of term &amp;#8220;xitong&amp;#8221; and &amp;#8220;liu&amp;#8221; since the ranking of webpages are based on a TF-&lt;span class=&quot;caps&quot;&gt;IDF&lt;/span&gt; measure&lt;sup class=&quot;footnote&quot;&gt;&lt;a href=&quot;#fn2&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. To be specific, these webpages are talking about the notorious Chinese politician Chen Xitong&lt;sup class=&quot;footnote&quot;&gt;&lt;a href=&quot;#fn3&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m always embarrassed when tell my name to unfamiliar people, since most of them will mention Chen. The pronunciation of Chen&amp;#8217;s first name is the same as mine in Chinese, but the first character differs. For Chen&amp;#8217;s, it&amp;#8217;s 希同 while for mine it&amp;#8217;s 熙同. The meaning of these two characters are totally different. Essentially, my name was given by my father without any relevance to Chen, since 熙 was a character widely used in person&amp;#8217;s name in China, Japan and Korea.&lt;/p&gt;
&lt;p&gt;Fortunately, the webpages in the first page of of the search results for my name are almost relevant to me. Thanks to the modern ranking algorithm, otherwise I&amp;#8217;ll be messed up with Chen again. You can try it out: &lt;a href=&quot;http://www.google.com/search?q=xitong+liu&quot;&gt;Xitong Liu on Google&lt;/a&gt; .&lt;/p&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;p class=&quot;footnote&quot; id=&quot;fn1&quot;&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;a href=&quot;http://www.google.com/support/chrome/bin/answer.py?answer=95464&quot;&gt;Google Chrome Incognito mode&lt;/a&gt;, in which there is no initial cookies and all new cookies are deleted after you close all incognito windows that you&amp;#8217;ve opened. It&amp;#8217;s equivalent to &amp;#8220;private browsing&amp;#8221; in the terminology of other browsers.&lt;/p&gt;
&lt;p class=&quot;footnote&quot; id=&quot;fn2&quot;&gt;&lt;sup&gt;2&lt;/sup&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/Tf–idf&quot;&gt;TF-&lt;span class=&quot;caps&quot;&gt;IDF&lt;/span&gt;&lt;/a&gt; The tf–idf weight (term frequency–inverse document frequency) is a weight often used in information retrieval and text mining. This weight is a statistical measure used to evaluate how important a word is to a document in a collection or corpus. Variations of the tf–idf weighting scheme are often used by search engines as a central tool in scoring and ranking a document&amp;#8217;s relevance given a user query.&lt;/p&gt;
&lt;p class=&quot;footnote&quot; id=&quot;fn3&quot;&gt;&lt;sup&gt;3&lt;/sup&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/Chen_Xitong&quot;&gt;Chen Xitong&lt;/a&gt; (陳希同, born June 1930) was a member of the Politburo of the Communist Party of China and the Mayor of Beijing until he was removed from office on charges of corruption in 1995.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Safari 5, Apple's next generation browser</title>
   <link href="http://xliu.org/blog/2010/06/safari5.html"/>
   <updated>2010-06-11T00:00:00-04:00</updated>
   <id>http://xliu.org/blog/2010/06/safari5.html</id>
   <content type="html">&lt;h1&gt;Safari 5, Apple&amp;#8217;s next generation browser&lt;/h1&gt;
&lt;p class=&quot;meta&quot;&gt;June 11 2010 &amp;#8211; Newark&lt;/p&gt;
&lt;p&gt;Apple updated its browser Safari to version 5 on the first day of &lt;span class=&quot;caps&quot;&gt;WWDC&lt;/span&gt; 2010, both on Mac and Windows. In the war of browser recently, each update will draw dense attention all around the industry. So, what&amp;#8217;s new in Safari 5?&lt;/p&gt;
&lt;h2&gt;The return of progress bar&lt;/h2&gt;
&lt;p&gt;One of Safari&amp;#8217;s most famous and elegant innovation is the integration of progress bar and address bar, and it&amp;#8217;s ported to Safari mobile on iPhone OS (which has been renamed as iOS). I don&amp;#8217;t know why the progress bar was replaced by a meaningless loading box in Safari 4. For a large webpage under slow connection, it&amp;#8217;s unclear what&amp;#8217;s going on when loading the webpage. Fortunately, the missing feature is restored in Safari 5.&lt;/p&gt;
&lt;h2&gt;Better HTML5 support&lt;/h2&gt;
&lt;p&gt;HTML5 is a hot topic in the recent years. All the browser vendors are try their best to add support for HTML5. Safari 5 add many a dozen new HTML5 features, including better video support, geo-location, WebSocket, etc. Apple has created a &lt;a href=&quot;http://www.apple.com/html5/&quot;&gt;library&lt;/a&gt; to show the most fancy features of HTML5, most of them are built on webkit&amp;#8217;s proprietary CSS3 properties, e.g. &lt;code&gt;-webkit-transform&lt;/code&gt;, &lt;code&gt;-webkit-gradient&lt;/code&gt;. Unfortunately, it has opted out the support of other browsers, including Google Chrome which was also built on webkit. Intuitively, Apple want to show that Safari can survive without Adobe&amp;#8217;s flash.&lt;/p&gt;
&lt;h2&gt;Fix of quirk tab behavior&lt;/h2&gt;
&lt;p&gt;Most new Mac users may feel unacceptable about the quirk tab behavior of Safari, as the links are always open in new window by default. If you want to open new link in new tab, only  ⌘ + Click may work. Many third party plugins can make Safari&amp;#8217;s tab behave the same as Firefox or Chrome, but it may slow down Safari or even make Safari crash-prone. Safari 5 saves us from pressing  ⌘ when opening links in new tab by providing new option regarding tab behavior.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/blog/static/2010/safari-new-tab-option.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Faster than ever before&lt;/h2&gt;
&lt;p&gt;It&amp;#8217;s awesome! Apple advertises that with the help of its latest javascript bytecode engine: Nitro, Safari can run faster even faster than the V8 engine in the latest Google Chrome 6. I have tried to validate Apple&amp;#8217;s declaration by running the SunSpider&lt;sup class=&quot;footnote&quot;&gt;&lt;a href=&quot;#fn1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; benchmark both on Safari 5 and Chrome 6. The test platform is &lt;span class=&quot;caps&quot;&gt;MBP&lt;/span&gt; 13 inch, 2.26 GHz Intel Core Due 2, 2 GB memory. The final score of Safari 5 is 358.2ms, and that of Chrome 6 is 362.8ms, which kept consistent with Apple&amp;#8217;s declaration that Nitro is 3 percent faster than V8. Hopefully, V8 may surpass Safari 5 again in the next release.&lt;/p&gt;
&lt;h2&gt;Safari Reader&lt;/h2&gt;
&lt;p&gt;I think this is the most exciting new feature of Safari 5. Currently people read more and more news articles online. However, almost all the news article webpages are filled with annoying advertisements which may distract users from reading news. What&amp;#8217;s more, most long news articles are paginated into several parts, and users have to click next page again and again when the current page is finished. It&amp;#8217;s both time and bandwidth consuming. With the help of Safari Reader, the news articles can be extracted and reformatted into a more readable page. Also, for paginated articles, if you open Safari Reader on the first page, the following parts of the article will be loaded automatically to be represented in a continuous, clutter-free view when you scrolling down to the formatted page, which will save a lot of time.&lt;/p&gt;
&lt;p&gt;To launch Safari Reader, press &lt;code&gt;Shift + Cmd + R&lt;/code&gt; or click the Reader icon in the right side of address bar when it&amp;#8217;s available. Safari will detect whether the current page only contains a single article and show the Reader icon automatically. It works well on most website, both on famous English news media like NYTimes or Chinese news media like &lt;span class=&quot;caps&quot;&gt;SINA&lt;/span&gt;, as well as common website such as my blog. According to some reference, it&amp;#8217;s based on &lt;a href=&quot;http://lab.arc90.com/experiments/readability/&quot;&gt;Arc90 Lab&amp;#8217;s Readability&lt;/a&gt; project which is opensourced under Apache License.&lt;/p&gt;
&lt;p&gt;Basically I think it works by matching the only container in which there are several &lt;code&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/code&gt; elements above a threshold (say, more than 5 paragraphs in the container). Once matched, the paragraphs are extracted and reformatted into a clear way (black text with white background in elegant font). With Apple&amp;#8217;s gorgeous font sub-pixel smoothing rendering technology, reading in Safari Reader is kind of enjoyment. A friend of mine said that he had seen a demonstration of Microsoft Research&amp;#8217;s new technology which is based on browser vision detection. It works by dividing the page into several rectangles and extracting the content in the target rectangle which the user may concentrate on. I think the time complexity of Microsoft&amp;#8217;s solution is much higher than that of Readability and currently it&amp;#8217;s not applicable in commercial browsers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/blog/static/2010/safari-reader.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;p class=&quot;footnote&quot; id=&quot;fn1&quot;&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;a href=&quot;http://www2.webkit.org/perf/sunspider-0.9/sunspider.html&quot;&gt;SunSpider&lt;/a&gt;, a JavaScript benchmark. This benchmark tests the core JavaScript language only, not the &lt;span class=&quot;caps&quot;&gt;DOM&lt;/span&gt; or other browser APIs. It is designed to compare different versions of the same browser, and different browsers to each other.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>How to make SSH work faster?</title>
   <link href="http://xliu.org/blog/2010/05/faster-ssh.html"/>
   <updated>2010-05-03T00:00:00-04:00</updated>
   <id>http://xliu.org/blog/2010/05/faster-ssh.html</id>
   <content type="html">&lt;h1&gt;How to make &lt;span class=&quot;caps&quot;&gt;SSH&lt;/span&gt; work faster?&lt;/h1&gt;
&lt;p class=&quot;meta&quot;&gt;May 3 2010 &amp;#8211; Newark&lt;/p&gt;
&lt;p&gt;You may be working on &lt;span class=&quot;caps&quot;&gt;SSH&lt;/span&gt; everyday, logining in and out, switching remote machines, change work locations (if you are working on a laptop), over and over. Each time you login into a machine, you have to wait for the command prompt for several seconds, input user name and password and kick yourself into the shell finally. Don&amp;#8217;t you thinking it&amp;#8217;s too time consuming to repeat the same actions? For me, I can not bear inputing the same password everyday. Here are some tricks to boost your productivity when working with &lt;span class=&quot;caps&quot;&gt;SSH&lt;/span&gt;.&lt;/p&gt;
&lt;h2&gt;Auto Login&lt;/h2&gt;
&lt;p&gt;OpenSSH has a great feature &amp;#8220;key-based authorization&amp;#8221; which uses &lt;span class=&quot;caps&quot;&gt;RSA&lt;/span&gt;/&lt;span class=&quot;caps&quot;&gt;DSA&lt;/span&gt; key pair to do authorization instead of password. With the help of it, login can be done automatically.&lt;/p&gt;
&lt;p&gt;Here are the steps:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Create ssh key pair, if you have&amp;#8217;t one. Check &lt;code&gt; ~/.ssh&lt;/code&gt;. If you find a fine with name &lt;code&gt;id_dsa.pub&lt;/code&gt; or &lt;code&gt;id_rsa.pub&lt;/code&gt;, you are done since the key pair is ready to use. Otherwise, create it simply by typing &lt;code&gt;ssh-keygen&lt;/code&gt; and following the instructions. Keep in mind that there are two kinds of key pairs, &lt;span class=&quot;caps&quot;&gt;RSA&lt;/span&gt; or &lt;span class=&quot;caps&quot;&gt;DSA&lt;/span&gt;. I always use &lt;span class=&quot;caps&quot;&gt;RSA&lt;/span&gt;. You can choose one on your own. If you choose &lt;span class=&quot;caps&quot;&gt;RSA&lt;/span&gt; with other options as default, you will get &lt;code&gt;id_rsa&lt;/code&gt; and &lt;code&gt;id_rsa.pub&lt;/code&gt; in &lt;code&gt; ~/.ssh&lt;/code&gt;. The former file is the private key and latter one is the public key.&lt;/li&gt;
	&lt;li&gt;Make sure your &lt;code&gt;~/.ssh&lt;/code&gt; is private. I want to emphasize that here that the private key, i.e. &lt;code&gt;id_rsa&lt;/code&gt;, is the equivalent with your password since people who can access this file can login the remote machine easily as they got your password! So make it private first.&lt;br /&gt;
&lt;pre&gt;chmod 700 &amp;#126;/.ssh&lt;/pre&gt;&lt;/li&gt;
	&lt;li&gt;Transfer your public key to the remote machine which you want to login automatically. &lt;span class=&quot;caps&quot;&gt;SCP&lt;/span&gt; may be a preferred way:&lt;br /&gt;
&lt;pre&gt;scp &amp;#126;/.ssh/id_rsa.pub user@remote.machine.com:&amp;#126;/my_key.pub&lt;/pre&gt;&lt;/li&gt;
	&lt;li&gt;Append your public key to the &lt;code&gt;~/.ssh/authorized_keys&lt;/code&gt; on the remote machine.&lt;br /&gt;
&lt;pre&gt;cat my_key.pub &amp;gt;&amp;gt; &amp;#126;/.ssh/authorized_keys&lt;/pre&gt;&lt;/li&gt;
	&lt;li&gt;Done! Check whether you can login into the remote machine automatically by simply type &lt;br /&gt;
&lt;pre&gt;ssh user@remote.machine.com&lt;/pre&gt; on your local machine. If it works, remove the public key on the remote machine.&lt;/li&gt;
	&lt;li&gt;For geekers who&amp;#8217;d like to do it in one-line fashion, here it is:&lt;br /&gt;
&lt;pre&gt;cat &amp;#126;/.ssh/id_dsa.pub | ssh -l user remote.machine.com &amp;#8216;cat &amp;gt;&amp;gt; &amp;#126;/.ssh/authorized_keys&amp;#8217;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Even Faster&lt;/h2&gt;
&lt;p&gt;Even auto login is set up, in some cases you have to wait for several seconds before the shell prompt bombs out. Still frustrating, right? In some worse cases, you have wait more than 10 seconds or even longer! Why? Each time you connect a remote machine, sshd would like to use your IP address to apply reverse &lt;span class=&quot;caps&quot;&gt;DNS&lt;/span&gt; lookup to determine your hostname. If the &lt;span class=&quot;caps&quot;&gt;DNS&lt;/span&gt; server goes slow, it may take seconds to return the results. The longer the lookup takes, the longer you have to wait.&lt;/p&gt;
&lt;p&gt;Two tricks can be applied to solve this problem:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Edit &lt;code&gt;/etc/hosts&lt;/code&gt; on the remote machine and add the IP address of your local machine to it with an appropriate hostname. So if you login the system, your IP address is resolved locally, which is definitely faster.&lt;/li&gt;
	&lt;li&gt;Disable &lt;span class=&quot;caps&quot;&gt;DNS&lt;/span&gt; lookup on the remote machine. Edit &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; and add one line:&lt;br /&gt;
&lt;pre&gt;UseDNS no&lt;/pre&gt; Restart the sshd server then. If everything goes well, you will see the save of time.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Both tricks require root privilege. If do not have root access, ask your administrator to help you.&lt;/p&gt;
&lt;h2&gt;Troubleshooting&lt;/h2&gt;
&lt;p&gt;Use &lt;code&gt;ssh -v&lt;/code&gt; or &lt;code&gt;ssh -vvv&lt;/code&gt; to output debug information and diagnose the problem.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Hello World</title>
   <link href="http://xliu.org/blog/2007/07/hello-world.html"/>
   <updated>2007-07-31T00:00:00-04:00</updated>
   <id>http://xliu.org/blog/2007/07/hello-world.html</id>
   <content type="html">&lt;h1&gt;Hello World&lt;/h1&gt;
&lt;p class=&quot;meta&quot;&gt;31 Jul 2007 &amp;#8211; Wuhan&lt;/p&gt;
&lt;p&gt;Hello World.&lt;/p&gt;
&lt;p&gt;你好，世界！&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;c&quot;&gt;&lt;span class=&quot;cp&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Hello World!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</content>
 </entry>
 
 
</feed>
