Skip to content

Instantly share code, notes, and snippets.

@pisceanfoot
pisceanfoot / binary search
Created April 17, 2014 02:01
binary search
@pisceanfoot
pisceanfoot / CrossFrameIE
Last active September 28, 2022 15:29
CrossFrameIE UnauthorizedAccessException
// FREE code from CODECENTRIX
// http://www.codecentrix.com/
// http://codecentrix.blogspot.com/
using System;
using System.Runtime.InteropServices;
using mshtml;
namespace CodecentrixSample
{
@pisceanfoot
pisceanfoot / XmlParser
Last active August 29, 2015 14:01
XmlParser with different xmlroot
public class XmlParser
{
private static Regex regex = new Regex("<(\\w+?)[ >]", RegexOptions.Compiled);
public static T Parse<T>(string body,Encoding encoding) where T : class
{
Type type = typeof(T);
string rootTagName = GetRootElement(body);
XmlAttributes rootAttrs = new XmlAttributes();
@pisceanfoot
pisceanfoot / EasyWebRequest
Created May 14, 2014 01:16
http web request helper
public static class EasyWebRequest
{
/// <summary>
/// HttpWebRequest方式
/// </summary>
public enum HttpMethod {
GET,
POST
};
@pisceanfoot
pisceanfoot / EnCryptographyHelper
Created May 14, 2014 01:17
EnCryptographyHelper with md5
public static class EnCryptographyHelper
{
public static string MD5Encoding(byte[] content)
{
MD5 md5 = MD5.Create();
byte[] bytes = md5.ComputeHash(content);
return HexToString(bytes);
}
@pisceanfoot
pisceanfoot / XmlUtils
Created May 14, 2014 01:17
merge multi xml file to xml
/// <summary>
///
/// </summary>
public static class XmlUtils
{
/// <summary>
/// MergeFiles to a single file
/// </summary>
/// <param name="files"></param>
/// <param name="fileContentMergeFail"></param>
@pisceanfoot
pisceanfoot / ClassLoader
Created May 14, 2014 01:18
ClassLoader reflect
public static class ClassLoader
{
public static List<T> Load<T>(string fileFullPath)
{
return Load<T>(new string[] { fileFullPath });
}
public static List<T> Load<T>(string path, string parttern)
{
string[] files = Directory.GetFiles(path, parttern);
@pisceanfoot
pisceanfoot / Log
Created May 14, 2014 01:19
log use log4net
/// <summary>
///
/// </summary>
public static class Log
{
private static ILog logger;
static Log()
{
string log4NetConfigPath = AppDomain.CurrentDomain.BaseDirectory + "//Log4Net.config";
@pisceanfoot
pisceanfoot / RetryableExcuteQueue
Created May 14, 2014 01:19
RetryableExcuteQueue
public class RetryableExcuteQueue<T>
where T : CommonContract
{
private Queue<ExuteItem> queue;
public RetryableExcuteQueue()
{
this.queue = new Queue<ExuteItem>();
}
@pisceanfoot
pisceanfoot / Thumbnail
Created May 14, 2014 04:56
GetNewSize - Thumbnail image
/// <summary>
/// </summary>
/// <remarks>
/// 原图路径
/// <add key="SourcePath" value="D:\Temp\Image\P800"/>
/// 压缩尺寸,多个尺寸“;”分隔
/// <add key="Destination" value="340*255"/>
/// <add key="Destination" value="340*255;640*480"/>
/// 保存路径,多个路径“;”分隔
/// <add key="NewSizePath" value="D:\Temp\Image\P340"/>