Skip to content

Instantly share code, notes, and snippets.

View blyry's full-sized avatar

blyry

View GitHub Profile
@blyry
blyry / HitchhikerTest.cs
Created March 6, 2012 20:34
Best unit test ever.
[Fact]
public void Should_be_able_to_wrap_interface_with_one_method()
{
Func<string, int> length = s => s.Length;
var wrapped = DelegateWrapper.WrapAs<IAnsweringEngine>( length );
Assert.NotNull( wrapped );
var i = wrapped.GetAnswer( "Answer to Life the Universe and Everything" );
Assert.Equal( 42, i );
}
//from http://kozmic.pl/2009/03/20/castle-dynamic-proxy-tutorial-part-viii-interface-proxy-without-target
@blyry
blyry / WhiteListPropertyResolver.cs
Created May 24, 2012 21:15
json.net whitelist converter
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
//Example Usage
/*
var otherTypeObj = new SomeOneElsesType();
var settings = new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
ContractResolver = new WhiteListPropertyResolver("Name","Number","Display","Required","MaxLen","MinLen","Type")
@blyry
blyry / sortbymixin.coffee
Created January 29, 2013 17:30
_.js mixin for string sorting.
#a fancy sorting function
sortWithComparisonMod = (obj, value, context, comparisonFunc) ->
#context and comparisonFunc are optional. if comparisonFunc is null and context is a function, then they've
#given us comparisonFunc in the second index
if _.isFunction(context) && not comparisonFunc? then (comparisonFunc = context;context = obj)
#if they didn't specify a comparisonFunc then they should just use the regular _.sortBy
if not comparisonFunc? then return _.sortBy(obj,value,context)
#normalize the iterator
iterator = if _.isFunction(value) then value else (obj) -> obj[value]
#rest of the sort function, this is kindof like how .NET does lambda closures! neato. From _.js 1.4.2
@blyry
blyry / PropertySizeComparer.cs
Last active January 2, 2016 18:19
IComparer for our app - it compares shirt sizes, with overloads for a couple of DTOs.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Cubrd.Services.DTOs;
namespace Cubrd.Services.Utility
{
Enable-RemoteDesktop
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
cinst IIS-WebServerRole -source windowsfeatures
cinst smtp4dev
cinst eazfuscator.net
cinst firefox
cinst googlechrome
cinst lastpass
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
cinst jre8
cinst dotnet3.5
cinst DotNet4.5
cinst eazfuscator.net
cinst firefox
cinst putty
cinst putty.install
cinst winrar
@blyry
blyry / dexServerChoco.ps1
Last active August 29, 2015 14:19
index server
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
CINST Boxstarter
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
cinst git
cinst git.install
cinst tortoisegit
cinst notepadplusplus
cinst notepadplusplus.install
cinst winmerge
@blyry
blyry / vmDev
Created December 21, 2015 15:59
Enable-RemoteDesktop
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar
cinst IIS-WebServerRole -source windowsfeatures
cinst lastpass
cinst putty
cinst putty.install
cinst everything
cinst winrar
@blyry
blyry / Routes.cs
Created January 14, 2016 23:40
first stab at automatically generating wcf ServiceContracts and OperationCOntracts.
/*
I think the next best way to go is to investigate hooking into ninject
and ninject.dynamicproxy to dynamically add the attributes to a proxy class that we hand off to wcf.
We can't just make our own dynamic proxy because we lose the dependency injection on the instance that ninject already gave us
BUT maybe if there's a dynamic proxy that just wraps the instance it was already given?
class myclass {
public foo() {}
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adPDCVMName": {
"type": "string"
},
"adAvailabilitySetName": {
"type": "string"
},