Skip to content

Instantly share code, notes, and snippets.

@mhinze
mhinze / build.cmd
Created February 22, 2013 13:38
Updated build.cmd psake launcher ... useful for pulling down solution package (like psake) .. since later this script actually invokes psake.
@echo off
rem source arg below can be semicolon-delim ie '-source "https://nuget.org/api/v2/;\\server\share"'
.\src\.nuget\nuget.exe install src\.nuget\packages.config -source "" -RequireConsent -o "src\packages"
if '%1'=='/?' goto help
if '%1'=='-help' goto help
if '%1'=='-h' goto help
powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\src\packages\psake.4.2.0.1\tools\psake.ps1' %*; if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }"
@mhinze
mhinze / ArrangeActAssertTemplate.cs
Created January 14, 2013 15:11
A template for Arrange / Act / Assert
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Should;
namespace $NAMESPACE$
{
[TestClass]
public class ArrangeActAssertTemplate
{
[TestMethod]
@mhinze
mhinze / TestCaseClassPerFixtureTemplate.cs
Created January 14, 2013 14:40
A template for "test case path per fixture" test organization pattern from http://xunitpatterns.com/Testcase%20Class%20per%20Fixture.html
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Should;
namespace $NAMESPACE$
{
[TestClass]
public class TestCaseClassPerFixtureTemplate
{
public static string actual;
@mhinze
mhinze / ExpectedExceptionWithMessageAttribute.cs
Created January 14, 2013 14:35
Extend the ridiculous MSTest ExpectedExceptionBaseAttribute to assert on message
using System;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace $NAMESPACE$
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class ExpectedExceptionWithMessageAttribute : ExpectedExceptionBaseAttribute
{
readonly bool _allowDerivedTypes;
@mhinze
mhinze / bench.txt
Created August 1, 2012 19:14
benchmarque output
c:\dev\FOO\IntegrationTests\bin\Release>..\..\..\packages\Benchmarque.0.1.10\tools\Benchmarque.Console.exe .\IntegrationTests.dll
Subject Assembly: .\IntegrationTests.dll
Loading subject assembly: c:\dev\FOO\IntegrationTests\bin\Release\IntegrationTests.dll
Benchmark ReadingBenchmark, Runner IDeserializeContent, 1 iterations
Implementation Duration Difference Each Multiplier
==============================================================================
Resx -0- -0- 89
Protobuf -0- -0- 1135 12.75x
MsgPack 2ms 2ms 3786 42.54x
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@mhinze
mhinze / bloody.txt
Created May 3, 2012 00:38
[The Listserve] A Bloody Mar/y/ia from Juba, South Sudan
here is something that i have worked on for a long time.
you can sort out the proportions to taste, but it will make you a solid bloody maria.
even in south sudan you can find most of these things.
you may need to sneak the tomato juice in, or use ceres.
i have not put in proportions, but have listed these things in order of importance/operation/process. it's art. deal.
if you hate things that taste good you can substitute vodka for tequila
juba / 2012
==================================
static Task<TResult> WrapTask<TResult>(this Task<TResult> task, Action<TResult> failedResultFactory)
{
TaskCompletionSource<TResult> tcs = new TaskCompletionSource<TResult>();
task.ContinueWith(result => tcs.SetResult(result);
task.Catch(exception => tcs.SetResult(failedResultFactory()));
return tcs.Task;
}
@mhinze
mhinze / exposeiis.ps1
Created February 22, 2012 14:39
Sample solutionscript to expose IIS
function global:ExposeIIS()
{
$config = [xml] ( get-content $env:IIS_USER_HOME/config/applicationhost.config )
# Add in new bindings for computer name
foreach($site in $config.configuration."system.applicationHost".sites.site)
{
foreach($bindings in $site.bindings)
{
# no need to add another binding for machine name if its exists
@mhinze
mhinze / orderme.cs
Created February 14, 2012 14:50
stupid first thoughts about some set ordering interface thing
public interface IOrderMe
{
Order PreferredOrder();
// or somethign like "void OrderMe(OrderContext relativeToOtherItems);"
}
public abstract class Order
{