Skip to content

Instantly share code, notes, and snippets.

View eightHundreds's full-sized avatar
💤

eightHundreds

💤
  • China
View GitHub Profile
@eightHundreds
eightHundreds / DeepClone.cs
Created April 21, 2017 05:24
the T marked as [Serializable]
public static T DeepClone<T>(T obj)
{
using (var ms = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(ms, obj);
ms.Position = 0;
return (T) formatter.Deserialize(ms);
}
│ cmdutils.h
│ config.h
│ ffmpeg.h
├─compat
│ │ getopt.c
│ │ os2threads.h
│ │ strtod.c
│ │ va_copy.h
│ │ w32pthreads.h
$(document).keydown(function (e) {
if (e.ctrlKey & e.keyCode == 83) {
toastr.success('', '保存成功', { positionClass: "toast-bottom-right" })
e.preventDefault();
}
})
string str=@".....文件路径........";
Path.GetFileName(Str)//返回文件名
Path.GetFileNameWithoutExtension(Str)//返回文件名且没扩展名
Path.GetExtension()//获得扩展名
Path.GetDirectoryName()//获得所在文件夹的名称,就是去除文件名的部分
Path.GetFullPath()//从 获得所在文件的全路径,支持..\a\b的方式获得路径
Path.Combine(string,string)//连接两个字符串,自动处理路径分隔符的问题自动增加 \
string path=Application.StartupPath获得exe文件所在路径
string ChangeExtension(string path, string extension)//修改扩展名
Path.GetTempPath()//获得临时文件夹目录
function hasClass( elements,cName ){
return !!elements.className.match( new RegExp( "(\\s|^)" + cName + "(\\s|$)") );
};
function addClass( elements,cName ){
if( !hasClass( elements,cName ) ){
elements.className += " " + cName;
};
};
function removeClass( elements,cName ){
if( hasClass( elements,cName ) ){
if ("createEvent" in document) {
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
element.dispatchEvent(evt);
}
else
element.fireEvent("onchange");
private bool IsPortOpen(string host, int port, TimeSpan timeout)
{
try
{
using (var client = new TcpClient())
{
var result = client.BeginConnect(host, port, null, null);
var success = result.AsyncWaitHandle.WaitOne(timeout);
if (!success)
{
@eightHundreds
eightHundreds / redirectToNewUrl.cs
Created November 24, 2017 04:59
注意header中不能有中文
[HttpGet("mobile/{*urlParams}")]
[HttpGet("msg/{*urlParams}")]
public IActionResult RedirecToNewUrl(string urlParams)
{
var encodedStrBuilder=new StringBuilder();
foreach (var fragment in urlParams.Split('/'))
{
encodedStrBuilder.AppendFormat("{0}/", TryUrlEncode(fragment));
}
encodedStrBuilder.Remove(encodedStrBuilder.Length - 1, 1);
public static void SetPrivateProperty<T>(object instance, string proName, object value)
{
var type = typeof(T);
var propertyInfo = type.GetProperty(proName, BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.Public);
propertyInfo.SetValue(instance, Convert.ChangeType(value, propertyInfo.PropertyType));
}
@eightHundreds
eightHundreds / README-Template.md
Created March 1, 2018 10:56 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites