星期五, 十二月 23, 2011

Serialize and DeSerialize generic Array

We often use things like Configuration[] configs and like to manage that in a xml file you can edit. Two simple extension methods can help you.

        public static string SerializeArray(this T[] list)
        {
            System.Xml.XmlDocument doc = new XmlDocument();
            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(list.GetType());
            System.IO.MemoryStream stream = new System.IO.MemoryStream();

            try
            {
                serializer.Serialize(stream, list);
                stream.Position = 0;
                doc.Load(stream);
                return doc.InnerXml;
            }
            catch { throw; }
            finally
            {
                stream.Close();
                stream.Dispose();
            }
        }

        public static T[] DeSerializeArray(string serializedData)
        {
            T[] list = null;
            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(T[]));
            XmlReader xReader = XmlReader.Create(new StringReader(serializedData));

            try
            {
                list = (T[])serializer.Deserialize(xReader);
            }
            catch
            {
                throw;
            }
            finally
            {
                xReader.Close();
            }

            return list;
        }


Code to serialize the data:

string xml1 = _environments.SerializeArray();
StreamWriter writer = new StreamWriter("config.xml");
writer.Write(xml1);
writer.Close();

To DeSerialize the data:

string xml = File.ReadAllText("config.xml");
_environments = Extensions.DeSerializeArray(xml);



If you don't like the root "ArrayOfConfiguration" you can change the extension methods to use a XmlRootAttribute like:
            XmlRootAttribute root = new XmlRootAttribute(rootName);
            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(T[]), root);

You need to use the matching name in both methods to get it working.

星期五, 十二月 16, 2011

S.C.A.M 9

Government should ban union's enforcement at work. So every one can be part of an union at work or choose not to be. Same thing for doctors and lawyers. They shouldn't only allow those permitted by the committee or bar

星期一, 十一月 14, 2011

枪和玫瑰演唱会归来












从groupon买的便宜票座位还可以,岁数大了,想起来如果真要在下面站5个小时,估计会累得够呛。6点开车出发,拿了票去看了电影Immortals,希腊神话的动作片,情节比较弱,看完了快9点,正好进场。开场之前放音乐就感觉音响效果不够好,暖场乐队Adelitas Way的演唱就很难挺清楚,唱了一个小时,后面还号召大家抽大麻什么的,有够傻。不过快结束时候一个有50岁的大姐就在过道上面抽大麻,等自己的儿子女儿过来... 后排也有抽东西的,多半也是大麻...

开始之前有人拉了条幅"Slash is in the house",可惜照不清楚,演出到后来就看不到了,估计被保安撤掉了。











Axl Rose按照惯例放大家鸽子一个小时,11点多才出来。不知道是因为后来重新调了声音,Axl的演唱倒是基本都能听清。唱新专辑的歌就在大屏幕显示很多不通顺的中文,Chinese Democracy这首放对应的中文歌词,包括“我有更多的手淫”...

Welcome to the Jungle  /  It’s So Easy  /  Mr. Brownstone  三首老歌,全场沸腾了,持续起立跟着唱...周围好多40岁左右的老家伙,还颇有些带着孩子来的,感觉15岁以上的孩子带过来还凑合,10岁的小孩子也有带来的,不是很合适,对耳朵也不好。我后面的夫妻和旁边的人说是他们儿子给买得票...

Sorry 这首报纸也给漏掉了

Riff Raff (AC/DC cover)  这首不熟,效果也不好,听他唱Riff Raff,还以为是唱Rock Rock Rock

Estranged 这首好长

Better  /  Richard Fortus guitar solo 这些没啥感觉

Live & Let Die 相比appetite for destruction来说平淡了点

This I Love 现场感觉也比CD好听

Rocket Queen  最近最喜欢的三首老歌之一

My Generation (Who cover, Tommy Stinson on vocals)  过道左边有个SB,暖场时候就在不停的骂,估计是大麻抽多了,唱到这里有满嘴F**k,坐下面的老哥带着儿子受不了了,让他闭嘴还不听,还把脸凑上去骂。然后被那个老哥把衣服拉烂掉了。我后面的女的说:skinny is going to get punched. 不过没打起来,再下面一个女的叫来了保安,把这个惹事的家伙和他的同伴都拉出去了。

还看到有人带保安到更下面去,不过没看到纠人出来 。底下grand stand也看到过一阵骚动,保安拿着手电照着什么,不知道是不是那个可怜的偷爬上台然后跳下来没人接的胖子。

Dizzy Reed piano solo  原来的GNR就剩他和Axl还在了,没想到有个吉他是从Soul Asylum过来的

Street of Dreams  这个也是新专辑的歌,还以为是use your illusion里面的,风格很像

You Could Be Mine 很商业化的一首,终结者2的主题歌

Sweet Child O’ Mine 电台最常放的一首

Another Brick in the Wall Pt. 2 snippet (Axl on grand piano) 这段钢琴的时候,屏幕上面一直在播下面两个女的舌吻...














November Rain Axl之前大段的钢琴独奏,总有点跑调的感觉,不过在11月唱这个歌实在很应景

DJ Ashaba guitar solo   / Don't Cry 这首也被报纸漏掉了

Whole Lotta Rosie (AC/DC again) 完全听不出来唱的什么

Bumblefoot guitar solo  / Knockin’ on Heaven’s Door  

Nightrain 很喜欢这个的chorus,合唱很给力

ENCORE: Madagascar  /  Shackler's Revenge 

Patience 很喜欢的几首Rocket Queen, Sweet Child O's Mine和这首都在前面歌曲结束以后有段旋律部分,开头的口哨更是超级喜欢,虽然现场感觉吹得改了调...

开始看到舞台两侧有两片红色的东西,后来充起气来,一边是耄头像,另外一边是只手,感觉耄 做的不是很像,记得Axl当年就在胳膊刺了耄头像。

照片最清楚的只有这么一张,可以看到耄的充气头像,
某段字幕从下往上滚动,看了半天才发现是:












Paradise City收场,最后2点多,Axl整场都没说太多的话,没有演唱的部分就往后台跑... 结束之后还上来谢幕,全场说是来了8000人,应该是坐了一半的左右,也还算不错了。

基本上每首歌都录了15-20秒视频,效果都不是很好,亮度太低,照片效果更糟,到了最后一首诗后一个工作人员说不能录像,但是放眼看去,全场都是在用手机拍的...好在录了视频,对照报纸的set list,找到一些不同。

回家路上想着这种车不多的时候就容易被抓超速,我前面一个车比我快那么一点,警车就从我昨天呼啸的高速过去开灯抓人...

星期五, 十一月 11, 2011

星期四, 十月 06, 2011

S.C.A.M 8

Our education system taught us a lot basic science and social stuff. Is it really something we need? College provides us a lot knowledge if we decide to be a scientist or researcher. Can all of us become scientist or researcher? Maybe we should have classes to teach high school students to be a plumber, carpenter, mechanics or electrician. It doesn't mean that they will have to work in those professionals, but isn't it nice to have the skill to fix stuff yourself or be a really skillful worker in related area? Japan can utilize 'robots' to build better cars. Why can't US have factories like that? Where workers are skillful mechanics who can build and repair machines which create high quality vehicles. Instead of those cheap labor to move pieces around?

星期四, 八月 25, 2011

Evangelicals and Israel: Theological Roots of a Political Alliance

by Donald Wagner
Donald E. Wagner teaches at North Park University in Chicago. He is the author of Anxious for Armageddon (1995) and Dying in the Land of Promise: Palestine and Palestinian Christianity from Pentecost to 2000 (revised edition, 2003). This article appeared in The Christian Century, November 4, 1998, pp. 1020-1026. Copyright by The Christian Century Foundation; used by permission. Current articles and subscription information can be found at www.christiancentury.org. This article prepared for Religion Online by Ted & Winnie Brock.

星期三, 八月 24, 2011

"The single most important thing we want to achieve is for President Obama to be a one-term president," McConnell told the National Journal last year.

Read more: http://www.foxnews.com/us/2011/07/26/top-4-in-congress-not-so-fab-on-debt-deal-yet/#ixzz1VyJd34d6

星期二, 八月 23, 2011

到一个哈佛法学院的人找女友的标准是‘“Sensible, not sensitive; simply complicated; predictably irrational; kindly demanding; constructively critical; certain of uncertainty; managing risks; helplessly hopeful; persistent, yet flexible ”法学院男生说话就是让人晕。

“敏而不疑,缜而不繁;娇而不横,求而不奢;诤而有益,谋而有断;处危有度,历难有瞻;其节如松,其韧若竹。”

星期三, 八月 17, 2011



You Might Be A Conservative If…

[show/hide]

星期五, 八月 12, 2011

S.C.A.M 7
Mitt Romney says ‘corporations are people’ at Iowa State Fair
I think rich people like him should pay more tax. Also big corporates should have AMT as well, so that big companies don't have any loop hole to use. This will also encourage small start ups and local business.

星期三, 八月 10, 2011




C# and .NET interview questions



[show/hide]

星期二, 八月 09, 2011

星期一, 八月 08, 2011

星期四, 八月 04, 2011


《哈利波特》人名各有深意 J·K·罗琳费尽心思


[show/hide]

星期五, 七月 29, 2011

S.C.A.M 6
Government budget should be associated with revenue and all items should be prioritized. Divided by percentage threshold and if revenue is below certain threshold, those things will not be paid. Government official and legislature salary, expense and benefits should have the lowest priority.

星期五, 七月 22, 2011


红军长征史上最惨烈的一战:喋血湘江


[show/hide]

星期一, 七月 18, 2011




Tutorials on WPF


[show/hide]

星期四, 七月 14, 2011

S.C.A.M 5
State government shouldn't be allowed to have a budget that borrows against future or causing future deficient. A budget should have a budget priority requirement that is associated with state tax income, the last priority should be legisture/government salary and benefit, including any service they get.

星期三, 七月 13, 2011



《我在赶集网的两个月》(完整版)


[show/hide]

星期二, 七月 12, 2011

twin city有很多打球的地方/俱乐部,看你住在哪儿了。
可以查查这个:
http://www.minnesotabadminton.com/p/places-to-play.html

星期五, 七月 08, 2011

S.C.A.M 4
Education reform, no child left behind just doesn't make any sense; students themselves and their parents should be motivated to make more effort to study hard, work hard otherwise they should take the responsibility of their own failure. 


National Endowment for Democracy: Paying to Make Enemies of America

[show/hide]

星期二, 七月 05, 2011

St. Paul City Council to oppose Vikings stadium plan | StarTribune.com

St. Paul City Council to oppose Vikings stadium plan | StarTribune.com
state legislators have problem when raising tax for the rich, but they have no problem when raising tax on everybody for the rich?

星期四, 六月 30, 2011

乡干部强行登台与女歌手互动遭拘留_新闻中心_新浪网

男子性侵15岁男孩无法定罪被拘15天_新闻中心_新浪网

男子性侵15岁男孩无法定罪被拘15天_新闻中心_新浪网 "无法可依,有法不依,执法不严,违法不究"


没希望工程

[show/hide]

星期二, 六月 28, 2011

中国铁建沙特亏损项目将由国家埋单
这么严重的渎职行为,没有相关人员被判刑么?

星期一, 六月 27, 2011



忽然明白了 为什么跑步机上跑得容易

[show/hide]

星期日, 六月 26, 2011

英国青年发明人力洗衣机:骑自行车洗衣服(图)

把轮子架起来,就可以在原地洗衣服了。

星期五, 六月 24, 2011

TREADMILL RUNNING - Training With Dr.Romanov

TREADMILL RUNNING - Training With Dr.Romanov
"The difference between running on the treadmill and running over ground can be discussed from mechanical, biomechanical and physiological points of view.

From the point of view of mechanics there is no difference between belt moving under our feet and our body moving forward in over ground running provided the velocity is the same. Indeed we are operating here with the same speed and consequently with the same forces on the ground and the same muscular efforts.

While it doesn't matter for mechanics which of the interacting bodies is moving: the belt or the body, it is not so for biomechanics. It makes a big difference there. The major one lies in the fact that in treadmill running, unlike over ground running, our upper body is not moving forward, it's our feet that are moved backwards by the running belt. This difference creates a different bio-motor pattern of the movement, where we have to produce some (otherwise undesirable) activity of the upper body to keep it against tipping over the support foot on the belt of the treadmill in order to keep the body in balance. So we have to hold our body to keep it from falling forward and we have to catch the running belt instead of our falling body. "

Oriental (Asian ) Vegetable Seed-AgroHaitai Ltd, Ontario Canada

Oriental (Asian ) Vegetable Seed-AgroHaitai Ltd, Ontario Canada: "- Sent using Google Toolbar"

星期三, 六月 22, 2011

‎"That one got a 'pants on fire' rating -- kind of like the filet mignon of bullsh*t." -- Jon Stewart listing false statements made by Fox News http://on.cc.com/jmxXHo
 http://www.thedailyshow.com/watch/tue-june-21-2011/fox-news-false-statements
S.C.A.M 3
Heard that who ever claimed disability, including mental disability might get $2500/month from government. That's way too easy for people to try to false claim stuff. Why cannot they require those people who have mental or other disability to live in a government facility and most of that money will be used to pay for the facility? The rest can be credit they can use on approved items in the facility. Then they can receive more proper care instead of living on their own. I doubt people without real disability will want it too. Same for low income people who get food stamp and money from government, I think they should be forced to join the communion so they can get trained and work for other people to receive food stamp that can be only used in the communion for what's approved. This way there will be less chance they can sell their food stamp to buy alcohol and drugs.

星期二, 六月 21, 2011

在另存为…对话框中添加快捷方式

Download Skype Video Call on Android

Download Skype Video Call on Android: "- Sent using Google Toolbar"


《水泊梁山那些基情燃烧的岁月:山寨大国里富二代与穷二代的战争》

[show/hide]