Skip to content

Instantly share code, notes, and snippets.

public class E
{
const string DEFAULT_ALPHABET = "mn6j2c4rv8bpygw95z7hsdaetxuk3fq";
const int DEFAULT_BLOCK_SIZE = 24;
const int MIN_LENGTH = 5;
public E()
{
this.Alphabet = DEFAULT_ALPHABET;
this.BlockSize = DEFAULT_BLOCK_SIZE;
@pisceanfoot
pisceanfoot / DownloadFile
Created May 14, 2014 07:38
fiddler plug DownloadFile
public class DownloadFile
{
public static void Download(Session oSession, string allowDomain)
{
if (oSession.responseCode != 200)
{
return;
}
string[] validDomain = allowDomain.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
@pisceanfoot
pisceanfoot / ServiceBlocker
Created May 16, 2014 08:56
wcf ServiceBlocker
internal class WCFFactory<T> : System.ServiceModel.ClientBase<T>
where T : class
{
public WCFFactory(string endpointConfigurationName)
: base(endpointConfigurationName)
{
}
public T GetService()
{
@pisceanfoot
pisceanfoot / python.bat
Created May 20, 2014 00:46
doskey for multi python installed
@echo off
doskey python27=D:\Python27\python.exe $*
doskey python31=D:\Python31\python.exe $*
@pisceanfoot
pisceanfoot / UrlConvert
Created May 20, 2014 01:16
ShortenUrl display
public class UrlConvert
{
#region Url Shortener
// http://blog.madskristensen.dk/post/Resolve-and-shorten-URLs-in-Csharp.aspx
private static readonly Regex regex = new Regex("((http://|www\\.)([A-Z0-9.-:]{1,})\\.[0-9A-Z?;~&#=\\-_\\./]{2,})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly string link = "<a href=\"{0}{1}\">{2}</a>";
/// <summary>
/// 缩短链接中Url地址
/// </summary>
@pisceanfoot
pisceanfoot / StringConvert
Created May 20, 2014 01:18
StringConvert util
/// <summary>
/// 类名: StringConvertUtil
/// 描述: 实现字符串的转换
/// 作者: Heclei
/// 版本: 1.0.0.0
/// 日期: 2007-04-11
/// </summary>
public class StringConvert
{
#region 转16进制字符串
@pisceanfoot
pisceanfoot / StringUtil
Created May 20, 2014 01:19
StringUtil html regex
public class StringUtil
{
#region 截取中文字符串
/// <summary>
/// 获取 gb2312 字符串长度
/// </summary>
/// <param name="content">字符串,兼容Null和DbNull.Value</param>
/// <param name="length">长度</param>
/// <returns></returns>
public static string GetGB2312StringLength(object obj, int length)
@pisceanfoot
pisceanfoot / CleanInvalidXmlChars
Created May 20, 2014 01:21
Clean Invalid Xml Chars
public static string CleanInvalidXmlChars(string text)
{
// From xml spec valid chars:
// #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
string re = @"[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000-x10FFFF]";
return Regex.Replace(text, re, "");
}
@pisceanfoot
pisceanfoot / SSBXmlTextWriter
Created May 20, 2014 01:21
SSB Xml TextWriter
public class SSBXmlTextWriter : XmlTextWriter
{
private static Regex InvalidXMLCharacter = new Regex(@"[\u0000-\u0008\u000B\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]", RegexOptions.Compiled);
public SSBXmlTextWriter(TextWriter w)
: base(w)
{
}
public SSBXmlTextWriter(Stream w, Encoding encoding)
@pisceanfoot
pisceanfoot / GenClassesFromXSD.bat
Created May 20, 2014 06:12
Gen Classes From XSD
SET VSNET_BINPATH="C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\xsd.exe"
%VSNET_BINPATH% /c /namespace:Framework.DataAccess DataAccessSettings.xsd
%VSNET_BINPATH% /c /namespace:Framework.DataAccess DataOperations.xsd