Skip to content

Instantly share code, notes, and snippets.

View howarddierking's full-sized avatar

Howard Dierking howarddierking

View GitHub Profile
@howarddierking
howarddierking / get-oauth.js
Created October 12, 2011 03:20
jQuery to handle an OAuth challenge response
function GetCommentsWithOAuth(){
viewModel.comments([]);
$.ajax({ url: "/services/comments/oauth",
accepts: "application/json",
cache: false,
statusCode: {
200: function(data){
viewModel.comments(data);
},
@howarddierking
howarddierking / OAuthFacebookOperationHandler.cs
Created October 12, 2011 00:41
Web API Operation Handler for initiating a server-driven OAuth2 workflow with Facebook
public class OAuthFacebookOpHandler : HttpOperationHandler<HttpRequestMessage, HttpRequestMessage> {
readonly Uri _facebookBaseAuthUri = new Uri("https://www.facebook.com/dialog/oauth");
readonly AuthorizeAttribute _authorizationAttribute;
readonly string _facebookAppId;
public OAuthFacebookOpHandler() : base("response") { }
public OAuthFacebookOpHandler(AuthorizeAttribute authorizeAttribute, string appId) : this() {
_authorizationAttribute = authorizeAttribute;
_facebookAppId = appId;
@howarddierking
howarddierking / customMTF_skeleton.cs
Created September 14, 2011 18:56
custom media type formatter - skeleton
class MyCustomMediaTypeFormatter : MediaTypeFormatter
{
public MyCustomMediaTypeFormatter() {
SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/vnd.howard.fancyformat"));
}
protected override object OnReadFromStream(Type type, Stream stream, HttpContentHeaders contentHeaders) {
//stuff
}
@howarddierking
howarddierking / gist:1209930
Created September 11, 2011 18:22
Project file transformation
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl b"
xmlns:b="http://schemas.microsoft.com/developer/msbuild/2003">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/b:Project">
<xsl:copy>
@howarddierking
howarddierking / gist:1209919
Created September 11, 2011 18:16
powershell script for transforming a codebase
Import-Module Pscx
# the variables you'll likely need to change on your local machine
$afroot = "D:\AppFabric"
$hgroot = 'D:\Programming Projects'
# $hgremote = "https://hg01.codeplex.com/wcf"
$hgremote = "D:\Programming Projects\wcf-codeplex-baseline_RC2"
# derived paths
$afwcfsource = $afroot + "\private\source\WCF"
Get-ChildItem $wcfsource -Exclude "*.StyleCop" -Recurse | %{Copy-Item $_.FullName -Destination ($hgroot + $_.FullName.Substring($wcfsource.Length)) -Force}
@howarddierking
howarddierking / EtagMessageHandler.cs
Created July 1, 2011 23:52
sample message handler for managing etags in web api
public class EtagMessageHandler : DelegatingChannel
{
readonly IETagStore _eTagStore;
public EtagMessageHandler(HttpMessageChannel innerChannel) : base(innerChannel) {
Trace.WriteLine("EtagMessageHandler - Ctor");
_eTagStore = new InMemoryETagStore();
}