This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
// http://www.fiddler2.com/fiddler/Core/ | |
using Fiddler; | |
public static class MockWebProxyHelper | |
{ | |
public enum HttpMethods | |
{ | |
GET, POST, PUT, Unknown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Web.Mvc; | |
public class AntiForgeryTokenFilterProvider : IFilterProvider | |
{ | |
public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) | |
{ | |
if (controllerContext.HttpContext.Request.HttpMethod.ToUpper() == "POST") | |
{ | |
yield return new Filter(new ValidateAntiForgeryTokenAttribute(), FilterScope.Global, null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpContext.Current = new HttpContext( | |
new HttpRequest("", "http://tempuri.org", ""), new HttpResponse(new StringWriter())); | |
NameValueCollection headers = HttpContext.Current.Request.Headers; | |
Type t = headers.GetType(); | |
const BindingFlags nonPublicInstanceMethod = BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance; | |
t.InvokeMember("MakeReadWrite", nonPublicInstanceMethod, null, headers, null); | |
t.InvokeMember("InvalidateCachedArrays", nonPublicInstanceMethod, null, headers, null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using Microsoft.Experience.CloudFx.Framework.Configuration; | |
using Microsoft.Experience.CloudFx.Framework.Storage; | |
using Microsoft.WindowsAzure.Storage.Table; | |
public static class TableNameManager | |
{ | |
private static readonly StorageAccountInfo StorageInfo; | |
static TableNameManager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Data.SqlClient; | |
using System.IO; | |
using System.Text; | |
using System.Web; | |
using Microsoft.WindowsAzure.ServiceRuntime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*--------------------- | |
INSTRUCTIONS: | |
1. open https://www.facebook.com/me | |
2. run script* | |
3. refresh if necessary, goto 2. | |
* to save as bookmarklet, create new bookmark in your browser of choice - | |
Name: "hide from timeline" | |
URL: "javascript: <content of gist below>" | |
-----------------------*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*--------------------- | |
INSTRUCTIONS: | |
1. open a photo, ie https://www.facebook.com/photo.php?fbid=XXXXXX | |
2. run script* | |
* to save as bookmarklet, create new bookmark in your browser of choice - | |
Name: "remove tag from photo" | |
URL: "javascript: <content of gist below>" | |
-----------------------*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class SequentialId | |
{ | |
public static string NewId(bool desc = false) | |
{ | |
var ticks = desc ? DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks : DateTime.UtcNow.Ticks; | |
return string.Format("{0:D19}-{1}", ticks, Guid.NewGuid()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: latest MVC's @Html.AntiForgeryToken() also sets this header automatically, so this may no longer be needed. | |
// register in Global.asax.cs: FilterProviders.Providers.Add(new XFrameOptionsHeaderFilterProvider()); | |
public class XFrameOptionsHeaderFilterProvider : IFilterProvider | |
{ | |
public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) | |
{ | |
yield return new Filter(new XFrameOptionsHeaderAttribute(), FilterScope.Global, null); | |
} | |
class XFrameOptionsHeaderAttribute : ActionFilterAttribute | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true; |