TimeSpan span = DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc));
Console.WriteLine(span.TotalMilliseconds);
输出:
1386928595163.35
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.
- Load up task manager (right click taskbar and select Task Manager)
- Go to the Processes Tab
- Select rdpclip.exe
- Click End Process
- Go to the Application Tab
- Click New Process
- Type rdpclip
- 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;
}
}
}
How can I select the first day of a month in SQL?
SELECT DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0)
Getting a string dynamically from strings resources
ResourceManager rm = new ResourceManager("RootResourceName",
typeof(SomeClass).Assembly);
string someString = rm.GetString("someString");
how to catch NULL values using case statement
select contactid,Title,FirstName,MiddleName, case ISNULL(MiddleName, 'NULLVALUE') when 'R.' then 'Robert' when 'B.' then 'Bids' when 'J.' then 'John' when 'NULLVALUE' then 'New Name' else 'No Name' end, LastName from Person.Contact
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使用express处理静态文件,static file
var express = require('express');
var app = express();
// log requests
app.use(express.logger('dev'));
app.use(express.static(__dirname + '/public'));
app.listen(1024);
console.log('Listening on port 1024');
使用http://localhost:1024/css/style.css就可以读取/public/css/style.css文件了
Node.js教程起步资料
Tutorials
- Hello World
- Hello World Web Server
- Node.js guide
- Build a blog with Node.js, express and mongodb
- Node.Js Tutorials At Project 70
- Node.js for Beginners
Videos
- Node tuts
- Introduction to Node.js with Ryan Dahl
- Node.js: Asynchronous Purity Leads to Faster Development
- Parallel Programming with Node.js
- Server-side JavaScript with Node, Connect & Express
- Node.js First Look
- Ryan Dahl’s Google Tech Talk
Screencasts
Books
- The Node Beginner Book
- Mastering Node.js
- Up and Running with Node.js
- Node.js in Action
- Smashing Node.js: JavaScript Everywhere
- Node.js & Co. (in German)
- Sam’s Teach Yourself Node.js in 24 Hours
- Most detailed list of free JavaScript Books
Courses
Blogs
Podcasts
JavaScript resources
- Crockford’s videos (must see!)
- Essential JavaScript Design Patterns For Beginners
- JavaScript garden
- JavaScript Patterns book
- JavaScript: The Good Parts book
Node Modules
- Wiki List on Github/Joyent/Node (start here last!)
- Search for registered node.js 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;
}
}