Friday, April 30, 2010

上海SB会(三)--崇洋媚外

慈禧老佛爷在多年以前,有句名言,“量中华之物力,结与国之欢心”。一副卑颜屈膝的奴像。不过这也全怪不得慈禧,这老女人精明的很,知道洋大人惹不起,大清已经是千疮百孔,早已经不复她老祖宗当年的盛况,再也无法与西方的坚船利炮相抗衡,只好唯唯若若的做小媳妇样。不过,慈禧也算是敢做敢当,既然愿意做小媳妇,她也不怕说出来,还称的上奴才中的正大光明的一分子。

中国人做奴才是有着优秀的光荣传统和悠久的历史,从几千年前的给自己人当奴才,到今天的变着法的讨洋大人开心,也算是与时俱进和科学发展观在现实生活中的一个体现。虽然说,拿破仑曾经说中国是一头睡狮,我不知道拿破仑是否在生物学上有着多高的造诣,因为还有一句话,“老虎不发威,你当是Hello Kitty”.也许拿同学将狮子和kitty混同一般了。

多年以前,有人撒野般的在天安门上喊什么“中国人民站起来了”(实际上是在政协会议上说的。)。似乎,中国人已经不用再讨洋大人欢心,只需要好好伺候好国内的老爷们。谁曾想,有个叫苏联的流氓国家,成为了我们的“老大哥”。斯大林,列宁的画像,一次又一次的通过了天安门,挂在那学校,医院,厂矿。苏联小说,布拉吉,《喀秋莎》充斥着大街小巷。可是好景不长,天安门上的那位,跟他的“老大哥”闹翻了。接下来的十几年里,惴惴不安。多年以后,抓到机会,狠狠的抓上了美帝的手,然后幽默的对日本首相说,“感谢国家,感谢日本天皇,感谢日本人民,感谢苍井空,让我们得到了江山”。

元朝的时候,全国人分为四等:一等蒙古人,二等色目人,三等汉人,四等南人。今天,第一等人,是core,第二等人是洋大人,第三等人就是我等草民了。

这篇有点语无伦次,但不管怎么样,还是要感谢国家,感谢党,感谢CCTV,感谢人民日报,让SB会圆满的SB了。

Thursday, April 29, 2010

这步棋是谁下错的?

作为中国教育制度的受害者,我写过很多篇blog痛骂这些不人道的教育制度。最近看了一些文章和blog,一股无名的悲愤之火从心头升起。我是怒从心头起,恶向胆边生。借着SB会的春风放假之际,在这漆黑无人的夜里,痛诉我的血泪史,矫情一番,借以抚慰我受伤的心灵。

上过国内高中的人,大多数都有这样的经历,在高二的时候会进行文理分班。我的数理化一向都是很好,并且我很讨厌背书,更别说那荒诞无聊的政治。其实我一直以来对历史都很感兴趣,可是每次看到考卷上面的所谓“鸦片战争的意义?”,你得一二三四的列出早已经编好的答案,或是某某某生于几年,再精彩的历史也会变的索然无味。我的高一班主任有一次私底下对我爸爸说,她觉的我报文科可能会更适合我。我当时听了,觉的她怎么会得出这么一个可笑的结论。我的其他老师和同学,都认为我会报理科,无论是从我的成绩还是从我的倾向上来看。我不知道她当时为什么会得出这么一个结论。多年以后,我回想起她当时的猜测,也许是对的。一直以来,我对许多人文学科都抱有浓厚的兴趣,直到现在,我依然在大量购买和阅读历史与人文类的书籍。而我也愿意将时间投入其中。我不知道,如果我一直从这条路上走下去,也许对我会更好一些。可是这万恶的文理分科,让我无从选择。让一个十四五岁的孩子,或是让众多蒙昧无知的中国家长,去为将来数十年的生活做一个重大的选择,本身就是一个很荒谬的选择。当大多数的孩子对自己后几十年的生活根本就还没有个感性和理性的认识的时候,还未对人生,对自己的兴趣有很好的认识和规划,就只给他两条路走,这和将他推到火坑中有什么区别?并不是每个十四五岁的孩子都成熟到能够为自己的未来负责,也不是每个孩子都有着一个能给自己提供有效帮助的开明的家长,更别说中国不同地区的经济发展带来的的教育资源严重分配不均衡的问题。最后为这一切买单的,只能是一届又一届的学生。

高考的时候,我所在的省是先考,然后估分报志愿。相比前几年的,考之前就先报志愿来说,算是一点点的小进步。我当时估分是630分左右。相比与我平时的分数,是个较低的分数。应该是能上厦大,与我一直期望的北大就没希望的。考之前,满怀希望,考完之后,就满不在乎了。我知道我自己,只要不出意外,比如答题卡填错了之类的,厦大之类的我肯定可以考上。稳定点的话,复旦,浙大之类的。如果运气好的话,说不定还可以捞到北大清华的尾巴。厦大也算是能接受的范围,我也就有恃无恐。

人总是有侥幸的心理,厦大不久就不在我考虑的范围之内。范围就缩小到中科大,交大,浙大。我爸爸还带我到我所在中学,他的一个同学那里,三个人分析了半天,最后回家,决定报交大的信息安全。我觉的这是我人生中做的最大的一个错误之一,我至今依旧悔恨不已。其实从我初中开始,我的目标是北大的数学系,当然,梦想破灭之后。我就倾向与中科大以及浙大的物理系。可这时问题来了,周围的亲戚开始给你建议了。比如,中科大在合肥,地方不好,而且待在这种学校只会死读书;物理系这种地方出来不太好早工作;上海这个城市很好;最扯淡的理由是,江XX也是从交大出来的。当然,他们不是反对,而是很委婉的给你建议,最后加上一句,最后的决定权还是你。我这种小地方出来的小门小户人家,没见过多大的世面,觉的交大也算是国内的名校,上海也是中国第一大城市,信息安全这个专业听起来又很拉风,稀里糊涂的就报了。后来听有关人士讲,我的那些老师对我报考交大很不以为然,因为我估分只有630,他们觉的我上不了。我就想,你们当时就不不能提醒一下吗?最后我的成绩是662。我不知道这种惨无人道的报志愿的方式毁了多少人的梦想?多少人生就断送在这条路上?

有的人会说,路是自己走的,哪里读书不是读?当然,这是绝对的。可是对于我这种志大才疏之人,我非爱因斯坦之辈,你如何让我自己开辟一条自己走的路?如果哪里都能读书,MIT就不是MIT了。本科四年,是我痛苦的四年。原本有许多计划,理想的我,硬生生的将四年荒废了。原本就很扯淡的专业,加上假模假样的专业课,混乱不堪的教学计划,虚假浮躁的学风,每当想起这四年的时光,心里总是很难受。人生没有那么多的四年给你挥霍,而这四年又是最黄金的四年。我觉的我选择上海,选择交大,选择信息安全是我最大的错误之一,我本不应该属于这里。有的人会说,我都只强调客观原因,不提主观原因。我是个意志薄弱的人,没有什么耐性,容易受环境影响。这样的情况下,一个好的环境,可能还能帮助我改善。如果当初我不听身边的人讲什么合肥城市不好啊,中科大里都是书呆子之类的混帐话。也许我今天心里会好受一点。

当我刚进交大的时候,一位学长就劝我准备出国,我当时不以为然。现在回想,再次的后悔不已。在人生的选择上,我一次又一次的站错方向。虽未满盘皆输,却已方寸大乱。

劝君莫惜金缕衣,劝君惜取少年时。花开堪折直须折,莫待无花空折枝。

Add/Hide Menu Item in the ECB from SharePoint Items

You add a new custom action to items the Edit Control Block (ECB) menu by using the Features. However, you can not hide a item from the ECB by using the features. But you can use the JavaScript to add or a new item to the ECB.

There is file named core.js in the<%Program files %>\common files\Microsoft shared\web server extensions\12\Template\layouts\1033 which is responsible for rendering.

Add a new item
1.Add a content editor web part to the page.(If you want all the lists and document libraries have the same feature, you can add the script to your master page. )

2.Add the script to the web part(The code snippet came from here)


function Custom_AddDocLibMenuItems(m, ctx) 
{ 
    var strDisplayText = Your display text 
    var strAction = Your action 
    var strImagePath = Your image path   
    // Add our new menu item 
     CAMOpt(m, strDisplayText, strAction, strImagePath);   
    // add a separator to the menu 
     CAMSep(m);  
    // false means that the standard menu items should also be rendered 
    return false; 
}

Hide a item

If you just want to hide menu item in a single list/library, add a content editor like above.

There is a function named AddDocLibMenuItems in the core.js that is used to render the ECB. If can find there are some functions calling in the AddDocLibMenuItems like below

AddCheckinCheckoutMenuItem — Add Check in/out menu item
AddVersionsMenuItem — Add version check menu item
AddSendSubMenu — Add send to menu item

So, if you want to hide the item from ECB, the easiest way is to comment the corresponding function in the AddDocLibMenuItems. But you should not midofy the core.js in the server directly, which would impact the whole farm. If you check the AddDocLibMenuItems, you will find that it would check if the Custom_AddDocLibMenuItems exist. So you can add your Custom_AddDocLibMenuItems function in the content editor, and return true.(Returning true would prevent from calling the default AddDocLibMenuItems).

The only thing you need do is to create a Custom_AddDocLibMenuItems function in the content editor web part, except for this part. If you include this part, it would throw a stack overflow exception. Because it cause a infinite recursive calling.


if (typeof(Custom_AddDocLibMenuItems) !="undefined") 

{ 

    if (Custom_AddDocLibMenuItems(m, ctx)) 

    return; 

}



In my example, I want to hide the menu item–Edit in Microsoft InfoPath. So,I delete two CAMOpt functions in the code. You can find these two lines below.
if (ctx.isWebEditorPreview==0 && ctx.listBaseType==1)
       
{
           
if (ctx.listTemplate==109 && itemTable.getAttribute("IsImage")=="1")
           
{
                strDisplayText
=L_EditInOIS_Text;
                strAction
="EditSingleImage('"+currentItemID+"')";
                strImagePath
=ctx.imagesPath+"oisweb.gif";
                menuOption
=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 240);
                menuOption
.id="ID_EditInOIS";
           
}
           
else
           
{
                setDocType
();
               
if (currentItemAppName !="" && currentItemOpenControl !="")
               
{
              strDisplayText
="";
             
if (currentItemAppName !=" ")
                        strDisplayText
=StBuildParam(L_EditIn_Text, currentItemAppName);
                   
else
           
{
                 
var   objEditor=StsOpenEnsureEx(currentItemOpenControl+".3");
                     
if (objEditor !=null )
                    strDisplayText
=L_EditInApplication_Text;
                       
}
           
if (strDisplayText !="")
           
{
                strAction
="editDocumentWithProgID2('"+currentItemFileUrl+"', '"+currentItemProgId+"', '"
+currentItemOpenControl+"', '"+bIsCheckout+"', '"+ctx.HttpRoot+"', '"+currentItemCheckedoutToLocal+"')";
                            strImagePath
=ctx.imagesPath+currentItemIcon;
                            menuOption
=CAMOpt(m, strDisplayText, strAction, strImagePath, null, 240);
                            menuOption
.id="ID_EditIn_"+currentItemAppName;
           
}
               
}
           
}
       
}



《The Man from Earth》--被时间遗忘的人


两个场景,投资一万美金,数个哈佛教授围坐一起,九十分钟,聊天而已。简单的不能再简单的场景,没有任何的特效。没有打斗,没有激情,只有叙述,简单的叙述,却是一部绝对让人让以忘怀的片子。简单的叙述,透出一股苍凉、古老,却也透露出一骨荒诞不经。前八十几分钟,是在信与不信中徘徊。从原先的荒谬,到惊讶,震惊,当情绪已经接近崩溃的边缘的时候,John说,这只是一个故事。众科学家,有的愤怒,有的如释重负。剧情的高潮,其实不过一分钟。可就是这一分钟,让整部剧活了起来。

在前八十分钟,众教授谈论了生与死,宗教,信仰,人类文明,历史等许多比较终极的问题。这些问题,已经被讨论了无数次,但要是这些问题是从一个生活了14000年的人嘴里说出来,就给了观众更多的思考空间。


Monday, April 26, 2010

上海SB会(二)--Two pictures for fun


上海SB会(一)

去年60大寿的时候,帝都有人为了到街对面的家中,绕了整整两个小时的路,才回到近在咫尺的家中。当帝都人民排着长队在地铁口安检的时候,我暗自庆幸,我是在魔都。时至今日,我才发现我浅薄了,我怎么把SB会给忘了,更不应该的是,我怎么把“普天之下,莫非王土”的古训也给忘了。


Thursday, April 22, 2010

SICP Series-chapter 2.3.3

At first, I put the code here that provided by text book already.
(defun element-in-set(x set)
 
(cond ((null set) nil)
       
((eq x (car set)) t)
       
(t (element-in-set x (cdr set)))))

(defun adjoin-set(x set)
 
(if (element-in-set x set)
     
set
     
(cons x set)))

(defun intersection-set(set1 set2)
 
(cond ((or (null set1) (null set2)) nil)
       
((element-in-set (car set1))
         
(cons (car set1)
               
(intersection-set (cdr set1) set2)))
       
(t (intersection-set (cdr set1) set2))))
2.59
(defun union-set(set1 set2)
 
(cond ((or (null set1) (null set2)) nil)
       
((null (element-in-set (car set1)))
         
(cons (car set1)
               
(intersection-set (cdr set1) set2)))
       
(t (intersection-set (cdr set1) set2))))

;Another method from Eli.
;Forget to use the function provided by language itself
(defun union-setv2(set1 set2)
 
(append set1 (remove-if (lambda(x)(element-in-set x set2)) set2)))
2.60
(defun union-set-dup(set1 set2)
 
(append set1 set2))

(defun adjoin-set-dup(x set)
 
(cons x set))

(defun element-in-set-dup(x set)
 
(member x set :test #'eq))
2.61
(defun adjoin-set-sort(x set)
 
(cond ((null set) (list x))
       
((= x (car set)) set)
       
((< x (car set)) (cons x set))
       
(t (cons (car set) (adjoin-set-sort x (cdr set))))))
2.62
(defun union-set-sort(set1 set2)
 
(cond ((null set1) set2)
       
((null set2) set2)
       
((= (car set1) (car set2))
         
(cons (car set1) (union-set-sort (cdr set1) (cdr set2))))
       
((< (car set1) (car set2))
         
(cons (car set1) (union-set-sort (cdr set1) set2)))
       
((> (car set1) (car set2))
         
(cons (car set2) (union-set-sort set1 (cdr set2))))))
2.63
Yes,they generate the same list.
2.65
The intersection-set-tree is very similar to the union-set-tree.

(defun union-set-tree(set1 set2) 
    (list-tree (union-set-sort (tree->list set1) (tree->list set2))))
2.66
;key and value are functions to get the key and value from a record.
(defun lookup(key set-of-records)
 
(if (null set-of-records)
     
nil
     
(cond ((= key (key (entry set-of-records))) (value (entry set-of-records)))
           
((< key (key (entry set-of-records)))
             
(lookup key (left-branch set-of-records)))
           
((> key (key (entry set-of-records)))
             
(lookup key (right-branch set-of-records))))))