Skip to content

Instantly share code, notes, and snippets.

@mwrock
mwrock / InstallChocolatey.cmd
Created April 3, 2012 13:32 — forked from ferventcoder/InstallChocolatey.cmd
Chocolatey One Line Install from the command line
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))";
@mwrock
mwrock / UrlHelperRoute
Created September 26, 2012 16:26
Testing UrlHelper.Route
var mockTeamFoundationFeatureAvailabilityService = new Mock<ITeamFoundationFeatureAvailabilityService>();
var testable = new ApiFeatureAvailabilityController(x => mockTeamFoundationFeatureAvailabilityService.Object);
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:8080/path");
var config = new HttpConfiguration();
config.Routes.MapHttpRoute("FeatureAvailability", "path/{id}", new { Controller = "ApiFeatureAvailability", id = RouteParameter.Optional });
request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
request.Properties[HttpPropertyKeys.HttpRouteDataKey] = config.Routes.GetRouteData(request);
testable.Url = new UrlHelper(request);
testable.Request = request;
@mwrock
mwrock / UrlHelperTest.cs
Created September 26, 2012 16:28
Testing UrlHelper.Route
//This is test setup
var mockTeamFoundationFeatureAvailabilityService = new Mock<ITeamFoundationFeatureAvailabilityService>();
var testable = new ApiFeatureAvailabilityController(x => mockTeamFoundationFeatureAvailabilityService.Object);
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:8080/path");
var config = new HttpConfiguration();
config.Routes.MapHttpRoute("FeatureAvailability", "path/{id}", new { Controller = "ApiFeatureAvailability", id = RouteParameter.Optional });
request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
request.Properties[HttpPropertyKeys.HttpRouteDataKey] = config.Routes.GetRouteData(request);
testable.Url = new UrlHelper(request);
testable.Request = request;
@mwrock
mwrock / gist:4658001
Created January 28, 2013 18:47
Using the RR API to get around App Harbor Port rewriter
RequestReduce.Api.Registry.UrlTransformer =
(context, , rrUrl) => {
var uri = new Uri(rrUrl);
if(uri.IsDefaultPort) {return rrUrl;}
var builder = new UriBuilder(uri);
builder.port = "80" //or whatever
return builder.ToString();
};
@mwrock
mwrock / gist:5130865
Created March 10, 2013 22:50
Boxstarter Example
#Get Boxstarter on RemotePC
CINST Boxstarter.Chocolatey
Import-Module Boxstarter.Chocolatey
#Create minimal nuspec and chocolateyInstall
New-BoxstarterPackage MyPackage
#Edit Install script
Notepad Join-Path $Boxstarter.LocalRepo "tools\ChocolateyInstall.ps1"
#Pack nupkg
Invoke-BoxstarterBuild MyPackage
#share Repo
@mwrock
mwrock / gist:5422718
Created April 19, 2013 19:44
Run this from the root of your workspace to use the TFS PowerTools Powershell CmdLets to exract All pending changes to a zip
Add-Type -AssemblyName System.IO.Compression.FileSystem,System.IO.Compression
$here= (Get-Item .).FullName
$archive = [System.IO.Compression.ZipFile]::Open(
(Join-Path $here "archive.zip"), [System.IO.Compression.ZipArchiveMode]::Create
)
get-tfsPendingChange | % {
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile(
$archive, $_.LocalItem, $_.LocalItem.Substring($here.Length+1)
)
}
@mwrock
mwrock / gist:5422968
Created April 19, 2013 20:19
Importing the TFS Power Tools PowerShell Cmdlets
Import-Module "${env:ProgramFiles(x86)}\Microsoft Team Foundation Server 2012 Power Tools\Microsoft.TeamFoundation.PowerTools.PowerShell.dll"
@mwrock
mwrock / gist:6771863
Created September 30, 2013 23:34
This will setup the apps and features you mentioned. You can use "clist -source windowsfeatures" to see all available features since your IIS and MSMQ settings may vary.
#setup IIS. you may want other IIS features but this is a basic example
cinst IIS-WebServerRole -source windowsfeatures
cinst IIS-HttpCompressionDynamic -source windowsfeatures
cinst IIS-ManagementScriptingTools -source windowsfeatures
cinst IIS-WindowsAuthentication -source windowsfeatures
#I have never setup MSMQ. this turns on the server feature
cinst MSMQ-Server -source windowsfeatures
cinstm DotNet4.5
Update-ExecutionPolicy Unrestricted
ble-blo
cinstm 7zip.install
Write-BoxstarterMessage 'Finished'
cinst 7zip
cinst winrar