Skip to content

Instantly share code, notes, and snippets.

View wsky's full-sized avatar
🏠
Working from home

Harry wsky

🏠
Working from home
View GitHub Profile
//解决部分服务器证书问题
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(delegate { return true; });
//以下可选,强制协议
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
ServicePointManager.Expect100Continue = true;
@wsky
wsky / gist:3205844
Created July 30, 2012 09:26
nhibernate sqlce config
<item key="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</item>
<item key="dialect">NHibernate.Dialect.MsSqlCeDialect</item>
<!--create|create-drop-->
<item key="hbm2ddl.auto">create-drop</item>
@wsky
wsky / branch.sh
Last active November 12, 2015 02:05
usual git cmd and svn
# https://github.com/Kunena/Kunena-2.0/wiki/Create-a-new-branch-with-git-and-manage-branches
git branch net20
git push origin net20
git checkout net20
git branch -d [branch]
git push origin --delete [branch]
@wsky
wsky / Application_Error.cs
Created July 30, 2012 03:05
Application_Error Ajax
var header = context.Request.Headers["X-Requested-With"];
if (!string.IsNullOrEmpty(header) && header.ToLower().IndexOf("xmlhttp") >= 0)
{
Server.ClearError();
Response.StatusCode = 400;
Response.Clear();
Response.Write(exception.Message);
Response.End();
return;
}
@wsky
wsky / CookieAwareWebClient.cs
Created July 28, 2012 07:25
CookieAwareWebClient
/// <summary>
/// 支持cookie的webclient
/// <remarks>
/// 请求完成后会自动将响应cookie填充至CookieContainer
/// </remarks>
/// </summary>
internal class CookieAwareWebClient : WebClient
{
internal CookieContainer _cookieContainer = new CookieContainer();
@wsky
wsky / AbstractComponentActivator.cs
Created July 18, 2012 15:40
How to implement Castle.MicroKernel.ComponentActivator.AbstractComponentActivator
public virtual object Create(CreationContext context, Burden burden)
{
var configuration = Model.ExtendedProperties[Constants.SessionFactoryConfiguration] as Configuration;
var f= configuration.BuildSessionFactory();
burden.SetRootInstance(f);//new for 3.x
//onCreation(model, instance);
return f;
}
@wsky
wsky / gist:1815043
Created February 13, 2012 08:32
clr event
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var f = new EventFactory();
f.Raised += (o, e) => { Thread.Sleep(100); Trace.WriteLine(1, Thread.CurrentThread.Name); };
f.Raised += (o, e) => { Thread.Sleep(200); Trace.WriteLine(2, Thread.CurrentThread.Name); };
f.Raised += (o, e) => { Thread.Sleep(300); Trace.WriteLine(3, Thread.CurrentThread.Name); };