Posted via email from 米良的实验室
2012年3月18日星期日
Enhanced typeof() operator in JavaScript
2012年3月15日星期四
Distribute files to multiple servers via scp
The most common task when operating the servers is to distribute a file to multiple servers.
So I wrote a piece of shell script to solve this problem:
- #!/bin/bash
- echo "mscp <source file> <target dir>"
- SourceFile=$1
- TargetDir=$2
- echo "Copy $SourceFile to $TargetDir as $RemoteUser"
- echo "Enter the servers:"
- if [ -f $SourceFile ]
- then
- printf "File found, preparing to transfer\n"
- while read server
- do
- scp -p $SourceFile ${server}:$TargetDir
- done
- else
- printf "File \"$SourceFile\" not found\n"
- exit 1
- fi
- exit 0
call the script "mscp <source file> <target dir>", then the script will ask you the list of target servers. So you can type them one by one. If the remote user is different than you current user, you can also explicitly identify it by typeing user@server
Beside the previous scenario, there is a more common sceanrio, that you have got a server list stored in afile already. Then instead of type the servers line by line, you can pipe the file content to the script.
e.g: cat server_list.txt > mscp src_files dest_path
Posted via email from 米良的实验室
2012年2月4日星期六
HTML codes to put special characters on your Web page
"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,Ţ,ţ,Ť,ť,Ṫ,ṫ,Ŧ,ŧ,Þ,þ,U,u,Ù,ù,Ú,ú,Û,û,Ũ,ũ,Ü,ü,Ů,ů,Ū,ū,Ŭ,ŭ,Ų,ų,Ű,ű,V,v,W,w,Ẁ,ẁ,Ẃ,ẃ,Ŵ,ŵ,Ẅ,ẅ,X,x,Y,y,Ỳ,ỳ,Ý,ý,Ŷ,ŷ,Ÿ,ÿ,Z,z,Ź,ź,Ž,ž,Ż,ż".Split(',')
.ToDictionary(k=>k,HttpUtility.HtmlEncode)
Result 5Dictionary<String,String> (304 items) | |
| Key | Value |
|---|---|
| A | A |
| a | a |
| À | À |
| à | à |
| Á | Á |
| á | á |
| Â | Â |
| â | â |
| Ã | Ã |
| ã | ã |
| Ä | Ä |
| ä | ä |
| Å | Å |
| å | å |
| Ā | Ā |
| ā | ā |
| Ă | Ă |
| ă | ă |
| Ą | Ą |
| ą | ą |
| Ǟ | Ǟ |
| ǟ | ǟ |
| Ǻ | Ǻ |
| ǻ | ǻ |
| Æ | Æ |
| æ | æ |
| Ǽ | Ǽ |
| ǽ | ǽ |
| B | B |
| b | b |
| Ḃ | Ḃ |
| ḃ | ḃ |
| C | C |
| c | c |
| Ć | Ć |
| ć | ć |
| Ç | Ç |
| ç | ç |
| Č | Č |
| č | č |
| Ĉ | Ĉ |
| ĉ | ĉ |
| Ċ | Ċ |
| ċ | ċ |
| D | D |
| d | d |
| Ḑ | Ḑ |
| ḑ | ḑ |
| Ď | Ď |
| ď | ď |
| Ḋ | Ḋ |
| ḋ | ḋ |
| Đ | Đ |
| đ | đ |
| Ð | Ð |
| ð | ð |
| DZ | DZ |
| dz | dz |
| DŽ | DŽ |
| dž | dž |
| E | E |
| e | e |
| È | È |
| è | è |
| É | É |
| é | é |
| Ě | Ě |
| ě | ě |
| Ê | Ê |
| ê | ê |
| Ë | Ë |
| ë | ë |
| Ē | Ē |
| ē | ē |
| Ĕ | Ĕ |
| ĕ | ĕ |
| Ę | Ę |
| ę | ę |
| Ė | Ė |
| ė | ė |
| Ʒ | Ʒ |
| ʒ | ʒ |
| Ǯ | Ǯ |
| ǯ | ǯ |
| F | F |
| f | f |
| Ḟ | Ḟ |
| ḟ | ḟ |
| ƒ | ƒ |
| ff | ff |
| fi | fi |
| fl | fl |
| ffi | ffi |
| ffl | ffl |
| ſt | ſt |
| G | G |
| g | g |
| Ǵ | Ǵ |
| ǵ | ǵ |
| Ģ | Ģ |
| ģ | ģ |
| Ǧ | Ǧ |
| ǧ | ǧ |
| Ĝ | Ĝ |
| ĝ | ĝ |
| Ğ | Ğ |
| ğ | ğ |
| Ġ | Ġ |
| ġ | ġ |
| Ǥ | Ǥ |
| ǥ | ǥ |
| H | H |
| h | h |
| Ĥ | Ĥ |
| ĥ | ĥ |
| Ħ | Ħ |
| ħ | ħ |
| I | I |
| i | i |
| Ì | Ì |
| ì | ì |
| Í | Í |
| í | í |
| Î | Î |
| î | î |
| Ĩ | Ĩ |
| ĩ | ĩ |
| Ï | Ï |
| ï | ï |
| Ī | Ī |
| ī | ī |
| Ĭ | Ĭ |
| ĭ | ĭ |
| Į | Į |
| į | į |
| İ | İ |
| ı | ı |
| IJ | IJ |
| ij | ij |
| J | J |
| j | j |
| Ĵ | Ĵ |
| ĵ | ĵ |
| K | K |
| k | k |
| Ḱ | Ḱ |
| ḱ | ḱ |
| Ķ | Ķ |
| ķ | ķ |
| Ǩ | Ǩ |
| ǩ | ǩ |
| ĸ | ĸ |
| L | L |
| l | l |
| Ĺ | Ĺ |
| ĺ | ĺ |
| Ļ | Ļ |
| ļ | ļ |
| Ľ | Ľ |
| ľ | ľ |
| Ŀ | Ŀ |
| ŀ | ŀ |
| Ł | Ł |
| ł | ł |
| LJ | LJ |
| lj | lj |
| M | M |
| m | m |
| Ṁ | Ṁ |
| ṁ | ṁ |
| N | N |
| n | n |
| Ń | Ń |
| ń | ń |
| Ņ | Ņ |
| ņ | ņ |
| Ň | Ň |
| ň | ň |
| Ñ | Ñ |
| ñ | ñ |
| ʼn | ʼn |
| Ŋ | Ŋ |
| ŋ | ŋ |
| NJ | NJ |
| nj | nj |
| O | O |
| o | o |
| Ò | Ò |
| ò | ò |
| Ó | Ó |
| ó | ó |
| Ô | Ô |
| ô | ô |
| Õ | Õ |
| õ | õ |
| Ö | Ö |
| ö | ö |
| Ō | Ō |
| ō | ō |
| Ŏ | Ŏ |
| ŏ | ŏ |
| Ø | Ø |
| ø | ø |
| Ő | Ő |
| ő | ő |
| Ǿ | Ǿ |
| ǿ | ǿ |
| Œ | Œ |
| œ | œ |
| P | P |
| p | p |
| Ṗ | Ṗ |
| ṗ | ṗ |
| Q | Q |
| q | q |
| R | R |
| r | r |
| Ŕ | Ŕ |
| ŕ | ŕ |
| Ŗ | Ŗ |
| ŗ | ŗ |
| Ř | Ř |
| ř | ř |
| ɼ | ɼ |
| S | S |
| s | s |
| Ś | Ś |
| ś | ś |
| Ş | Ş |
| ş | ş |
| Š | Š |
| š | š |
| Ŝ | Ŝ |
| ŝ | ŝ |
| Ṡ | Ṡ |
| ṡ | ṡ |
| ſ | ſ |
| ß | ß |
| T | T |
| t | t |
| Ţ | Ţ |
| ţ | ţ |
| Ť | Ť |
| ť | ť |
| Ṫ | Ṫ |
| ṫ | ṫ |
| Ŧ | Ŧ |
| ŧ | ŧ |
| Þ | Þ |
| þ | þ |
| U | U |
| u | u |
| Ù | Ù |
| ù | ù |
| Ú | Ú |
| ú | ú |
| Û | Û |
| û | û |
| Ũ | Ũ |
| ũ | ũ |
| Ü | Ü |
| ü | ü |
| Ů | Ů |
| ů | ů |
| Ū | Ū |
| ū | ū |
| Ŭ | Ŭ |
| ŭ | ŭ |
| Ų | Ų |
| ų | ų |
| Ű | Ű |
| ű | ű |
| V | V |
| v | v |
| W | W |
| w | w |
| Ẁ | Ẁ |
| ẁ | ẁ |
| Ẃ | Ẃ |
| ẃ | ẃ |
| Ŵ | Ŵ |
| ŵ | ŵ |
| Ẅ | Ẅ |
| ẅ | ẅ |
| X | X |
| x | x |
| Y | Y |
| y | y |
| Ỳ | Ỳ |
| ỳ | ỳ |
| Ý | Ý |
| ý | ý |
| Ŷ | Ŷ |
| ŷ | ŷ |
| Ÿ | Ÿ |
| ÿ | ÿ |
| Z | Z |
| z | z |
| Ź | Ź |
| ź | ź |
| Ž | Ž |
| ž | ž |
| Ż | Ż |
| ż | ż |
TimNew
------------
To Realize your potential
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
TimNew
------------
To Realize your potential
Posted via email from 米良的实验室
2011年10月13日星期四
Chrome Remote Desktop is amazing
TimNew
------------
To Realize your potential
Posted via email from 米良的实验室
2011年9月19日星期一
Incredipede:一个神奇的游戏
TimNew
------------
To Realize your potential
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
TimNew
------------
To Realize your potential
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 米良的实验室