<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>qingbo.blog</title><link>http://qingbo.net/blog/</link><description>Random thoughts about life and technologies</description><lastBuildDate>Sat, 19 May 2012 00:51:16 GMT</lastBuildDate><generator>PyRSS2Gen-1.0.0</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>警惕 Chrome 的查看源代码 (View Page Source) 功能</title><link>http://qingbo.net/blog/post603-beware-of-chrome-view-page-source.html</link><description>&lt;p&gt;前阵子解决一个问题的时候，差点以为是我们自己在 HTML 代码中输出的一段信息有问题，结果发现，Chrome 的 View Source Code 竟然会重新发送一个请求！&lt;/p&gt;
&lt;p&gt;有史以来，所有的浏览器从来没有过这样天才的设计。大家都是老老实实，既然你让我显示源代码，那我就直接给你把正在看的这个页面的源代码显示出来。没有人想过竟然可以重新发起一个请求，去拿“纯洁的”源代码。这是革命性的！Chrome 你做到了！&lt;/p&gt;
&lt;p&gt;早在2008年，就已经有人提出这个 bug - &lt;a class="new-window" href="http://code.google.com/p/chromium/issues/detail?id=523" target="_blank"&gt;View source forces page reload&lt;/a&gt;. 中间有人将之标记过 Fixed，但是世界末日快来了，Chrome 的稳定版本已经飚到18了，市场份额已经远超 Firefox 了，实际上这个 bug 仍然存在。我的天啊，究竟是什么样的设计，导致解决这样一个问题这么难？&lt;/p&gt;
&lt;p&gt;甚至还曾有开发者认为 View Source 就应该是这样的行为 (&lt;a class="new-window" href="http://code.google.com/p/chromium/issues/detail?id=4650" target="_blank"&gt;链接&lt;/a&gt;):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Yes, when you "view source", you're really opening a new tab that opens the page 
again and displays the source rather than renders the page. &lt;strong&gt;&lt;em&gt;Many web pages are 
dynamic and modify their HTML content (eg. using JavaScript/XMLHttpRequest) so we 
cannot display the current HTML - this is why a new request is made.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you want to view the current state of a dynamic page, you should use the 
inspector. "File icon -&amp;gt; Developer -&amp;gt; JavaScript console"&lt;/p&gt;
&lt;p&gt;I don't see how this is a security bug or a bug at all - &lt;strong&gt;the behavior is by design&lt;/strong&gt; - 
closing as such.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;注意里面加粗倾斜的那段话——因为很多网页是动态的，所以无法显示当前的 HTML，所以发送一个新的请求。这逻辑真够奇怪的！你是想“显示当前的 HTML”吗？你发送一个新的请求解决了这个问题吗？没有解决，那你何必要发一个新的请求？这就相当于脱了裤子，屁还是没有放出来。&lt;/p&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post603-beware-of-chrome-view-page-source.html</guid><pubDate>Sat, 21 Apr 2012 04:31:01 GMT</pubDate></item><item><title>Nothing to Envy</title><link>http://qingbo.net/blog/post602-nothing-to-envy.html</link><description>&lt;p&gt;&lt;a class="new-window" href="http://www.thesamueljohnsonprize.co.uk/pages/news/index.asp?NewsID=26" target="_blank"&gt;Winner of the 2010 BBC Samuel Johnson prize&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="new-window" href="http://nothingtoenvy.com/" target="_blank"&gt;What if the nightmare imagined by George Orwell in 1984 were real?&lt;/a&gt; 这本书真是太棒了，我读英文还不是很快，不过书中的真实故事越来越抓住人的心理，前几天晚上都看到很晚才睡。此书中有些许关联的不同人物穿插叙事的方式也没有觉得太乱，比较自然、有条理。与1984的绝望不同，这本书除了让人看到外人很难知道的一些真相，悲哀，但同时也给人一些希望，让人珍惜亲情。此处摘录一些印象深刻的段落(数字是 Kindle 的 location)。&lt;/p&gt;
&lt;p&gt;103 没有污染&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The night sky in North Korea is a sight to behold. It might be the most brilliant in Northeast Asia, the only place spared the coal dust, Gobi Desert and carbon monoxide choking the rest of the continent.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;209&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;They learned that China's diluted brand of c0mmun1sm was less successful than that brought by Kim Il-sung and that millions of Chinese were going hungry.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;341 轻率、残酷的三八线&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The United States was concerned that the Soviet Union might seize Korea as a staging ground on the way to the bigger prize of Japan... So the two army officers looked for a convenient way to divide the peninsula. They slapped a line across the map at the 38th parallel.&lt;br /&gt;
The line bore little relationship to anything in Korean history or geography... The bifurcation between north and south was an entirely foreign creation, cooked up in Washington and stamped on the Koreans without any input from them. One story has it that the secretary of state at the time, Edward Stettinius, had to ask a subordinate where Korean was.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;373&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Some of the rice farmers were sympathetic to the North because they'd heard a rumor that the C0mmun1sts would give them free land.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;409 傻子往北跑，能人往南跑&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Fearing persecution by the C0mmun1sts, tens of thousands of Koreans from north of the 38th parallel had fled south - among them landlords, businessmen, Christian clergymen, and Japanese collaborators. A small number of C0mmun1st sympathizers fled north. (这部分人的命运很悲惨，因为是从“敌方”过来的)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;414 卸磨杀驴&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;After the war, Kim Il-sung made it his first order of business to weed out foe from friend. He started at the top with potential rivals for the leadership. He disposed of many of his comrades in arms who had led the struggle from Manchuria to unseat the Japanese occupiers. He ordered the arrest of the founding members of the C0mmun1st Par4y in South Korea. They had been invaluable during the war; now that they'd served their purpose they could be discarded. Throughout the 1950s, many more were purged in what was increasingly coming to resemble an ancient Chinese empire with Kim Il-sung the unchallenged master of the realm.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;424 精细的人口分类学。他们为了防止人们篡改自己的档案，在北部一个山区省存有备份。上大学是需要政审的&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The classifications became more refined in subsequent phases, such as the "Understanding People Project," between 1972 and 1974.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;439&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;North Koreans of the lower ranks were banned from living in the showcase capital of Pyongyang or the nicer patches of countryside toward the south where the soil was more fertile and the weather warmer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;471 创造历史，无可争议&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It was especially taboo to talk about the Korean War and who started it. In the official histories (and there was nothing but official history in North Korea), it was the South Korean Army that invaded, acting on orders from the Americans, not the North Korean Army storming across the 38th parallel.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;510&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Their textbooks at school were full of stories of people burned, crushed, stabbed, shot, and poisoned by the enemy.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;556 某些移居日本的人把后代送回朝鲜帮助建设“祖国”，然而他们被视为敌人（除了他们的财富），命运凄惨&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;No matter that they were avowed C0mmun1sts who gave up comfortable lives in Japan, they were lumped in with the hostile class. The regime couldn't trust anyone with money who wasn't a member of the Worker's Par4y... the strength of the regime came from its ability to isolate its own citizens completely.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;587 孔夫子教遍地开花&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Koreans have measured their success in life by their proximity to power - part of a long Asian tradition of striving to get off the farm and close to the imperial palace.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;643 喉舌&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"Those who write in accordance with the par4y's intention are heroes," Kim Jong-il proclaimed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;646 无耻流氓穷光蛋也要面子，掩耳盗铃&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Because Pyongyang is the only North Korean city frequented by foreigners, the regime goes to great lengths to ensure that its inhabitants make a good impression with their appearance and are ideologically sound... The streets and squares in the city center were designed in the ostentatiously oversized style favored in Moscow and other C0mmun1st cities that conveys the power of the regime over the individual.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;691&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;North Korea was perpetually short of men - an estimated 20 percent of working-age men were in the armed services, the largest per capita military in the world.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;704 改造人类&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Kim Il-sung's goal wasn't merely to build a new country; he wanted to build better people, to reshape human nature. To that end, he created his own philosophical system, juche, which is commonly translated as "self-reliance."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;759 造神从娃娃抓起&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A few days before each birthday, the Workers' Par4y would distribute to every child more than two pounds of sweets... When the time came, the children lined up in front of the portraits to express their gratitude... "Thank you, dear father Kim Il-sung"&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;861 一切行动听指挥&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The mobile police often dropped in after midnight to see if there were any overnight guests who might have come to visit without travel permits...Since the country was too poor and the power supply too unreliable for electronic surveillance, state security relied on human intelligence - snitches.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;887 外国人民生活在水深火热中&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Anything positive that happend in capitalist countries or especially South Korea, which in 1998 hosted the Summer Olympics, was downplayed. Strikes, disasters, riots, murders - elsewhere - got plenty of coverage.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;916 社会主义需要坚强的意志&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Eastern Europeans and the Chinese weren't as strong by nature or as disciplined.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;985&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;New clothes were dispensed by your work unit or school, often on Kim Il-sung's birthday, reinforcing his image as the source of all good things.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;1009 泡菜是不能共产的&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The North Korean regime understood you couldn't keep Koreans happy without kimchi. Each family got 70 kilograms per adult and 50 kilos per child... Kimchi thieves were common in Chongjin. Even in a society as collectivist as North Korea, no one wanted to share their kimchi with a stranger.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;1024&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In fact, thousands of ethnic Koreans in China fled the famine caused by Mao Zedong's disastrous "Great Leap Forward" to return to North Korea.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;1032&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Lies were built upon lies, all the way to the top, so it is in fact conceivable that Kim Il-sung himself didn't know when the economy crashed...&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;1036&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Kim Il-sung skillfully played the Soviet Union and China against each other, using their rivalry to extract as much aid as possible. Like an old-style emperor, he commanded tribute from neighboring realms: Stalin personally sent an armored limousine, Mao sent a complete train carriage... One day he would decree that the country should switch from rice to potatoes for its staple food; the next he would decide that raising ostriches was the cure for North Korea's food shortage. The country lurched from one harebrained scheme to another.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;1046 就像1984里&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The north Korean propaganda machine kept hysteria at a high level, ginning up incessant reports of imminent invasion by the imperialist warmongers.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;1103 拯救嗷嗷待哺的韩国同胞&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;People were told that their government was stockpiling food to feed the starving South Korean masses on the blessed day of reunification. They were told that the United states had instituted a blockade against North Korea that was keepking out food... United States - North Korea's favorite scapegoat.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;1114 忍受饥饿，升华精神&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Enduring hunger became part of one's patriotic duty. Billboards went up in Pyongyang touting the new slogan, "Let's Eat Two Meals a Day." North Korean television ran a documentary about a man whose stomach burst, it was claimed, from eating too much rice.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;1301 只有皇上可以风流&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Pornographers were executed. Notwithstanding his own excesses and those of Kim Jong-il, a playboy in his youth, par4y officials caught in adulterous affairs lost their jobs.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;1744 神死了！&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"If a great man ilke Kim Il-sung can die, why should a good-for-nothing ilke me go on living and consume food?" he cried.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;2113&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;North Koreans learned to swallow their pride and hold their noses. They picked kernels of undigested corn out of the excrement of farm animals.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;2304 不是被饿死的&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;By 1998, an estimated 600,000 to 2 million North Koreans had died as a result of the famine, as much as 10 percent of the population. In Chongjin, where food supplies were cut off earlier than the rest of North Korea, the toll might have been as high as 20 percent. Exact figures would be nearly impossible to tally since North Korean hospitals could not report starvation as a cause of death.&lt;/p&gt;
&lt;p&gt;Between 1996 and 2005, North Korea would receive $2.4 billion worth of food aid, much of it from the United States. But as much as the North Korean regime was willing to accept foreign food, it rejected the foreigners who came along with it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;2659 关于吃人&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It does not seem, though, that the practice was widespread or even occurred to the degree that was chronicled in China during the 1958-62 famine, which killed as many as 30 million people.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;2877 失败的政变&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In the end, the entire 6th Army was dissolved, replaced eventually by units from the 9th Army from Wonsan. the process dragged on for many months. To this day, the exact reasons remain a mystery... Supposedly, corruption was rampant within the 6th Army and its officers were skimming off the profits for themselves and, like capos in the Mafia, were punished by the big boss.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;2958 共产也要防盗&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Most of the families in his neighborhood had raised the walls around their houses, ignoring a regulation that restricted the height to 1.5 meters so that police could look in.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3019&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Since North Korea couldn't manufacture its own appliances anymore, imported sets had to be fixed to the government stations and then their tuners disabled - a North Korean version of crippleware that would prevent them from receiving any information from the outside world.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3100 株连&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Any antiregime activity would have terrible consequences for the protester, his immediate family, and all other known relatives. Under a system that sought to stamp out tainted blood for three generations, the punishment would extend to parents, grandparents, brothers, sisters, nieces, nephews, cousins.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3344 前50年只有不到1000人逃出！关键就是他们认为自己还是世界上最幸福的。&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In the nearly half a century that elapsed between the end of the Korean War and Mi-ran's defection in October 1998, only 923 North Koreans had fled to South Korea. It was a minuscule number if you consider that while the Berlin Wall stood an average of 21,000 East Germans fled west every year.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3352 叛逃的代价... 不过许多人还是渴望自由。&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Defectors had to be able to live with the knowledge that their freedom came at the expense of loved ones who would likely spend the rest of their lives in a labor camp... By 2001, it was estimated that 100,000 North Koreans had sneaked into China, a small percentage of whom eventually defected to South Korea.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3375 传说中，边界那边的中国农民都很富有，一天吃三顿米饭&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;(It was said) that ordinary Chinese peasants living across the border were so rich that they ate white rice three times a day.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3388 我以前也是这么想的……&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In her wildest dreams Dr. Kim never imagined leaving North Korea. It was not that she was ignorant or lacking in curiosity about the world - she was an avid reader and loved tales of exotic faraway lands - but as far as she was concerned, North Korea was the very best country of all. Why go anywhere else?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3578 中国会遣返叛逃者&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;At least eight thousand women were arrested in one such roundup in March 2000. (As of 2008, the crackdown on North Korean defectors continued.)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3863 韩国接受朝鲜人“叛逃”，但是&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The NIS was also screening for Korean-speaking Chinese posing as North Koreans to obtain South Korean citizenship and resettlement benefits that were worth more than $20,000.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;3963 叛逃头等舱&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Defections were arranged like package tours and Mrs. Song went first class. Her package included the private car that drove her from Chongjin to the border, the bribes to the North Korean border guards who carried her on their backs across the river, and the stolen South Korean passport. "I could have done it cheaper," Oak-hee explained, "but I wanted her to tranvel like a VIP."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;4533 精神食粮&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When North Korea runs short of food, the regime feeds its population with more propaganda.&lt;/p&gt;
&lt;/blockquote&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post602-nothing-to-envy.html</guid><pubDate>Tue, 17 Apr 2012 00:18:17 GMT</pubDate></item><item><title>《史蒂夫·乔布斯传》精彩摘录</title><link>http://qingbo.net/blog/post601.html</link><description>&lt;p&gt;37页&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;它（迷幻药）让我更清楚什么是重要的——创造伟大的发明，而不是赚钱。应该尽我所能，将此生放回历史和人类思想的长河。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;168页&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“这个道理很简单，团队扩张时，如果吸收了几名二流队员，他们就会招来更多二流队员，很快，你的团队里甚至还会出现三流队员，”他回忆道，“麦金塔的经验告诉我，一流队员只喜欢同一流队员合作，这就意味着你不能容忍二流队员。”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;181页&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;但他对产品的关注又是斯卡利永远达不到的，而且乔布斯会侮辱任何一个算不上一流队员的人，以避免苹果出现太多的笨蛋。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;205页 Paul Rand - &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"我解决你的问题，你付钱给我。我设计出来的东西你用也行，不用也罢，都得付钱给我，但是我不做备选。"&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;332页&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;人们总是说他们和别人合不来，他们不喜欢团队合作。但是我发现，一流选手喜欢和一流选手共事，他们只是不喜欢和三流选手在一起罢了。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;392页&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;艺术的作用就是驱赶丑陋。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;399页（这是“风水”真正有意义的地方）&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Steve 坚信，设计对路的建筑物会对文化起到积极的作用。&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;519页（书末乔布斯的原话太精彩了，大段摘录）&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;像IBM或微软这样的公司为什么会衰落，我有我自己的见解。这样的公司干得很好，它们进行创新，成为或接近成为某个领域的垄断者，然后产品的质量就变得不那么重要了。这些公司开始重视优秀的销售人员，因为是他们在推动销售、改写了收入数字，而不是产品的工程师和设计师。因此销售人员最后成为公司的经营者。IBM的约翰·埃克斯是聪明、善辩、非常棒的销售人员，但是对产品一无所知。同样的事情也发生在施乐。做销售的人经营公司，做产品的人就不再那么重要，其中很多人就失去了创造的激情。斯卡利加入后，苹果就发生了这样的事情，那是我的失误；鲍尔默接管微软后也是这样。苹果很幸运，能够东山再起，&lt;strong&gt;但我认为只要鲍尔默还在掌舵，微软就不会有什么起色。&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;521页&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;我的动力是什么？我觉得，大多数创造者都想为我们能够得益于前人取得的成就而表达感激。我并没有发明我用的语言或数学。我的食物基本都不是我自己做的，衣服更是一件都没做过。我所做的每一件事都有赖于我们人类的其他成员，以及他们的贡献和成就。我们很多人都想回馈社会，在历史的长河中再添上一笔。我们只能用这种大多数人都掌握的方式去表达——因为我们不会写鲍勃· 迪伦的歌或汤姆· 斯托帕德(Tom Stoppard)的戏剧。我们试图用我们仅有的天分去表达我们深层的感受，去表达我们对前人所有贡献的感激，去为历史长河加上一点儿什么。那就是推动我的力量。&lt;/p&gt;
&lt;/blockquote&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post601.html</guid><pubDate>Wed, 28 Mar 2012 13:11:54 GMT</pubDate></item><item><title>运算符优先级</title><link>http://qingbo.net/blog/post600.html</link><description>&lt;p&gt;一段计时的代码，把时间长度用“2小时37分钟28秒”这样的形式输出，但是偶然注意到结果很有问题。盯着代码看了半天，觉得逻辑判断都是正确的，后来用一个数字 debug 才找到真相。&lt;/p&gt;
&lt;p&gt;比如 4000 秒，程序先判断如果大于一小时，就输出小时数，然后算余数。就是算余数这一步除了问题，代码写成 &lt;code&gt;secs % 60*60&lt;/code&gt;。写代码的人为了清晰，还故意在乘号两边去掉了空格，可是这更加容易地造成了错觉，让人觉得 &lt;code&gt;60*60&lt;/code&gt; 是先计算的。可是 "%" 的优先级和乘除是同等的！&lt;/p&gt;
&lt;p&gt;&lt;a class="new-window" href="http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html" target="_blank"&gt;运算符优先级&lt;/a&gt;是挺难记的。我觉得，迷惑的时候，加括号就行了，可读性也绝对好。&lt;/p&gt;
&lt;p&gt;不过这次通过 Oracle 这个文档我是记住了，"%" 和乘除都是 multiplicative operators, 所以是同等优先级。想想处理器原理，确实是这样，除法的结果不就顺便出来余数了吗。&lt;/p&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post600.html</guid><pubDate>Tue, 06 Mar 2012 12:53:31 GMT</pubDate></item><item><title>Java SimpleDateFormat 与 locale (以及 Mac OS X 更改语言)</title><link>http://qingbo.net/blog/post599-java-simpledateformat-locale.html</link><description>&lt;p&gt;遇到一个非常怪异的问题，Tomcat 里面有个 servlet 用 SimpleDateFormat 解析日期的，类似这样：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;DateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
formatter.parse("05-Jan-2012")
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;但是会抛出 ParseException - Unparseable date "05-Jan-2012".&lt;/p&gt;
&lt;p&gt;我仔细看了看，似乎一切都是对的，不应该出错。于是写一个最简单的测试类，main 函数就这么两行，同一台机器上运行完全正常。更纳闷了。&lt;/p&gt;
&lt;p&gt;最后在 servlet 代码里打出 formatter.format(new Date()) 的结果，发现是 "29-二月-2012"!&lt;/p&gt;
&lt;p&gt;这才想起我最早拿到这台 MacBook Pro 时系统是中文，我改成英文但是登录界面等少数地方还是中文。不知道 Tomcat 是怎么设置的 locale，不过这里有人在 Windows 上遇到&lt;a class="new-window" href="http://bytes.com/topic/apache/answers/558992-tomcat-locale-difference-console-windows-service" target="_blank"&gt;同样的问题&lt;/a&gt;，可以通过指定 java 参数解决。&lt;/p&gt;
&lt;p&gt;但是苹果恰好有一个文档：&lt;a class="new-window" href="http://support.apple.com/kb/HT4102" target="_blank"&gt;Mac OS X: How to change the language displayed in the login window&lt;/a&gt;！看起来，我在 System Preferences 里修改的只是我当前用户的 locale，而我启动 tomcat 的时候，使用了 sudo——root 的 locale 仍然是中文？&lt;/p&gt;
&lt;p&gt;不管怎么样，既然有了这么专业的文档，照做就是了。不过苹果给的第一种解决办法太让人无语了：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Reinstall Mac OS X and select the desired language during installation&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;正常做法是在 Terminal 里执行 &lt;code&gt;sudo languagesetup&lt;/code&gt;，挑选想要的语言即可。&lt;/p&gt;
&lt;p&gt;P.S. SimpleDateFormat 是有个 constructor 可以指定 locale 的。&lt;/p&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post599-java-simpledateformat-locale.html</guid><pubDate>Sun, 04 Mar 2012 05:13:03 GMT</pubDate></item><item><title>无限递归导致 Segmentation fault</title><link>http://qingbo.net/blog/post598-infinite-recursion-causing-segmentation-fault.html</link><description>&lt;p&gt;某服务器上一个 cron job 是 shell 脚本调用 Java 程序，最近老是报 Segmentation fault, 每次看见此信息&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;/bin/sh: line 1:  4285 Segmentation fault java ...&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;总觉得无处下手，bash 的问题？Java 版本不对？信息量太少了。其实遇到这种事情不能谎，表面上没有信息一定要挖出信息来。今天仔细一看，这个脚本把标准输出重定向到一个日志文件去了，于是去看日志。这个程序的主体是对一个信息列表做循环，恰好在每个循环的关键部分开始前、结束后都会写一条日志。其目的是为了计时，不过正是这两条日志让我很快找到了错误缘由，因为发现日志文件的末尾只有一个开始前的，说面在这个循环的处理过程里面发生了 Segmentation fault.&lt;/p&gt;
&lt;p&gt;找出程序的源代码，发现循环里面调用的方法有一个是递归的，情况就开始明朗了，猜测就是递归无法终止导致 stack overflow，segmentation fault. 果然，根据日志里最后一行日志中记录的真实数据，发现这条数据是有问题的，会导致此方法无限递归。&lt;/p&gt;
&lt;p&gt;Wikipedia 的 &lt;a class="new-window" href="http://en.wikipedia.org/wiki/Segmentation_fault" target="_blank"&gt;Segmentation fault&lt;/a&gt; 词条里有一节是 "Common causes", 我这次遇到的就是最后一条。&lt;/p&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post598-infinite-recursion-causing-segmentation-fault.html</guid><pubDate>Sat, 03 Mar 2012 02:08:30 GMT</pubDate></item><item><title>wget 自动发送用户名密码</title><link>http://qingbo.net/blog/post597.html</link><description>&lt;p&gt;有个 Server 需要 Basic Auth 认证，但是我发现在它自己上面有一个任务会通过 wget 访问一个自己的 URL，调用的过程并没有提供用户名和密码，竟然可以成功访问！&lt;/p&gt;
&lt;p&gt;一开始我以为是 Apache 里面配置的访问规则是对本地访问不需要认证，但是并非如此。bash alias? 也不是。加上 --debug 参数调用 wget，发现它确实在访问本机的这个域名时会加上 Authorization 这个 header, 而访问其它域名的时候则不加。&lt;/p&gt;
&lt;p&gt;最终通过 strace 发现它会打开 $HOME/.netrc 文件，原来秘密就在里面。中间看了半天 manual，只看到它会读取 /etc/wgetrc, $HOME/.wgetrc, 没注意到还会读这个文件。我不太喜欢这种做法——谈不上安全，又不容易维护。&lt;/p&gt;
&lt;p&gt;参考：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class="new-window" href="http://linux.die.net/man/5/netrc" target="_blank"&gt;.netrc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="new-window" href="http://www.gnu.org/software/wget/manual/wget.html" target="_blank"&gt;wget&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post597.html</guid><pubDate>Thu, 01 Mar 2012 13:10:08 GMT</pubDate></item><item><title>QQ 输入法的词频</title><link>http://qingbo.net/blog/post596.html</link><description>&lt;p&gt;现在 QQ 和搜狗都开始做 Mac 上的输入法。搜狗的问题是没有投入足够的资源在这上面，而它做 Mac 输入法也似乎是无奈之举。当时 QQ 突然发布了 Mac 输入法，搜狗没隔几天也赶紧出来一个，结果 bug 一大堆，至今在软件的功能和稳定性方面，搜狗依旧落后很多。&lt;/p&gt;
&lt;p&gt;前些天用了一下搜狗输入法，在 Gmail 里的聊天界面，候选窗口无法正确定位。可能跟我用两个屏幕有关系，不过在 QQ 群里（没错，他们用 QQ 群跟用户交流）报告了之后，有人告诉我用正在测试的 1.5 版本试试。我试了一下，完全不能用，应该是切到搜狗输入法它就 crash 了。&lt;/p&gt;
&lt;p&gt;QQ 输入法的功能现在非常稳定了，我没有遇到过任何问题。官方网站的 Mac 页面做得也有模有样（搜狗跟它一比就显得山寨），属性设置里也有丰富的选项可供选择，可是有个很致命的问题，那就是词频。我遇到许多让人觉得不可思议的词频，仅选取一小部分放在这儿 (都是第一页)：&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/qingbo/6930622863/" title="QQ Mac 输入法词频 by qingbo, on Flickr"&gt;&lt;img src="http://farm8.staticflickr.com/7195/6930622863_01b7fff0b9.jpg" width="260" height="247" alt="QQ Mac 输入法词频"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;难道就是这么烂？&lt;/p&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post596.html</guid><pubDate>Wed, 29 Feb 2012 12:41:55 GMT</pubDate></item><item><title>小打小闹</title><link>http://qingbo.net/blog/post595.html</link><description>&lt;p&gt;在我的网站日志目录里先找到 Sogou spider 的 IP：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# grep -h -F "Sogou web spider" * | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 5
 109766 220.181.94.231
  26244 220.181.125.69
     93 220.181.94.235
     90 220.181.125.107
     83 220.181.94.236
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;然后看看从访问最多的那个 IP 来的都是什么 user agent:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# grep -h -F "220.181.94.231" * | grep -v -F "robots.txt" | awk '{ for (i=12; i&amp;lt;=NF; i++) printf("%s ", $i); printf("\n"); }' | sort | uniq -c | sort -nr
 109497 "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)" 
    187 "Sogou-Test-Spider/4.0 (compatible; MSIE 5.5; Windows 98)" 
    109 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Avant Browser; InfoPath.1; .NET CLR 2.0.50727; .NET CLR1.1.4322)" 
     70 "Tsinghua AI Lab Robot 2.0" 
     55 "Tsinghua AI Lab Robot" 
     35 "-" 
     21 "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.7) Gecko/2009031915 Gentoo Firefox/3.0.7" 
     18 "Sogou Pic Spider/3.0(+http://www.sogou.com/docs/help/webmasters.htm#07)" 
      1 "Sogou Mobile Spider1.0 (http://wap.sogou.com)"
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;真有意思。&lt;/p&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post595.html</guid><pubDate>Sun, 26 Feb 2012 06:40:08 GMT</pubDate></item><item><title>grep: writing output: Broken pipe in iTerm2</title><link>http://qingbo.net/blog/post594-grep-writing-output-broken-pipe-item2.html</link><description>&lt;p&gt;前天用 &lt;a class="new-window" href="http://www.iterm2.com/" target="_blank"&gt;iTerm2&lt;/a&gt;，在执行一个 &lt;code&gt;grep "xxx" filename | head&lt;/code&gt; (filename 这个文件应该相当大，grep 到的内容也应该有很多)这样的命令时，遇到大量如下错误输出：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;grep: writing output: Broken pipe&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;而在 Mac 自带的 Terminal.app 里面执行完全一样的命令，不会有任何错误。用 which 查看，使用的确实是同一个 grep 命令，同一个 head 命令。再仔细观察，发现其实 iTerm 里面，命令也输出了正确的结果，那后面的这些错误信息应该是输出到 stderr 的。把命令改成&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;grep "xxx" filename 2&amp;gt;errors | head
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;确实，错误信息都跑到 errors 文件里了。这时又发现，在 Terminal.app 里命令在输出10行之后立即结束执行，而在 iTerm 里则取决于这个文件有多大，grep 出来的内容有多少行，它就会执行相应长的时间。网上看到有人说这是 head 取得10行后立即退出，这个 pipe 的读端就没了，grep 继续往 pipe 写，于是 - broken pipe, 只要将错误定向到 /dev/null, 忽略即可。可是我经常用 grep 来在特别大的日志文件里找东西，进行下一步分析前，就先用 head 看看 grep 的正则表达式写的对不对。每次 grep 都不管 head 只读少数行这个现实，一直执行到读完整个文件，太浪费时间和资源了。&lt;/p&gt;
&lt;p&gt;为什么在 Terminal 里，grep 会在 head 退出之后马上退出呢？当进程往一个 broken pipe 写东西的时候，会收到一个 &lt;a class="new-window" href="http://en.wikipedia.org/wiki/SIGPIPE" target="_blank"&gt;SIGPIPE&lt;/a&gt; 信号，导致它退出。这时就觉得，肯定是 iTerm2 做了什么手脚，导致 SIGPIPE 这个信号没有被 grep 收到。&lt;/p&gt;
&lt;p&gt;用一个 dtrace 命令来看系统里信号的发送接收情况 (参考 &lt;a class="new-window" href="http://www.brendangregg.com/DTrace/dtrace_oneliners.txt" target="_blank"&gt;dtrace oneliners&lt;/a&gt;)：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo dtrace -qn 'proc:::signal-send { printf("%s (PID=%d) sent signal %d to PID %d\n", execname, pid, arg1, args[1]-&amp;gt;pr_pid) }
proc:::signal-handle { printf("%s (PID=%d) was sent signal %d\n", execname, pid, arg0)}'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;在Terminal.app 里执行上面的命令，可以跟踪到：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;grep (PID=3524) sent signal 336414016 to PID 3524
grep (PID=3524) was sent signal 13&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;而在 iTerm 里执行则什么都没有（应该只能看见时间同步服务 ntpd 不停接收信号）。从上面也看到，信号其实是 grep 自己发给自己的，&lt;a class="new-window" href="http://www.cs.pitt.edu/~alanjawi/cs449/code/shell/UnixSignals.htm" target="_blank"&gt;13 就是 SIGPIPE&lt;/a&gt;。我不了解 Unix 编程，猜想收到 SIGPIPE 退出这个应该是 libc 这样底层的库已经定义的行为吧。&lt;/p&gt;
&lt;p&gt;找到 iTerm2 的源代码，竟然轻易在&lt;a class="new-window" href="https://github.com/gnachman/iTerm2/blob/master/main.m" target="_blank"&gt;它的 main.m&lt;/a&gt; 中找到了可疑代码：&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(int argc, const char *argv[])
{
    signal(SIGPIPE, SIG_IGN);
    sigset_t signals;
    sigemptyset(&amp;amp;signals);
    sigaddset(&amp;amp;signals, SIGPIPE);
    sigprocmask(SIG_BLOCK, &amp;amp;signals, NULL);

    return NSApplicationMain(argc, argv);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;一开始我只注意到第一行，&lt;code&gt;signal(SIGPIPE, SIG_IGN);&lt;/code&gt; 即在收到 SIGPIPE 信号时忽略，但是注释掉之后发现和原来一样的行为 (如果只是 SIG_IGN, dtrace 应该能跟踪到发送)。接着注意到下面几行也是处理 SIGPIPE 信号的，把 SIGPIPE 完全 block 掉！至少 sigprocmask 这个函数是对子进程有作用的，因为在 iTerm2 里执行 grep，grep 就是 iTerm2 的子进程（具体关系是 iTerm2 - login - bash - grep，可以安装个 pstree 查看）。&lt;/p&gt;
&lt;p&gt;真相大白，果然把相关代码全部注释掉之后，用 XCode 自己 build 了一个，这个问题解决掉了。&lt;code&gt;git blame main.m&lt;/code&gt;，发现这段代码是 2011-10-31 在 &lt;a class="new-window" href="https://github.com/gnachman/iTerm2/commit/474cd19a972cea6a0d34f552a8a7ecaec514f3f9" target="_blank"&gt;474cd19a972cea6a0d34f552a8a7ecaec514f3f9&lt;/a&gt; 这个 commit 加入的。所以在 &lt;a class="new-window" href="http://code.google.com/p/iterm2/downloads/list" target="_blank"&gt;iTerm2 下载列表&lt;/a&gt;里，使用 20111020 那个 build 应该没这个问题，而我用的是新一点的 20111219.&lt;/p&gt;
&lt;p&gt;在 google code 上&lt;a class="new-window" href="http://code.google.com/p/iterm2/issues/detail?id=1687" target="_blank"&gt;创建了一个 issue&lt;/a&gt;, George Nachman 很快 fix 了这个问题。显然我的改法太简单粗暴，具体修改见 &lt;a class="new-window" href="https://github.com/gnachman/iTerm2/commit/b0a6289bc00835e1356b626b76f6ffba4a4c8097" target="_blank"&gt;commit b0a6289bc0&lt;/a&gt;. 没想到竟然之前有人汇报的一个 issue 也是这个 bug 引起的，作者在&lt;a class="new-window" href="http://code.google.com/p/iterm2/issues/detail?id=1686" target="_blank"&gt;此 issue&lt;/a&gt; 中上传了一个最新的 build 版本，大家可以使用。&lt;/p&gt;</description><guid isPermaLink="true">http://qingbo.net/blog/post594-grep-writing-output-broken-pipe-item2.html</guid><pubDate>Tue, 03 Jan 2012 04:18:16 GMT</pubDate></item></channel></rss>
