This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var customMatchers = { | |
toInclude: function (util, customEqualityTesters) { | |
return { | |
compare: function (actual, expected) { | |
if (expected === undefined) { | |
expected = ''; | |
} | |
var result = { | |
message: '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .NET/CLR app domains | |
// You - always want to be logging these errors! | |
AppDomain.CurrentDomain.UnhandledException += (s,e) => {}; | |
// Framework specific handlers | |
System.Windows.Application.Current.DispatcherUnhandledException += (s,e) => {}; // WPF | |
System.Windows.Forms.Application.ThreadException += (s,e) => {}; // Windows Forms | |
System.Threading.Tasks.TaskScheduler.UnobservedTaskException += (s,e) => {}; // TPL - not really very imporant | |
// ASP.NET (i'm guessing you hook into this in your Global.asx?) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//On start up : | |
MvcHandler.DisableMvcResponseHeader = true; | |
// as an http module/global asax | |
protected void Application_PreSendRequestHeaders(object sender, EventArgs e) | |
{ | |
// Remove the "Server" HTTP Header from response - security review recommends against sending this | |
var app = sender as HttpApplication; | |
if (app == null || null == app.Context) return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-AzureEmulatorErrors | |
{ | |
$LocalApplicationDataPath = [Environment]::GetFolderPath([System.Environment+SpecialFolder]::LocalApplicationData) | |
$AzureResourceRoot = "$LocalApplicationDataPath\dftmp\Resources" | |
Write-Host "Local Azure Resource Root: $AzureResourceRoot" | |
pushd "$AzureResourceRoot" | |
$logs = (dir -Recurse *\directory\LoggingStorage\*.log) | |
$ErrorAndWarnLines = $logs | Select-String -pattern "\[ERROR\]|\[WARN \]" | |
$entries = $ErrorAndWarnLines | select LineNumber, ` | |
Line, ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example usages: | |
public class MyControllerFixture : IUseFixture<ControllerFixtureInit> | |
{ | |
private readonly MyController _sut; | |
private ControllerTestContext _controllerTestContext; | |
private readonly IMyDependency _dependency; | |
public MyControllerFixture() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void ConfigureContainer() | |
{ | |
var containerBuilder = new ContainerBuilder(); | |
var assembly = Assembly.GetExecutingAssembly(); | |
containerBuilder.RegisterControllers(assembly); | |
containerBuilder.RegisterType<Mediator>().As<IMediator>(); | |
containerBuilder.RegisterAssemblyTypes(typeof(CustomerService).Assembly) | |
.AsImplementedInterfaces();//Will regiter the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var accounts = new Dictionary<string,string>{ | |
{"accountname", "accountkey"}, | |
}; | |
var latestLogsByAppName = GetLatestLogsByAppName(accounts); | |
latestLogsByAppName//.Where (l => !l.ApplicationName.Contains("WebRole") ) | |
//.Where(l => l.LastModified < DateTime.UtcNow.AddDays(-1)) | |
.OrderBy (l => l.LastModified) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
//turn response codes into enum values | |
var things = GetData().Select (x =>{ | |
var id = GetNumberFromStart(x); | |
var name = ConvertToVariable(x.Replace(id.ToString(),string.Empty)); | |
return string.Format("{0} = {1},",id,name); | |
} ); | |
things.Dump(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Select-UniqueChildrenWithStringPattern { | |
param($path, $pattern) | |
Get-ChildItem $path -Recurse -exclude *.exe,*.dll,*.pdb,*.jpg,*.png,*.gif,*.mst,*.msi,*.msm,*.gitignore,*.idx,*.pack,*.suo,*.ico,*.nupkg,*.zip,*.7z | | |
Select-String -Pattern $pattern | | |
Where-Object { $_ -ne $null } | | |
Select-Object Path -Unique | |
} | |
function String-ReplaceRecursive { | |
param($path, $pattern, $replaceValue) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Set environment variables for Visual Studio Command Prompt | |
pushd 'c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC' | |
cmd /c "vcvarsall.bat&set" | | |
foreach { | |
if ($_ -match "=") { | |
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])" | |
} | |
} | |
popd | |
write-host "`nVisual Studio 2012 Command Prompt variables set." -ForegroundColor Yellow |