2008年11月23日星期日

嘿,今天你精神病了么?

由总后卫生部组织、北京军区总医院牵头制定的《网络成瘾临床诊断标准》近日通过专家论证,这意味着我国医学界诊断“网瘾”将实行标准 化.《标准》中有这样 一项量化的指标:平均每天连续使用网络达到或超过6小时,而且这种症状达到或者超过3个月.
----11月23日《人民日报》

恩,我参照了一下自己的症状,原来我是重度精神病患者唉……这下好了,以后杀人不犯法咯~咱是精神病,咱怕谁?


今天你精神病了么?

2008年11月17日星期一

[FWD]奥巴马胜选演说·文言版

〈奥巴马胜选演说·文言版〉

东东枪

Hello,Chicago!

芝城父老,别来无恙,

If there is anyone out there who still doubts that America is a place where all things are possible, who still wonders if the dream of our founders is alive in our time, who still questions the power of our democracy, tonight is your answer.

余尝闻世人有疑,不知当今美利坚凡事皆可成就耶?开国先贤之志方岿然于世耶?民主之伟力不减于昔年耶?凡存诸疑者,今夕当可释然。

It’s the answer told by lines that stretched around schools and churches in numbers this nation has never seen, by people who waited three hours and four hours, many for the first time in their lives, because they believed that this time must be different, that their voices could be that difference.

今夕之释然,皆蒙美利坚民众之协力——学塾祠庙之外,市井乡野之间,万千父老心焦似焚,苦待竟日,愿献一票之力。其中,平生未尝涉国事者,数亦不少,而今有此义举,皆因一念不衰——今夫天下,非同既往,愿发吁天之声,必成动地之势。

It’s the answer spoken by young and old, rich and poor, Democrat and Republican, black, white, Hispanic, Asian, Native American, gay, straight, disabled and not disabled. Americans who sent a message to the world that we have never been just a collection of individuals or a collection of red states and blue states. We are, and always will be, the United States of America.

今夕之释然,皆仰吾国同胞之齐心——何谈贫富老幼之差、党社宗族之异,惶论发肤肌体之别、志趣爱恶之分。吾国既以“合众”为名,吾辈则更无疏离之意,红蓝二党并肩而立,数十邦州挽手相合,无分你我,共称一家,昂然于世,齐声一呼,天下乃有此释然。

It’s the answer that led those who’ve been told for so long by so many to be cynical and fearful and doubtful about what we can achieve to put their hands on the arc of history and bend it once more toward the hope of a better day.

今夕之释然,皆因愤懑者之镇静,忧惧者之勇气,犹疑者之笃定——平素世间种种,消磨其志向,溃灭其梦想,而值此风云之际,除旧更新,当仁不让,倾力而动乾坤者,更何人哉!

It’s been a long time coming, but tonight, because of what we did on this date in this election at this defining moment change has come to America.

俟之诚久,其志弥坚。幸天地明察,乃有今日,乃有此刻,乃有此一选举,乃有我亿万美利坚大好国民——吾邦之大变革,方得自兹而始也!

A little bit earlier this evening, I received an extraordinarily gracious call from Sen. McCain.

Sen. McCain fought long and hard in this campaign. And he’s fought even longer and harder for the country that he loves. He has endured sacrifices for America that most of us cannot begin to imagine. We are better off for the service rendered by this brave and selfless leader. I congratulate him; I congratulate Gov. Palin for all that they’ve achieved. And I look forward to working with them to renew this nation’s promise in the months ahead.

倾接参议员麦君凯恩电,虽未得晤,幸有一谈,其言谆谆,其意诚诚,鄙人感佩之至。选战期内, 麦君劳碌几重,奔波几许,皆为国家计。诸般求索,时日良多,皆非余所能及。于国于民之惊人牺牲,亦非庸庸如吾辈者所可想见。以麦君之胆魄襟怀,能为吾邦所 用,实国家之幸,万民之幸也。前途漫漫,其事未竟,余所盼瞩由衷者,唯共麦凯恩君、佩林君,及诸贤士比肩,会吾等之绵力,成吾邦之大业。

I want to thank my partner in this journey, a man who campaigned from his heart, and spoke for the men and women he grew up with on the streets of Scranton and rode with on the train home to Delaware, the vice president-elect of the United States, Joe Biden.

乔君拜登,亦吾所感铭至深者也。竞选之业,艰险不足与外人道,幸有乔君之辅佐,其诚天可鉴之。乔君其人,素言恳辞切,意笃情真,盖尝经斯兰克顿街乡邻之提命,饱聆特拉华州父老之晤教也。他日余既登总统之位,乔君必当副之。

And I would not be standing here tonight without the unyielding support of my best friend for the last 16 years the rock of our family, the love of my life, the nation’s next first lady Michelle Obama.

拙荆米氏,追随鄙人凡一十六年,既为爱侣,更为挚友,既为吾阖家之基石,又乃余终生之至爱。鄙人尝自忖度,倘无贤妻若此,今朝阔论高谈于此处者,不知何人矣!

Sasha and Malia I love you both more than you can imagine. And you have earned the new puppy that’s coming with us to the new White House.

小女萨沙、玛丽,余素深喜之。昔日为父尝与汝等言,此番选战若得一胜,愿购小犬一头相赠,待阖家乔迁总统府邸之日,偕汝等同进吾宅。今当胜负已出,既有一诺在前,必自践行不欺也。

And while she’s no longer with us, I know my grandmother’s watching, along with the family that made me who I am. I miss them tonight. I know that my debt to them is beyond measure.

祖母大人虽已仙逝,料必有灵在天,俯察人寰,想应颔首开颜矣。吾奥巴马氏列祖列宗,亦当如是。今日今时,此情此景,鄙人追思之心,乌鸟之情,曷其有极!唯生死陌路,仙凡有别,虽怀反哺之心,而无答报之门也!

To my sister Maya, my sister Alma, all my other brothers and sisters, thank you so much for all the support that you’ve given me. I am grateful to them.

至若玛雅、艾玛二姐妹,以及吾家诸同胞,所惠我者,亦属良多,久沐恩德,此当拜谢。

And to my campaign manager, David Plouffe, the unsung hero of this campaign, who built the best — the best political campaign, I think, in the history of the United States of America.To my chief strategist David Axelrod who’s been a partner with me every step of the way.To the best campaign team ever assembled in the history of politics you made this happen, and I am forever grateful for what you’ve sacrificed to get it done.

大卫?普劳夫君,大卫?阿克塞罗德君,一为鄙人竞选事务之经理,一为鄙人国事韬略之智囊。余尝自喟叹,左右谋士,余所仰赖者,皆亘古未见之贤才。普阿二君,则更此中之翘楚。区区不才,有何德能,可得膀臂若此?当此功成之际,感荷之心,亦自拳拳。

But above all, I will never forget who this victory truly belongs to. It belongs to you. It belongs to you.

至于鄙人铭之肺腑,须臾不敢忘怀者,则诸位也。盖今日鄙人之胜绩,实诸位之胜绩,鄙人之荣光,实诸位之荣光!

I was never the likeliest candidate for this office. We didn’t start with much money or many endorsements. Our campaign was not hatched in the halls of Washington. It began in the backyards of Des Moines and the living rooms of Concord and the front porches of Charleston. It was built by working men and women who dug into what little savings they had to give $5 and $10 and $20 to the cause.

余素朴陋,虽有参选之心,并无必胜之志。谋事之初,银资乏匮,从者寥寥;起事之地,皆蔽寓荒斋,不在高阁;成事之基,无非寻常百姓,涓滴之献。

It grew strength from the young people who rejected the myth of their generation’s apathy who left their homes and their families for jobs that offered little pay and less sleep.

It drew strength from the not-so-young people who braved the bitter cold and scorching heat to knock on doors of perfect strangers, and from the millions of Americans who volunteered and organized and proved that more than two centuries later a government of the people, by the people, and for the people has not perished from the Earth.

今日之胜,有赖一众热血青年,抛其家,别其室,不辞其苦,不计其酬,矻矻于此——“国中青年 爱国之心已泯”之谬论,今可休矣!今日之胜,有赖壮志未已之诸前辈,无惧寒暑,行走奔波,劝说民众。今日之胜,乃数百万美利坚民众之胜,察其意,皆属踊跃 为国,观其行,处处谨严有序,足堪告慰二百年前开国之先贤——民有、民治、民享之政体,未尝动摇也!

This is your victory.

嗟夫!此实诸位之功也!

And I know you didn’t do this just to win an election. And I know you didn’t do it for me.You did it because you understand the enormity of the task that lies ahead. For even as we celebrate tonight, we know the challenges that tomorrow will bring are the greatest of our lifetime — two wars, a planet in peril, the worst financial crisis in a century.

余知诸君之意非在此一选举,亦非在鄙人一身。盖瞻前路之艰辛,益知此任非同小可也。虽今夕欢贺于此,而明朝酒醒,大患仍自当前,不容有怠——两地烽烟熊熊而起,四海之内纷纷而乱,金融业界惶惶而不得宁。

Even as we stand here tonight, we know there are brave Americans waking up in the deserts of Iraq and the mountains of Afghanistan to risk their lives for us.There are mothers and fathers who will lie awake after the children fall asleep and wonder how they’ll make the mortgage or pay their doctors’ bills or save enough for their child’s college education. There’s new energy to harness, new jobs to be created, new schools to build, and threats to meet, alliances to repair.

是夜,饮宴笙歌之声不绝于耳,而异邦大漠群山中,吾国大好青年,兀自苦戍边塞,惝恍竟夜,性 命尚未得安。吾国千万庶民,为人父母者,兀自惴惴难眠,所忧者,乃房宅所贷、病患之费、抚育之资也。至若吾国能源之耗,百业之兴,痒序之教,攻伐之术,怀 远之道,亦皆吾等忡忡挂怀者也。

The road ahead will be long. Our climb will be steep. We may not get there in one year or even in one term. But, America, I have never been more hopeful than I am tonight that we will get there. I promise you, we as a people will get there.

渺渺乎其远,如不可达,危危乎其高,若不可攀。朝夕岁月,焉得成就?余不揣愚钝,愿以四载韶华,付诸此业,胜算何如虽不可知,然昂扬必胜之奇志,成就伟业之壮怀,平生未之有也。君子一诺,其重何如,此地今夕,愿斗胆发一狂言——吾辈既在,其事必成!

There will be setbacks and false starts. There are many who won’t agree with every decision or policy I make as president. And we know the government can’t solve every problem. But I will always be honest with you about the challenges we face. I will listen to you, especially when we disagree. And, above all, I will ask you to join in the work of remaking this nation, the only way it’s been done in America for 221 years — block by block, brick by brick, calloused hand by calloused hand.

逶迤坎坷,份内之事。异见争端,料必有之。国中之政府,谅非无所不能者。余所秉承不移者,唯 忠信矣。倘有危难于前,必无欺瞒于世。诸君言论臧否,纵悖逆相左之议,余必当洗耳以聆。于此之外,更当恳请诸君,不吝心血,致力报效,以振吾美利坚重兴之 业。余亦别无他想,唯盼吾侪协力,延继吾国既肇二百二十一年之大统,汇涓滴之力,而成万世之业。

What began 21 months ago in the depths of winter cannot end on this autumn night. This victory alone is not the change we seek. It is only the chance for us to make that change. And that cannot happen if we go back to the way things were. It can’t happen without you, without a new spirit of service, a new spirit of sacrifice.

昔年冬日,余有志于斯,投身此业,屈指算来,倏然近二载矣。当此秋夜,追思反省,仍无溃退逃 亡之意。选战之胜,无非一役之功,余梦寐所思矢志所求者,非在乎此。溯源究本,此役之胜,不过革世变时一大好良机耳。倘止步于斯,垂手而待,或无诸君倾力 相援,则壮志丰功,无非泡影,诸般梦想,终必虚妄。

So let us summon a new spirit of patriotism, of responsibility, where each of us resolves to pitch in and work harder and look after not only ourselves but each other. Let us remember that, if this financial crisis taught us anything, it’s that we cannot have a thriving Wall Street while Main Street suffers. In this country, we rise or fall as one nation, as one people.

爱国之心,报国之念,吾人固有之,然逢今日之世,此心此念亦当一变——吾辈各执己业,益当各竭其力,各尽其命,非但为一己之利,而更期普世之荣。今岁,金融业界动荡多舛,细审观之,当可以之为鉴——实业之损,亦是金融之伤。可知,既在邦域之内,吾辈荣辱休戚,皆相与共矣!

Let’s resist the temptation to fall back on the same partisanship and pettiness and immaturity that has poisoned our politics for so long. Let’s remember that it was a man from this state who first carried the banner of the Republican Party to the White House, a party founded on the values of self-reliance and individual liberty and national unity.Those are values that we all share.

党争纷纭,阴谋卑鄙,愚鲁无知,皆腐蚀清白、惑乱政局之弊也,其缘由已久,余今愿与诸君协力,共灭除之。昔年曾有此郡先贤,执共和党之帜,而掌总统府之权。自强独立,自由统一等信念,皆斯人之所倡,亦吾辈之所宗。

And while the Democratic Party has won a great victory tonight, we do so with a measure of humility and determination to heal the divides that have held back our progress. As Lincoln said to a nation far more divided than ours, we are not enemies but friends. Though passion may have strained, it must not break our bonds of affection.

今岁选战,吾民主党人幸有一胜,然谦逊和合之心未尝少减。余素信服者,乃山河破碎之际,林肯总统之言——“既是至亲,终不为敌。虽弩张剑拔,而血脉未尝断,情义不少减。”

And to those Americans whose support I have yet to earn, I may not have won your vote tonight, but I hear your voices. I need your help. And I will be your president, too.

固然,仍有四方志士,不为鄙人所动,另有高明之选。虽终悭此一票之缘,然诸君高论,余亦声声在耳,字字在心。倘能得诸君之援手,鄙人幸甚。他日待余总而统之,亦必不另眼以待也。

And to all those watching tonight from beyond our shores, from parliaments and palaces, to those who are huddled around radios in the forgotten corners of the world, our stories are singular, but our destiny is shared, and a new dawn of American leadership is at hand.

吾邦民众,散居天下,各安其命,而其志一也。吾邦鼎盛之势,今已乍现锋芒。

To those — to those who would tear the world down: We will defeat you. To those who seek peace and security: We support you. And to all those who have wondered if America’s beacon still burns as bright: Tonight we proved once more that the true strength of our nation comes not from the might of our arms or the scale of our wealth, but from the enduring power of our ideals: democracy, liberty, opportunity and unyielding hope.

至于心怀叵测,与世人为仇、与天下为敌者,吾邦猛志常在,彼等必取灭亡。心思纯良,久慕大同 者,吾辈当倾力以助,鼎力相援。犹疑未定,不知吾自由之邦兴衰如何者,吾辈愿以今日盛况以告之——美利坚之所以谓之“美”者,非刀兵之强,金银之众,实民 主、自由、机遇、梦想之美也!

That’s the true genius of America: that America can change. Our union can be perfected. What we’ve already achieved gives us hope for what we can and must achieve tomorrow.

天自有道,地自有德,恩赋吾邦无上异禀——无他,唯变而已矣。美利坚变革不怠,合众国日趋尽善。当以过往先贤之伟绩,助吾侪今日之雄心,开子孙万世之辉光。

This election had many firsts and many stories that will be told for generations. But one that’s on my mind tonight’s about a woman who cast her ballot in Atlanta. She’s a lot like the millions of others who stood in line to make their voice heard in this election except for one thing: Ann Nixon Cooper is 106 years old.

今岁选战,多开亘古之先,屡传千秋佳话。感我至深者,亚特兰大之老妪安?尼克松?库帕也——库氏之一票,于数百万美利坚民众之选票无异,其所以引人称奇者,其人今岁高龄一百有六矣。

She was born just a generation past slavery; a time when there were no cars on the road or planes in the sky; when someone like her couldn’t vote for two reasons — because she was a woman and because of the color of her skin.

当其父辈之时,天道不彰,黑人为奴。库氏其生也不逢时,汽车尚不行于道,飞机未曾起于空,库氏既属黑人,又系女流,票选一事,概无瓜葛。

And tonight, I think about all that she’s seen throughout her century in America — the heartache and the hope; the struggle and the progress; the times we were told that we can’t, and the people who pressed on with that American creed: Yes we can.

今日今时,回溯库氏百岁之涯,但见吾邦先贤屡败屡战,且退且进,悲欣交集,甘苦杂陈。幸而正道存焉,壮志存焉,曰:吾辈既在,无所不能。

At a time when women’s voices were silenced and their hopes dismissed, she lived to see them stand up and speak out and reach for the ballot. Yes we can.

万马齐喑,其事堪哀,吾邦女界怒而起,愤而争,苦战不歇,历数十载。幸哉库氏,以百岁之高龄,终得亲见女流自立于世,重获天赋之权——吾辈既在,无所不能!

When there was despair in the dust bowl and depression across the land, she saw a nation conquer fear itself with a New Deal, new jobs, a new sense of common purpose. Yes we can.

当百业萧条,国人绝望哀鸣之际,库氏亲见吾美利坚出旷世之新政,挽狂澜于既倒,扶大厦之将倾,退畏惧之势,扶奋勇之心,终至人各有位,民心乃安——吾辈既在,无所不能!

When the bombs fell on our harbor and tyranny threatened the world, she was there to witness a generation rise to greatness and a democracy was saved. Yes we can.

当吾国良港遭袭,天下桀纣当道,暴政肆虐之时,库氏亲见豪杰群起,民主不衰——吾辈既在,无所不能!

She was there for the buses in Montgomery, the hoses in Birmingham, a bridge in Selma, and a preacher from Atlanta who told a people that “We Shall Overcome.” Yes we can.

蒙哥马利公车之罢辍,伯明翰城黑人之群起,塞尔玛城血雨腥风之事,库氏般般亲历。更曾亲聆亚特兰大传教之士振臂登高之呼——“吾等必胜!”诚哉斯言!吾辈既在,无所不能!

A man touched down on the moon, a wall came down in Berlin, a world was connected by our own science and imagination. And this year, in this election, she touched her finger to a screen, and cast her vote, because after 106 years in America, through the best of times and the darkest of hours, she knows how America can change. Yes we can.

俟科学昌明于世,创想通贯一时,既登广寒之阙,又溃柏林之墙。洋洋乎!有百年如是,乃见今岁选战中,库氏之一票。浩浩兮!一百零六载交锋更迭,方有美利坚今日之变革——吾辈既在,无所不能!

America, we have come so far. We have seen so much. But there is so much more to do. So tonight, let us ask ourselves — if our children should live to see the next century; if my daughters should be so lucky to live as long as Ann Nixon Cooper, what change will they see? What progress will we have made?

转眼兴亡过手,而今迈步从头。追昔抚今,不禁扪心而问——俟再历百年岁月,倘吾等后辈儿孙,亦有得享高寿如库氏者,复可见何等之变数?吾辈今日之功,他年可得而见之乎?

This is our chance to answer that call. This is our moment. This is our time, to put our people back to work and open doors of opportunity for our kids; to restore prosperity and promote the cause of peace; to reclaim the American dream and reaffirm that fundamental truth, that, out of many, we are one; that while we breathe, we hope. And where we are met with cynicism and doubts and those who tell us that we can’t, we will respond with that timeless creed that sums up the spirit of a people: Yes, we can.

所谓天命时运,莫过于此——当为吾邦万民造安身立命之业,为吾辈儿孙启各显雄才之门,为寰宇 各国创太平静好之世,为吾等壮志赋千秋不灭之元神。吾邦立国之本,必将光耀于天下。万千同胞,当如一人,一息尚存,梦想不灭。纵有世人旁观在侧,而疑窦生 焉,吾辈亦当以千秋不易之训共答之曰——吾辈既在,无所不能!

Thank you. God bless you. And may God bless the United States of America.

拜谢诸君。愿天佑吾民,天佑吾邦。

2008年11月14日星期五

Jokes From RFCs

一向是严肃的Internet标准制定者RFC也会开玩笑,事实上在数千的RFC文档里不缺乏恶搞式的幽默,似乎从1989年开始,每年的愚人节都会出台一个玩笑性质的RFC文档,而且有些玩笑(RFC 1149, 2322)事实上被人实现或者投入使用:
RfC 527 (1973)
ARPAWOCKY (看起来是一首诗?)

RfC 748 (1978)
Telnet Randomly-lose option (Telnet协议的随机丢失选项(估计作者是在抱怨当时网络丢包吧))

RfC 1097 (1989)
Telnet subliminal-message option (Telnet潜在信息选项?)

RfC 1149 (1990)
Standard for the transmission of IP datagrams on avian carriers
这个搞笑性很高:使用信鸽(或者其他鸟类)传输IP数据包的标准
而且这个RFC有好事者实现了,还不止一次:
The first implementation was B2P (back to Pigeons) April 2001 in Bergen, Norway. 用信鸽传递纸条,然后再OCR扫描进去的实现。
A later implementation (FiFly, March 2004, Israel) reached 2,27Mbit/s data transfer rate (very high latency, though) .用信鸽传递闪存芯片的实现
And a later one (April 2005) even higher throughput with adhesive surface-mounted carriers (SNAP = SNAil-based data transfer Protocol, 37 Mbit/s).这个是很囧的用蜗牛拉光盘小车的实现(谁说蜗牛就一定慢,以后不许抱怨网速和蜗牛一样慢)
下面的就不一个一个翻译了……太多了,造几个有代表性的翻译:

RfC 1216 (1991)
Gigabit network economics and paradigm shifts

RfC 1217 (1991)
Memo from the Consortium for Slow Commotion Research

RfC 1313 (1992)
Today's Programming for KRFC AM 1313 Internet Talk Radio

RfC 1437 (1993)
The Extension of MIME Content-Types to a New Medium

RfC 1438 (1993)
Internet Engineering Task Force Statements Of Boredom (SOBs)

RfC 1605 (1994)
SONET to Sonnet Translation

RfC 1606 (1994)
A Historical Perspective On The Usage Of IP Version 9 传说中的IPv9就是这个啦~天朝的科学研究,有兴趣的Google

RfC 1607 (1994)
A view from the 21st century

RfC 1776 (1995)
The Address is the Message

RfC 1882 (1995)
The 12-Days of Technology Before Christmas

RfC 1924 (1996)
A Compact Representation of IPv6 Addresses 吧ipv6地址压缩成Base85编码

RfC 1925 (1996)
The Twelve Networking Truths

RfC 1926 (1996)
An Experimental Encapsulation of IP Datagrams on Top of ATM IP包通过声音传输,嗯,通讯基本靠吼就是这个了

RfC 1927 (1996)
Suggested Additional MIME Types for Associating Documents

RfC 2100 (1997)
The Naming of Hosts

RfC 2321 (1998)
RITA -- The Reliable Internetwork Troubleshooting Agent

RfC 2322 (1998)
Management of IP numbers by peg-dhcp
RfC 2322 actually is being used successfully at hacking camps like HIP (Hacking in Progress) or the CCCamp. In a different area it is widely (and successfully) used: to handle frequency usage at clubs for RC model planes (cars, ships, ...)

RfC 2323 (1998)
IETF Identification and Security Guidelines

RfC 2324 (1998)
Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0) 超文本咖啡壶控制协议

RfC 2325 (1998)
Definitions of Managed Objects for Drip-Type Heated Beverage Hardware Devices using SMIv2

RfC 2549 (1999)
IP over Avian Carriers with Quality of Service (支持QOS的IP over 信鸽协议- -||)

RfC 2550 (1999)
Y10K and Beyond 有两千年问题,自然也有一万年问题

RfC 2551 (1999)
The Roman Standards Process -- Revision III

RfC 2795 (2000)
The Infinite Monkey Protocol Suite (IMPS)
   This memo describes a protocol suite which supports an infinite
number of monkeys that sit at an infinite number of typewriters in
order to determine when they have either produced the entire works of
William Shakespeare or a good television show. The suite includes
communications and control protocols for monkeys and the
organizations that interact with them.
描述了一个支持无限只猴子坐在无限台打字机前以测试他们能否打出整部莎士比亚的作品或者是肥皂剧本的协议

RfC 3091 (2001)
Pi Digit Generation Protocol(圆周率生成协议,他们还能想出更加没用的浪费电能的方式么?)

RfC 3092 (2001)
Etymology of 'Foo' Foobar的来源(不是那个音乐播放器啦)

RfC 3093 (2001)
Firewall Enhancement Protocol (FEP)

RfC 3251 (2002)
Electricity over IP - Mostly Pointless Lamp Switching (MPLampS)
通过IP协议传送电能

RfC 3252 (2002)
Binary Lexical Octet Ad-hoc Transport (BLOAT)

RfC 3514 (2003)
The Security Flag in the IPv4 Header

RfC 3751 (2004)
Omniscience Protocol Requirements

RfC 4041 (2005)
Requirements for Morality Sections in Routing Area Drafts

RfC 4042 (2005)
UTF-9 and UTF-18
UTF-8不够用咯

RfC 4144 (2005)
How to Gain Prominence and Influence in Standards Organizations
(not sure about this one - real, valid content but not feeling RfC-ish)

RfC 4824 (2007)
The Transmission of IP Datagrams over the Semaphore Flag Signaling System (SFSS)
这次不用信鸽了,用旗语了么?那么我们是不是还能发明个用狼烟的?

RfC 5241 (2008)
Naming Rights in IETF Protocols

2008年11月6日星期四

C++表达式计算

又是给某人写的作业...

#include
#include
#include
#include
#include
#include
#include
using namespace std;
//栈内优先级
map isp;
//入栈优先级
map icp;
//分离表达式
list Tokenize(const string& str,const string& delimiters){
list tokens;
string::size_type delimPos = 0, tokenPos = 0, pos = 0;
if(str.length()<1) return tokens;
while(1){
delimPos = str.find_first_of(delimiters, pos);
tokenPos = str.find_first_not_of(delimiters, pos);
if(string::npos != delimPos){
if(string::npos != tokenPos){
if(tokenPos tokens.push_back(str.substr(pos,delimPos-pos));
}else{
tokens.push_back("");
}
}else{
tokens.push_back("");
}
pos = delimPos+1;
} else {
if(string::npos != tokenPos){
tokens.push_back(str.substr(pos));
} else {
tokens.push_back("");
}
break;
}
}
return tokens;
}
inline bool isNumber(char c){
return c=='.'||'0'<=c&&c<='9';
}
inline bool isSymbol(string op) {
return op=="+"||op=="-"||op=="*"||op=="/"||op=="%"||op=="^"||op=="("||op==")";
}
inline bool isSpace(char c){
return c==' '||c=='\t'||c=='\n'||c=='\r';
}
//格式化&分离表达式
list toExpressionArray(string exp){
string fexp;
const char* data = exp.data();
int idx = 0;
int len = exp.length();
for(;idx char c = data[idx];
if(isNumber(c)){
fexp.push_back(c);
}
else if(!isSpace(c)){
fexp.push_back(' ');
fexp.push_back(c);
fexp.push_back(' ');
}
}
return Tokenize(fexp," ");
}

//中序换前序
list m2l(list m) {
list l;
stack s;
string op;
string y;
s.push("#");
for(list::const_iterator i = m.begin();i!=m.end();i++){
op = *i;
if(op=="")
continue;
if(!isSymbol(op)){
l.push_back(op);
}else{
if(icp[op]>isp[s.top()]){
s.push(op);
}else if(op==")"){
y = s.top();
s.pop();
while(y!="("){
l.push_back(y);
y = s.top();
s.pop();
}
}else{
y = s.top();
s.pop();
while(icp[op] l.push_back(y);
y = s.top();
s.pop();
}
s.push(y);
s.push(op);
}//if2
}//if1
}//for
while(s.top()!="#"){
l.push_back(s.top());
s.pop();
}
return l;
}
//计算
double _calc(double o1, double o2, char op) {
switch(op){
case '+':{
return o1+o2;
}
case '-':{
return o1-o2;
}
case '*':{
return o1*o2;
}
case '/':{
return o1/o2;
}
case '^':{
return pow(o1,o2);
}
}
return 0;
}
//计算前序表达式
double calc(list in){
stack sk;
for(list::const_iterator i = in.begin();i!=in.end();i++){
string op = *i;
if(!isSymbol(op)){
sk.push(atof(op.data()));
}else{
double o2 = sk.top();
sk.pop();
double o1 = sk.top();
sk.pop();
char o = op.data()[0];
double r = _calc(o1,o2,o);
sk.push(r);
}
}
return sk.top();
}
//没用
void printList(list l){
int x=0;
for(list::const_iterator i = l.begin();i!=l.end();i++){
cout<<++x<<":"<<*i< }
}
int main()
{
isp["+"]=3;
isp["-"]=3;
isp["*"]=5;
isp["/"]=5;
isp["%"]=5;
isp["^"]=5;
isp["("]=1;
isp[")"]=6;
isp["#"]=0;

icp["+"]=2;
icp["-"]=2;
icp["*"]=4;
icp["/"]=4;
icp["%"]=4;
icp["^"]=4;
icp["("]=6;
icp[")"]=1;
icp["#"]=0;

string exp;
cout<<"Exp:";
cin>>exp;
list l1 = toExpressionArray(exp);
printList(l1);
list l2 = m2l(l1);
printList(l2);
double r = calc(l2);
cout<<"Result:"< return 0;
}

2008年11月4日星期二

超长字段数据库删除重复记录

今天接到一个CASE,在遥远的德国有一个1.1GB的MYSQL数据库,里面只有一个表,表里记录了若干很大的text字段和Blob字段,要求把某个text字段的重复项删除。(表里有上百万的记录,需要排除重复的字段平均大小在1K左右,带索引)
表结构如下:

DROP TABLE IF EXISTS `cert_db`.`certs`;
CREATE TABLE `cert_db`.`certs` (
`id` int(10) unsigned NOT NULL auto_increment,
`ServerName` varchar(128) default NULL,
`SerialNumber` blob NOT NULL,
`Version` int(10) unsigned NOT NULL,
`NotBefore` datetime NOT NULL,
`NotAfter` datetime NOT NULL,
`CertData` blob NOT NULL,
`IPK_DUMP` blob,
`IPK_N` blob,
`IPK_E` blob,
`Signature` blob NOT NULL,
`SigAlgName` varchar(50) default NULL,
`SigAlgOID` varchar(50) default NULL,
`SigAlgParams` blob,
`SubjectDN` text,
`IssuerDN` text,
`CertDump` text,
`SPK_DUMP` blob,
`SPK_N` blob,
`SPK_E` blob,
`ReallyBAD` char(1) default NULL,
`X509Dump` blob NOT NULL,
PRIMARY KEY (`id`),
KEY `IDX_CERTDN` USING HASH (`SubjectDN`(383))
) ENGINE=InnoDB AUTO_INCREMENT=4515 DEFAULT CHARSET=gbk;

第一次尝试使用如下语句:

delete from certs
where subjectdn in (
select subjectdn from certs
group by
subjectdn
having
count(subjectdn) > 1
)
and id not in (
select min(id) from certs
group by
certs
having
count(certs)>1
)

结果在本地的4000条记录上测试时就华丽的让MYSQL 挂掉了。。
然后使用md5进行索引,分步骤删除,成功:

#hash all
DROP TABLE IF EXISTS hash_all;
create table hash_all(
select id,md5(subjectdn) as dnhash from certs
);
#find dupclited
DROP TABLE IF EXISTS hash_dup;
create table hash_dup(
select id,dnhash from hash_all
group by
dnhash
having
count(dnhash)>1
);
#list rows to delete
DROP TABLE IF EXISTS hash_del;
create table hash_del(
select h.id,h.dnhash from hash_all h,hash_dup d
where
h.id!=d.id
and
h.dnhash=d.dnhash
);
#delete
delete c from certs c,hash_del d where c.id=d.id;
#then clean up
DROP TABLE IF EXISTS hash_all;
DROP TABLE IF EXISTS hash_dup;
DROP TABLE IF EXISTS hash_del;