Skip to content

Instantly share code, notes, and snippets.

View dotnetchris's full-sized avatar

Chris Marisic dotnetchris

View GitHub Profile
@dotnetchris
dotnetchris / 1 - Map Arguments to Properties.cs
Created February 19, 2016 20:53 — forked from bretcope/1 - Map Arguments to Properties.cs
Sigil Object Mapping - Basic Examples
// Runnable from Linqpad 5
// Must install the Sigil nuget package and include the Sigil namespace
void Main()
{
var createSample = GetMapperDelegate();
// try it out
createSample(23, "Hello").Dump();
}
public class StyleRelativePathTransform : IBundleTransform
{
private const string UrlPattern = @"url\s*\(\s*([""']?)([^:)]+)\1\s*\)";
private static readonly Regex UrlRegex = new Regex(UrlPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
public void Process(BundleContext context, BundleResponse response)
{
var mergedCss = new StringBuilder();
@dotnetchris
dotnetchris / publish.targets
Created October 5, 2012 14:34
Msbuild file for getting web deploy to play nicely with Cassette.MSBuild
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CassetteOutputPath>$(IntermediateOutputPath)cassette-cache</CassetteOutputPath>
<CopyAllFilesToSingleFolderForPackageDependsOn>
BundleAssets;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
@dotnetchris
dotnetchris / Cassette.targets
Created October 5, 2012 14:36
Tweaked Cassette.targets file for working with web deploy and Cassette.MSBuild
<?xml version="1.0" encoding="utf-8" ?>
<!--
The web application csproj file has been modified to import this file.
So after a build, the Cassette bundles will be saved into a cache directory.
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="$(OutputPath)\Cassette.MSBuild.dll" TaskName="CreateBundles"/>
<PropertyGroup>
<!--<CassetteOutputPath Condition="'$(CassetteOutputPath)' == ''">Content/cassette-cache</CassetteOutputPath>-->
@dotnetchris
dotnetchris / web.config
Created September 20, 2012 20:48
RavenDB server web.config usage for gist https://gist.github.com/3758246
<configuration>
<appSettings>
<add key="Raven/AnonymousAccess" value="All" />
<add key="Raven/RunInMemory" value="true" />
<add key="Raven/VirtualDirectory" value="/ravendb.testserver" />
<add key="Raven/TempIndexPromotionMinimumQueryCount" value="1" />
</appSettings>
<system.web>
<customErrors mode="Off">
</customErrors>
@dotnetchris
dotnetchris / Skip_transform_results_tests
Created September 20, 2012 20:45
These tests show a bug in the usage of SkipTransformResults against index queries when using RavenDB 960 Server mode, but not Embedded
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using Raven.Abstractions.Data;
using Raven.Abstractions.Indexing;
using Raven.Client.Document;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
@dotnetchris
dotnetchris / gist:3298615
Created August 8, 2012 20:44
Restful ASP.NET MVC C# controller
[Authorize("Users")]
public class ProfileController : ResourceController
{
private readonly UserReports _userReports;
private readonly Func<UserService> _userServiceFactory;
private readonly ILogger _logger;
private readonly Func<ProfileViewModelValidator> _validatorFactory;
public ProfileController(UserReports userReports, Func<UserService> userServiceFactory, Func<ProfileViewModelValidator> validatorFactory, ILogger logger)
{
@dotnetchris
dotnetchris / gist:2924189
Created June 13, 2012 13:50
Failing test for EasyHttp when dealing with Json dates
public class when_json_dates
{
Establish context = () =>
{
input =@"{""Users"":[{""Id"":""90c68332-a5e2-42ca-bde7-9e0701412110"",""IsActive"":true,""LockedOutUntil"":""\/Date(1289073014137)\/""}],""Count"":1}";
IEnumerable<IDataReader> readers = new List<IDataReader> { new JsonReader(new DataReaderSettings(DefaultEncoderDecoderConfiguration.CombinedResolverStrategy()), "application/.*json") };
decoder = new DefaultDecoder(new RegExBasedDataReaderProvider(readers));
@dotnetchris
dotnetchris / gist:1706161
Created January 30, 2012 19:30
MSpec verification
static bool DoSomethingCompleted = false;
Establish context = () =>
{
The<IThing>()
.WhenToldTo(x => x.DoSomething())
.Return(()=> { DoSomethingCompleted = true; return 5; });
};
@dotnetchris
dotnetchris / gist:1473259
Created December 13, 2011 18:36
Using Machine.Fakes to share testing configuration through composition
[Subject(typeof(ThingOrchestrator))]
public class Given_i_am_a_logged_user_and_view_things : WithSubject<ThingOrchestrator>
{
private static readonly List<People> PeopleRepository = new List<People> {.....};
private static readonly List<Thing> ThingsRepository = new List<Thing> { ...... };
private static readonly List<Thing> ResultThings = new List<Thing>();
private static readonly List<Exception> Exceptions = new List<Exception>();