Copy and Paste is not working on my Remote Desktop Connection… what’s wrong?

A very annoying occurrence that I sometimes suffer is when all of a sudden the copy and paste function stops working when I am connected to a remote machine. Turns out the problem is coming from a little process called rdpclip. Rdpclip (remote desktop clipboard) is responsible for managing a shared clipboard between your local host and the remote desktop (the process runs on the remote machine not your local host).

So what do I do when clipboard stops working?

Luckily fixing the issue is pretty straightforward and involves a few simple steps.

  1. Load up task manager (right click taskbar and select Task Manager)
  2. Go to the Processes Tab
  3. Select rdpclip.exe
  4. Click End Process
  5. Go to the Application Tab
  6. Click New Process
  7. Type rdpclip
  8. Click Ok

There, copy and paste should now work normally again.

It happens so often, this process is annoying! What do I do to fix it permanently?

Unfortunately I don’t know why rdpclip stops working nor how to fix it permanently; however, there is a way to make it easier if it happens often.

  • Create a new bat file and call it whatever you want say, clipboard.bat.
  • Write the following two commands on separate lines in the new bat file
    • Taskkill.exe /im rdpclip.exe
    • Rdpclip.exe
    • Save the bat file and drag it into the toolbar quick launch section

Now whenever your copy and paste operation fails to restore it, all you need to do is click this new batch file which will kill rdpclip and restart it. Still a workaround but at least it’s a quick procedure.

– See more at: http://www.gfi.com/blog/copy-paste-working-remote-desktop-connection-whats-wrong/#sthash.AhDKFvk7.dpuf

C#从文件byte[]获取文件mime(contentType)

public class MimeHelper
    {
        public static int MimeSampleSize = 256;
        public static string DefaultMimeType = "application/octet-stream";
        [DllImport(@"urlmon.dll", CharSet = CharSet.Auto)]
        private extern static System.UInt32 FindMimeFromData(
            System.UInt32 pBC,
            [MarshalAs(UnmanagedType.LPStr)] System.String pwzUrl,
            [MarshalAs(UnmanagedType.LPArray)] byte[] pBuffer,
            System.UInt32 cbSize,
            [MarshalAs(UnmanagedType.LPStr)] System.String pwzMimeProposed,
            System.UInt32 dwMimeFlags,
            out System.UInt32 ppwzMimeOut,
            System.UInt32 dwReserverd
        );
        public static string GetMimeFromBytes(byte[] data)
        {
            try
            {
                uint mimeType;
                FindMimeFromData(0, null, data, (uint)MimeSampleSize, null, 0, out mimeType, 0);
                var mimePointer = new IntPtr(mimeType);
                var mime = Marshal.PtrToStringUni(mimePointer);
                Marshal.FreeCoTaskMem(mimePointer);
                return mime ?? DefaultMimeType;
            }
            catch
            {
                return DefaultMimeType;
            }
        }
    }

Node.js使用express解析cookie

首先使用cookieParser()解析请求头里的Cookie, 并用cookie名字的键值对形式放在 req.cookies 你也可以通过传递一个secret 字符串激活签名了的cookie 。
app.use(express.cookieParser());
app.use(express.cookieParser('some secret'));

下面是读写cookie的代码


var express = require('express');
var app = express();
app.get('/readcookie',function(req,res){
    res.send('req.cookies.name:' + req.cookies.name);
});
app.get('/writecookie',function(req,res){
    res.cookie('name', 'I'm a cookie', 60000);
    res.send("cookie saved");
});
app.listen(3000);
console.log('listening on port 3000');

Node.js教程起步资料

Tutorials

Videos

Screencasts

Books

Courses

Blogs

Podcasts

JavaScript resources

Node Modules

Other

.Net mvc自定义字符串截取(考虑全角/半角)

public static class HtmlHelpers
{
  public static string Truncate(this HtmlHelper helper, string inputString, int length)
  {
    string tempString = string.Empty;
    for (int i = 0, tempIndex = 0; i < inputString.Length; ++i, ++tempIndex)
    {
      if (System.Text.Encoding.UTF8.GetBytes(new char[] { inputString[i] }).Length > 1)
      {
        ++tempIndex;
      }
      if (tempIndex >= length)
      {
        tempString += "...";
        break;
      }
      tempString += inputString[i];
    }
    return tempString;
  }
}

C#中汉字排序简单示例(拼音/笔划)


class Program
    {
        static void Main(string[] args)
        {
            string[] arr = { "趙(ZHAO)", "錢(QIAN)", "孫(SUN)", "李(LI)", "周(ZHOU)", "吳(WU)", "鄭(ZHENG)", "王(WANG)"};
            //发音 LCID:0x00000804
            CultureInfo PronoCi = new CultureInfo(2052);
            //Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");
            Array.Sort(arr);
            Console.WriteLine("按发音排序:");
            for (int i = arr.GetLowerBound(0); i <= arr.GetUpperBound(0); i++)
                Console.WriteLine("[{0}]:t{1}", i, arr.GetValue(i));
            Console.WriteLine();
            //笔画数 LCID:0x00020804
            CultureInfo StrokCi = new CultureInfo(133124);
            Thread.CurrentThread.CurrentCulture = StrokCi;
            Array.Sort(arr);
            Console.WriteLine("按笔划数排序:");
            for (int i = arr.GetLowerBound(0); i <= arr.GetUpperBound(0); i++)
                Console.WriteLine("[{0}]:t{1}", i, arr.GetValue(i));
            Console.WriteLine();
            //zh-cn (拼音:简中)
            Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-cn");
            Array.Sort(arr);
            Console.WriteLine("zh-cn:");
            for (int i = arr.GetLowerBound(0); i <= arr.GetUpperBound(0); i++)
                Console.WriteLine("[{0}]:t{1}", i, arr.GetValue(i));
            Console.WriteLine();
            //zh-tw (笔划数:繁中)
            Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-tw");
            Array.Sort(arr);
            Console.WriteLine("zh-tw:");
            for (int i = arr.GetLowerBound(0); i <= arr.GetUpperBound(0); i++)
                Console.WriteLine("[{0}]:t{1}", i, arr.GetValue(i));
            Console.ReadKey();
        }
    }