How to extend Visual Studio Xaml Designer

I do want to extend Visual Studio Xaml designer with a context menu, but encountered many troubles.

  1. To get start,  this page helps.
  2. To choose right extension method, I inspected source code of similar tools. For my case, it’s StyleCop.
  3. To understand VSPackage project, read How VSPackages Add User Interface Elements to the IDE.
  1. To set correct parent guid:id, refer project XAML Markup Styler. Two post are helpful here:
    1. http://archive.msdn.microsoft.com/VSCTPowerToy
    1. http://blogs.msdn.com/b/dr._ex/archive/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1.aspx
Posted in Uncategorized | Leave a comment

用PowerShell批量编辑ID3

很多MP3的ID3是BIG5编码的 用下边这个PowerShell脚本可以批量把title, author变成简体中文

$big5 = [Text.Encoding]::GetEncoding(950)
$root = “<your mp3 folder>”
$files = Get-ChildItem $root -Filter “*.mp3” -Recurse
foreach($file in $files) {

 

$wmp = New-object –COM WMPlayer.OCX;

$media = $wmp.newMedia($file.FullName);

$newTitle = $big5.GetString([Text.Encoding]::Default.GetBytes($media.GetItemInfo(“Title”)));

$media.SetItemInfo(“Title”, $newTitle);

$newAuthor = $big5.GetString([Text.Encoding]::Default.GetBytes($media.GetItemInfo(“Author”)));

$media.SetItemInfo(“Author”, $newAuthro);

}

Posted in Uncategorized | Leave a comment

没装office如何看doc/docx文件

有人说了,我们可以安装word viewer。确实不错,可word viewer也得下载一会儿,最主要是我根本不想装多余的软件。现在SkyDrive就可以在线查看word, excel和ppt文件了,对于excel还可以在线编辑。Have a try. Office Live也有相同功能。

Posted in Uncategorized | Leave a comment

how to send gmail from ubuntu terminal

  1. Telnet won’t work because gmail requires SSL now.
  2. Prepare your user/password in base64 encoding.
  3. openssl s_client -CApath /etc/ssl/certs/ -connect smtp.gmail.com:465 -crlf (-crlf is important)
  4. SMTP session:helo
    auth login
    UserInBase64
    PasswordInBase64
    mail from: <sender>
    rcpt to: <to>
    data
    .
    quit
Posted in Uncategorized | Leave a comment

How run Windows Virtual PC and VirtualBox at the same time

Posted in Uncategorized | Leave a comment

Visual Studio don’t response when I create new project or stop debugging

Today, I found visual studio didn”t response for more one minute when creating new project or just stopping debugging. It was quit annoying! I had to wait and wait everytime I stopped debugging and wanted to change some code. I didn’t know what to do while waiting and can’t remember the idea I was thinking when I came back. Annoying.

VS’s UI didn’t hang, but you can’t click any place of it. I tried following things:

  1. Open Task Manager. CPU and memory is ok.
  2. Open Process Explorer. Can’t find any thread in VS is consuimg CPU.
  3. Open Process Monitor. No much record and information. VS was just profiling itself and creating a few existing folders.
  4. Uninstall newly installed VS exstention.
  5. Uninstall big VS exstension.

The problem was still there. It might have something to do with network because home network is slower than company network if VS is trying to fetch data from other servers. It shouldn’t show such difference because I didn’t encounter it before. The only difference from yesterday is that our servers were shutdown this weekend. Visual Studio might fetch data form shutdown server. It might relate to debugging, because it’s ok if I start program by pressing ctrl+F5. Finally I found a deadly symbol path pointing to our ‘sleeping’ server. 🙂

Posted in Uncategorized | Leave a comment

新机器

嘎嘎
Posted in Uncategorized | 5 Comments

转: From twitter

帝都很多文绉绉的地名其实原本乡土得很。甘井胡同→干井胡同;辟才胡同→劈柴胡同;礼士路→驴市胡同;光彩胡同→棺材胡同;秀水街→臭水街;雅宝路→哑巴胡同;中关村→中官村→中官(太监)坟。
Posted in Uncategorized | Leave a comment

最近遭遇三大骗

第一骗 01095500 阳光保险电话推销

第二骗 17996 铁通上门推销
第三骗 KFC
请广大群众小心上网晓习 提前预防
Posted in Life | Leave a comment

Product of everything except current

Product of everything except current
Write a function that takes as input two integer arrays of length len, input and index, and generates a third array, result, such that:
result[i] = product of everything in input except input[index[i]]
Specifically:
void everythingExcept(int len,                // in parameters
                      int *input, int *index,
                      int *result             // out parameter
                     );
For instance, if the function is called with len=4, input={2,3,4,5}, and index={1,3,2,0}, then result will be set to {40,24,30,60}.
IMPORTANT: Your algorithm must run in linear time.
If you would like to implement the solution in C#, consider the following signature:
public int[] everythingExcept(int[] input, int[] index);

Answer:
For example, if we have 4 elements in input array, we could calculate product like this:
Step1         a1 a2 a3 a4
                 1  *   *  *
                 *  *   *  1
—————————
Step 2     a1   a2  a3 a4
              1    *   *   *
              1*a1 *   *   *
              *    *   *   a4*1
              *    *   *   1
——————————
Step 3     a1    a2  a3 a4
              1     *   *   *
              a1    *   a3*a4
              a1*a2    *   a4
              *     *   *   1
——————————
Step 4   a1    a2  a3 a4
           1     a2*a3*a4
           a1    *   a3*a4
           a1*a2    *   a4
           a1*a2*a3     1

code written in notepad:
public int[] everythingExcept(int[] input, int[] index)
{
    // null, empty, index range check
    int[,] pairs = new int[input.Length,2];
    pairs[0,0] = 1;
    for(int i = 1; i< input.Length ; i++)
    {
        pairs[i,0] = pairs[i-1,0] * input[i-1];
    }
    pairs[input.Length-1,1] = 1;
    for(int i = input.Length – 2; i>=0; i–)
    {
        pairs[i,1] = pairs[i+1,1] * input[i+1];
    }
    int[] result = new result[input.Length];
    for(int i = 0; i < result.Length; i++)
    {
        reuslt[i] = pairs[index[i],0] * pairs[index[i],1];
    }
    return result;
}
NOTE: we can’t calculate product of all elements then divide each element, because product of all elements might be great than Int32.MaxValue but result array don’t.

Posted in 计算机与 Internet | Leave a comment