2012年2月4日星期六

HTML codes to put special characters on your Web page

尝试了一下用 LinqPad 把各种诡异的字母转成 Html 编码~结果发现不是左右字符都能转过去~
.net 内置的工具并不能完美的处理所有的Html编码~

字符来源

Query
"A,a,À,à,Á,á,Â,â,Ã,ã,Ä,ä,Å,å,Ā,ā,Ă,ă,Ą,ą,Ǟ,ǟ,Ǻ,ǻ,Æ,æ,Ǽ,ǽ,B,b,Ḃ,ḃ,C,c,Ć,ć,Ç,ç,Č,č,Ĉ,ĉ,Ċ,ċ,D,d,Ḑ,ḑ,Ď,ď,Ḋ,ḋ,Đ,đ,Ð,ð,DZ,dz,DŽ,dž,E,e,È,è,É,é,Ě,ě,Ê,ê,Ë,ë,Ē,ē,Ĕ,ĕ,Ę,ę,Ė,ė,Ʒ,ʒ,Ǯ,ǯ,F,f,Ḟ,ḟ,ƒ,ff,fi,fl,ffi,ffl,ſt,G,g,Ǵ,ǵ,Ģ,ģ,Ǧ,ǧ,Ĝ,ĝ,Ğ,ğ,Ġ,ġ,Ǥ,ǥ,H,h,Ĥ,ĥ,Ħ,ħ,I,i,Ì,ì,Í,í,Î,î,Ĩ,ĩ,Ï,ï,Ī,ī,Ĭ,ĭ,Į,į,İ,ı,IJ,ij,J,j,Ĵ,ĵ,K,k,Ḱ,ḱ,Ķ,ķ,Ǩ,ǩ,ĸ,L,l,Ĺ,ĺ,Ļ,ļ,Ľ,ľ,Ŀ,ŀ,Ł,ł,LJ,lj,M,m,Ṁ,ṁ,N,n,Ń,ń,Ņ,ņ,Ň,ň,Ñ,ñ,ʼn,Ŋ,ŋ,NJ,nj,O,o,Ò,ò,Ó,ó,Ô,ô,Õ,õ,Ö,ö,Ō,ō,Ŏ,ŏ,Ø,ø,Ő,ő,Ǿ,ǿ,Œ,œ,P,p,Ṗ,ṗ,Q,q,R,r,Ŕ,ŕ,Ŗ,ŗ,Ř,ř,ɼ,S,s,Ś,ś,Ş,ş,Š,š,Ŝ,ŝ,Ṡ,ṡ,ſ,ß,T,t,Ţ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

ŧ

Þ

&#222;

þ

&#254;

U

U

u

u

Ù

&#217;

ù

&#249;

Ú

&#218;

ú

&#250;

Û

&#219;

û

&#251;

Ũ

Ũ

ũ

ũ

Ü

&#220;

ü

&#252;

Ů

Ů

ů

ů

Ū

Ū

ū

ū

Ŭ

Ŭ

ŭ

ŭ

Ų

Ų

ų

ų

Ű

Ű

ű

ű

V

V

v

v

W

W

w

w

Ŵ

Ŵ

ŵ

ŵ

X

X

x

x

Y

Y

y

y

Ý

&#221;

ý

&#253;

Ŷ

Ŷ

ŷ

ŷ

Ÿ

Ÿ

ÿ

&#255;

Z

Z

z

z

Ź

Ź

ź

ź

Ž

Ž

ž

ž

Ż

Ż

ż

ż

Best regards,

TimNew
------------
If not now then when?
if not me then who?

Release your passion
To Realize your potential

I am a pessimist, I feel I'm living in a world without light.
But I am also a prayer, I believe I’m going towards a world full of sunshine!

Posted via email from 米良的实验室

2011年11月21日星期一

Chrome Extension Isolation

I met a wield problem today, while I'm developing a chrome extension for our QAs.
I try to inject a script to click a group of specific links on the page. The script runs quite well when I paste it in firebug or chrome script console.
But once it is loaded from extension, it behaves in a strange way.
I spent several hours to figure out the problem. Finally I found the reason seems caused by jQuery function click event not fired correctly.
Then I try to debug the script line by line. And I found the code is indeed being executed. To confirm my assumption, I added an alert there, and it does be fired.
So I decide to publish the anchor object to a global variable(I mean a member defined on window).
Then I found a more wield phenomenon: when I debugger breaks in my script, the variable is being set correctly. But when I try to print the variable in console, the variable become undefined again!!!
I was confused by the result, then I guess the call might be muted by chrome for security reason. Then there should be some permission configuration somewhere.
But after I read every pages related to chrome extension permission configuration,  I still haven't found the answer I wish to found.
Suddenly I saw there are several words said  the extension is running in a isolated environment.
This inspired me that the chrome extension is working in a pattern that different than my understanding.
The content script doesn't manipulates the DOM directly but via a proxy and marshal.
Then it must be the reason why the even isn't fired, the event call couldn't be marshaled.
And the only solution is to inject the script to the page as a part of the DOM. Then the script can interact with the DOM directly.
Then I modified the manifest JSON, make it load a new script as content script, and I use that script insert a script tag to tag to load my original functionality script.
So as a conclusion: chrome extension is running in a isolated sandbox rather than running the DOM. We should remember this all the time, even though chrome makes the content script can access the Some directly. Since there are some limitations in such kinda simulation, such as function call and variable is not marshaled.

Sent from TimNew's Desire HD

Posted via email from 米良的实验室

2011年11月13日星期日

Simple Design

最近TW HR改變了Code Reivew的流程。現在所有應聘者的提交的代碼都會被上傳到一個SVN Server上去,然後大家 Review 完,通過 myTW 的投票機制打分。
其實這份代碼,麼一個 TWer 應該都有寫過,於是不知道從誰開始的,最近突然流行起了把自己當年面試時提交的代碼也上傳到SVN,然後讓大家幫忙 Review。

於是我也就跟風了一把~把我的代碼也搞上去了~
然後也看了看別人的代碼。

很有意思的是發現肖鵬的代碼有兩份,一份是當年面試提交的,另外一份應該是近期寫的。兩種完全不同的風格~
還有就是光磊的代碼,Java版,3個類搞定~

對比肖鵬的新版本和光磊的代碼~
我覺得我面試的那份代碼簡直就是 Over Design 和 Tricky Code 的絕佳範例!
一個小小的面試題裡,我居然實現了一個輕量級的依賴注入框架,一個輕量級的 RX 推送框架,以及一個 Message Bus 系統~
然後外部依賴也多到嚇人,xUnit,Moq, MVVM.Light, System.Windows.Interaction, Expression.Drawing, 最要命的是還有一個對 Code Contract的運行時編譯器 ccrewriter 的依賴,木有這玩意兒,不要想把代碼編譯過去!唯一值得慶幸的是,這些依賴大部分,能添加的都被我通過 Nuget 在編譯時進行自動下載了~

在看了光磊的極簡風格的代碼後,我就在想,當年的代碼風格確實是走上了一條不歸路。於是造就了這份連傳說中號稱無所不能的新哥也說看不懂的代碼~
現在看來,確實,這樣的代碼,不僅讓讀的人痛苦,也讓寫代碼的我無比痛苦~
最無語的,我現在已經不是很明白代碼的一些細節地方為什麼是那麼寫的了~而這時間,僅僅過去了幾個月而已~~

於是,我效仿,肖鵬同學,按照我現在的理解,寫了一個第二版出來。感謝 Scott Robinson 的那次169字符的打賭,在學習了無數超精簡的代碼版本後,我的第二版代碼也極大的精簡了。最讓我開心的是我徹底的在代碼裡去掉了傳說中的Switch Case~在Enumeration不支持定義方法和進行重載的 C#裡,我也寫出了近似於 Java 那樣精簡的代碼~ 當然,也利用了一些 Java 所沒有的 C# 特性~

最有意思的事情是,上次寫這個代碼,花了我整整三天,每天都還搞到 11 點半以後~(最後還是沒有足夠的時間去設計GUI的配置界面,於是及其 Tricky 通過在 WPF App 中重用了 Console 版的配置輸入解析模塊,於是造就那個從命令輸入參數,在GUI控制流程和渲染動畫的詭異應用~)
而這次,我僅僅花了4個小時,就搞定了所有的代碼~時間大概只花了原來的1/10~而且明顯代碼可讀性和可維護性都有了極大的提高~由於設計很簡單,所以可擴展性和靈活性在一定的修改前提下,也是不錯的~
相比之前那種通過大而全的框架去保證靈活性和可擴展性的方法來看,Simple Design 有著其非常獨特的優勢~

這是我第一次通過實踐,真正的見證了Simple Design 的強大~也讓我對這Simple Design的Simple有了更深一層的理解~Simple Design其實並不Simple~

Best regards,

TimNew
------------
If not now then when?
if not me then who?

Release your passion
To Realize your potential

I am a pessimist, I feel I'm living in a world without light.
But I am also a prayer, I believe I’m going towards a world full of sunshine!


Posted via email from 米良的实验室

2011年10月13日星期四

Chrome Remote Desktop is amazing

Google Chrome Remote Desktop Extension is really amazing!!!!!
I try to install the extension on both Chrome on my iMac and the one on my laptop with Win 7.
Then I try to connect the iMac from Win 7 via Chrome Remote Desktop!
The performance is really amazing!!!! It is less well than Windows RDP but much better than the famous but sucks VNC!!!!!
I totally have no idea how Google implemented this! But it do works super well in my environment!

Chrome_remote_desktop_control_

You know, before Chrome Remote Desktop, there is only one real cross platform remote desktop solution: VNC, and the performance of which is unacceptable poor, and we have to install a lot of ugly software to make it happen.
 But now, we can achieve it by simply install chrome and the chrome extension....
It is amazing!

I found the desktop fade in animation works smoothly via remote desktop! And I can even play movie from Mac!!!!!
Chrome_remote_desktop_play_vid
While playing video, the peak of the network traffic might be reach 800kBps to 1MBps... but normally it should be 300 kBps.....

But since it is only the beta version, so there are some limitations in Chrome Remote Desktop:
1. The Hotkey doesn't work well, which means you cannot Press Cmd+Space to pop up quick-silver or spot-light...
2. Mouse Wheel doesn't work well, which means you cannot scroll the page with your mouse wheel, or magic mouse.
3. Sound doesn't bring to remote side, if you wanna play movie with Chrome Remote Desktop, then you might be have to read the subtitle rather than hear the speech.
4. CPU consuming is high, I guess Chrome Remote Desktop spend a lot of CPU power on compressing the data to be transferred, so the CPU consuming is higher than other Remote Desktop solution......

And special Precondition required for Chinese Netizens:
If you are try to use Chrome Remote Desktop in China, this miracle land, you might need some other special technology tool to help you get rid of the famous GFW. To my experience, sometimes Remote Desktop OAuth might be blocked by GFW. 

Best regards,

TimNew
------------
If not now then when?
if not me then who?

Release your passion
To Realize your potential

I am a pessimist, I feel I'm living in a world without light.
But I am also a prayer, I believe I’m going towards a world full of sunshine!


Posted via email from 米良的实验室

2011年9月19日星期一

Incredipede:一个神奇的游戏

http://incredipede.com/

这真的是一个神奇的游戏,代码估计是用 C# +  Farseer 物理引擎写的!
这创意绝了~
游戏是要求玩家创造一个生物,然后生物重复某种动作,不断前进。当它卡住的时候,玩家可以改造这个生物的形态,然后让它继续前进~

Best regards,

TimNew
------------
If not now then when?
if not me then who?

Release your passion
To Realize your potential

I am a pessimist, I feel I'm living in a world without light.
But I am also a prayer, I believe I’m going towards a world full of sunshine!


Posted via email from 米良的实验室

2011年9月16日星期五

TDD vs Natural Selection : Part II

As discussed in previous part, both TDD and natural selection can produce suitable designs. But there are costs.
The design from mayual selection is just perfect, but the cost is 99% unsuitable species die out. It is the cost of life.
Same to TDD, except TDD isn't so cruel. If you try to write a piece of code in TDD and pure factoring way, which means all the designs are in order to eliminate smell. And you might find that to eliminate the smell sometime is not so easy that you can have it done in minutes. You might need several tries to find out the most proper approach, since you might find that you just introduced a new, and maybe more serious smell while you eliminating a smell. Sometimes you might find that the upcoming new smells just drive into a dead road, and you just want revert the changes and retry from a fresh start. In worst case, you might find you can hardly find the right way, and you just got lost in the code.
In some simple project, you might find the situation is just acceptable, but in some complex project, you can hardly do that or you might find at the  end of the day you and your pair produced nothing with great effort.

So in my opinion, TDD doesn't mean no design at all. When you practicing TDD, you must focus on the detailed code. At this time if you can easily got lost without the guide from a clear, more general, high level vision. It just works like the architecture design or general solution to specific type of problem.

Such design can save you tons of time wasted on times of retries.

Sent from TimNew's Desire HD

Posted via email from 米良的实验室

2011年9月14日星期三

FluentAssertion is not compatible with xUnit.Extensions

I met a weird problem that I found the Resharper Test Runner hangs when I introduced theory test case in my unit test. 
After some spikes, I found the problem seems caused by the incompatibility between FluentAssertion(http://fluentassertions.codeplex.com/) and xUnit.Extension (http://xunit.codeplex.com/).
It is wired, and there seems to be no quick fix.
So I replace the Fluent Assertion with Should and Should.Fluent(http://should.codeplex.com/), which is a port of ShouldIt(http://code.google.com/p/shouldit/). 
After that, everything goes well except the syntax between Fluent Assertion and Should Fluent are not compatible with each other, although they're really similar.
But Should.Fluent doesn't support something.Should.Be(), it requires something.Should.Be.Equals(), which is really annoying to me.

According to the Fluent's introduction, Fluent is a direct fork of xUnit. And I'm not sure what's the impact caused by this.

Best regards,

TimNew
------------
If not now then when?
if not me then who?

Release your passion
To Realize your potential

I am a pessimist, I feel I'm living in a world without light.
But I am also a prayer, I believe I’m going towards a world full of sunshine!


Posted via email from 米良的实验室

2011年6月9日星期四

[O'Reilly ONLamp Blog]What ever happened to IPv5?

Because i work on small IP things, I’m constantly asked — “Will they do IPv6?” “You know, 32-bits aren’t enough for light switches… What about IPv6?” “You’re not cool until you can do IPv6!” I know, I know. IPv6, whatever. Yes, of course they will do that.

But, what ever happened to IPv5?

IPng, Internet Protocol next generation, was conceived in 1994 with a goal for implementations to start flooding out by 1996 (yeah, like that ever happened). IPv6 was supposed to be the “god-send” over the well-used IPv4: it increased the number of bytes used in addressing from 4 bytes to 16 bytes, it introduced anycast routing, it removed the checksum from the IP layer, and lots of other improvements. One of the fields kept, of course, was the version field — these 8 bits identify this IP header as being of version “4″ when there is a 4 in there, and presumably they would use a “5″ to identify this next gen version. Unfortunately, that “5″ was already given to something else.

In the late 1970’s, a protocol named ST — The Internet Stream Protocol — was created for the experimental transmission of voice, video, and distributed simulation. Two decades later, this protocol was revised to become ST2 and started to get implemented into commercial projects by groups like IBM, NeXT, Apple, and Sun. Wow did it differ a lot. ST and ST+ offered connections, instead of its connection-less IPv4 counterpart. It also guaranteed QoS. ST and ST+, were already given that magical “5″.

And now as the Internet clock ticks, our PCs don’t use IPv5. So we’re moving onto 6.

Posted via email from 米良的实验室

2011年5月25日星期三

Push Data Flow Model in C# 4.0

In the pri 4.0 era, there are two interfaces reveal a new world to .net world. The two hero are IEnumerable<T> and IEnumerator<T>.
Based on these two interfaces, .net introduced a lot of amazing staffs that dramatically simplified the development related to data flow, these well known features are: foreach loop, yield keyword, and LINQ.
These 2 interfaces provide an common abstraction layer for the operation that pull data from the data source. And with this abstraction, you can apply foreach loop to almost every kind of data source in the .net world.
IEnumerable<T> and IEnumerator<T> are cool, but they are somehow not so convenient to use in some cases, such as in asynchronous context or in obvious latency environment.
And the pull data flow model also has a capable brother, the push data flow, which can fill up the gap that pull model left for us.

So in .net 4.0, Microsoft introduce another 2 great interfaces, called IObservable<T> and IObserver<T>. These two interfaces, just as IEnumerable<T> and IEnumerator<T>, also open a door to the new world for every .net developer. With these 2 interfaces, people can setup a lot of features that corresponding to IEnumerable<T> and IEnumerator<T>.

Now Microsoft has a great library that called Rx(which stands for "Reactive Extension"), which provided a lot of features that similar to LINQ and more based on IObserable<T> and IObserver<T>.

Best regards,

TimNew
------------
If not now then when?
if not me then who?

Release your passion
To Realize your potential

I am a pessimist, I feel I'm living in a world without light.
But I am also a prayer, I believe I’m going towards a world full of sunshine!


Posted via email from 米良的实验室

[LeeCampbell] My WPF Charting Comparisons

My WPF Charting Comparisons

I have recently been looking for some graphing/charting functionality for a home project I am working on. My requirements are fairly simple:

  1. handle data quantities in the region of thousands and tens of thousands of rows/items
  2. be able to display line charts with or without data points (there will be so many data points that they can become noise)
  3. be able to display multiple sets of data to be able to compare data
  4. free or cheap
  5. xcopy install

Now as the Charting products I wanted to compare were all going to be in WPF I assumed that these requirements were just a given but apparently not, so let me specify them as well

  1. be able to bind the data from my own view model (i.e. I don’t want to have controls littering my View Model)
  2. have the graph update as the data changes

Now to see the list of contenders:

So for the really quick review of each

WPF Toolkit Charting

This is the CodePlex project from some of the lads at Microsoft. This is presumable of a lesser quality than the rest of the Toolkit as the Charting component is in preview. The WPF Toolkit allows for great looking charts by utilising the power of WPF Styles. It is one of those balancing acts that must be difficult to make when designing software; extensibility vs. simplicity. The WPF Toolkit leans more towards the extensible option. Extending the charts to look the way you want can be done but many will find it fiddly and frustrating, but once done can be very rewarding and the Graphs can look amazing. The WPF Toolkit also utilises the power of WPF binding by allowing me to bind to my ViewModel. So it looks like a good start, however, the clear and painful problem with the WPF Toolkit is performance. When loading up even hundreds of rows/items the performance is fairly poor. When I tried to throw just over a thousand items at a Line Series the performance was completely unacceptable. One other problem I have is that I get intermittent lock ups. When updating the data, the charting code will run off into a loop and not come out of it, freezing the UI. Hmmm another cross.

Positives:

  • Extensibility allows for beautiful graphs
  • Charts bind to ViewModel
  • Free

Negatives:

  • Woeful performance
  • Random lock ups.

AmCharts

AmCharts appears to be a Charting solution aimed at the financial industry. The chart control that I thought would best fit my needs was the Stock chart. This chart had a great feature that allowed zooming on the X-axis by providing a range slider. Performance was great when I threw ~1500 items at the control. An odd problem I had was the graph would only appear once I resized my window. I think this has to do with binding to a ViewModel as the Demo does not have this problem but it also directly interacts with the control from the Code behind. I want to avoid “messing with controls” from my ViewModel. A more real problem I have is that while the performance is great, the binding seems to be a once off event. Changes to the values in my collection are not reflected by any change to the chart.

Positives

  • Good performance
  • Charts bind to ViewModel
  • Zoom functionality
  • Good samples
  • Smallest DLL size (223KB)

Negatives

  • One time data binding
  • Odd problem with Chart not rendering until i resized the window.

Visifire

VisiFire charts looked to be a great option. They were very easy to get up and running, had some good samples like the AmCharts. My first play with the Visifire charts provided me with a good looking chart. My problems came when I went to bind the Charts to my ViewModel…Visifire does not support data binding! I’m not even sure why someone would write a WPF control that does not support data binding. I wasted plenty off time writing some adapters so that I could get data binding working. Data binding is in the wish list for version 3 (how it didn't make it into the wish list for the 1st version I don’t know). Performance of Visfire was pretty good (not spectacular) and sat in between AmCharts and the hopelessly slow WPF Toolkit.

Positives

  • Easy to get up and running
  • Pretty good looking default charts
  • Moderate performance

Negatives

  • You cant bind a data series to a collection!

Dynamic Data Display

The Dynamic Data Display (aka D3) is another Microsoft project on Codeplex from a Microsoft research team in Russia. D3 authors claim outstanding performance even with massive amounts of data. Sounds like a sure fire winner! The control library also supports different types of charts to the other libraries like Maps and Isolines ( I have no idea what an isoline is). The samples show some good stuff with smooth moving animated graphs with dynamic data points. The big fail on the project is again, no data binding. All manipulation of the charts needs to be done in C# code and needs to be very imperative. There are some guys, however, who have made posts creating an extension to the controls to support data-binding. Either way, while this looked to be a good set of controls, the authors don’t appear to have followed the Pit-of-Success principle. I would go in to details, but the fact it took me hours of reading forums, looking at samples and coding to just get my Model showing on the screen. When it did get on to the screen it was fast, but didn’t update when the underlying data changed. This is a very immature set of controls but may have a bright future if the team can get some fundamentals right.

Positives

  • High performance
  • Easy to scroll and zoom data

Negatives

  • Hardest set of controls to work with. Everything has to be done in code. Authors seem to miss the point of WPF entirely. Presentation and logic feel very much couple together.
  • After all my mucking around the chart didn’t update with my changes to the data.

In summary, I am pretty disappointed with the state of all of these charting controls. What I did manage to get working to a satisfactory state was the WPF Toolkit. As the only real problem I had with the WPF Toolkit charting controls was their performance; I decided that an easy way to get some better performance out of the control was to only show as many data points as there were available pixels. If I only have 400 pixels to show my data it becomes a bit silly to try and get the graph to render 1400 data points. I created a Custom Control that extends CollectionViewSource by having a MaxItemCount property that can be set to effectively filter the amount of data the CollectionViewSource reveals to the Charting controls. The performance was better but I was able to further tweak the performance by adding a DivisionConverter to further reduce the collection size by the parameter specified (10 in my case). This means I only show a data point for every 10 pixels wide the chart is. This ended up being a great compromise….except for the random lock ups. If I play on the Chart for long enough changing the data to update the chart, eventually the program just falls in to a loop. If I can solve this bug I may have a winner on my hands. Ed:—Playing around more I may have got rid of this problem. Still pops up sometimes straight after a build, but a restart fixes it. This may be to do with my build of Win7 (pre release that I am still running). This throws the WPF Toolkit +the 2 tiny bits of filter code clearly into the lead as it can be made to look great and handle tens of thousands of rows.

If any one is interested in the code I used to test/play with each of these libraries you can find a zip of the VS2008 solution here. To see any of the spikes, just set it as the start up project and run or Right click on the project and “Debug”—> “Start new instance”. Only the MyDomain project wont run as that is the Class library that has the small part of the domain to test the charts with.

ChartingPlaygournd.zip – Source code for my tests.

Posted via email from 米良的实验室