Skip to content

Instantly share code, notes, and snippets.

View brantb's full-sized avatar

Brant Bobby brantb

View GitHub Profile
@half-ogre
half-ogre / CreateUrlHelperToFakeIsLocalUrl
Created July 3, 2011 08:02
It is way too hard to fake a call to Controller.Url.IsLocalUrl, which means I failed as a tester that day.
public static UrlHelper CreateUrlHelperToFakeIsLocalUrl(string fakeRequestUrl)
{
var httpContextBase = new Mock<HttpContextBase>();
httpContextBase.Setup(x => x.Request.Url).Returns(new Uri(fakeRequestUrl));
var requestContext = new RequestContext(httpContextBase.Object, new RouteData());
return new UrlHelper(requestContext);
}
// controller.Url = CreateUrlHelperToFakeIsLocalUrl("http://aFakeHost/aFakePage");
@geddski
geddski / nesting.js
Created January 14, 2012 05:08
helper function for nesting backbone collections.
function nestCollection(model, attributeName, nestedCollection) {
//setup nested references
for (var i = 0; i < nestedCollection.length; i++) {
model.attributes[attributeName][i] = nestedCollection.at(i).attributes;
}
//create empty arrays if none
nestedCollection.bind('add', function (initiative) {
if (!model.get(attributeName)) {
model.attributes[attributeName] = [];
@kylefritz
kylefritz / HandlebarsBundleTransform.cs
Created July 6, 2012 13:54
Compile Handlebars Templates in .net mvc
using System.IO;
using System.Text;
using System.Web;
using System.Web.Optimization;
using Jurassic;
using System.Globalization;
namespace Fewt.Web
{