Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Specialized;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Moq;
/// <summary>
/// This helper class can be used to set up Moq mocks of MVC3 controllers.
/// Slightly modified from the original version from Scott Hanselman's blog:
@breezhang
breezhang / gistdiff.ps1
Created August 30, 2012 07:33 — forked from timheuer/gistdiff.ps1
My hack start at creating a script for auto-submitting a diff to gist.github.com
# ask the user for a gist name
param (
[string]$gistname = "$(Read-Host 'Enter a name for the gist')"
)
# constant
$gistapi = "https://api.github.com/gists"
$filename = $gistname + '.diff'
$teststring = "`{`"description`": `"the description for this gist`",`"public`": true,`"files`": `{`"file1.txt`": `{`"content`": `"String file contents`"`}`}`}"
# get the diff from the current session
@breezhang
breezhang / gist:3523645
Created August 30, 2012 07:14 — forked from nickfloyd/gist:1046526
Powershell basic authentication
//This returns a 404 not found - powershell; I expected a 401 if my creds were bad
$Url = "https://github.com/api/v2/xml/commits/list/fellowshiptech/portal/Portal_2011.6.23_15-26"
$webclient = new-object system.net.webclient
$webclient.credentials = new-object system.net.networkcredential("user", "password")
$result = $webclient.DownloadString($Url)
$result
//This returns the data I want via terminal
curl -u user:password https://github.com/api/v2/xml/commits/list/fellowshiptech/portal/Portal_2011.6.23_15-26
@breezhang
breezhang / ExampleModel.cs
Created August 29, 2012 02:07 — forked from DalSoft/ExampleModel.cs
ASP.NET MVC 3 - Improved JsonValueProviderFactory using Json.Net
//Example of a model that won't work with the current JsonValueProviderFactory but will work with JsonDotNetValueProviderFactory
public class CmsViewModel
{
public bool IsVisible { get; set; }
public string Content { get; set; }
public DateTime Modified { get; set; }
public DateTime Created { get; set; }
//This property will not work with the current JsonValueProviderFactory
public dynamic UserDefined { get; set; }
}