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
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
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
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
//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
// .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
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
public class CmsController : BootstrapBaseController | |
{ | |
private readonly PrismicProxy _prismicProxy; | |
public CmsController(PrismicProxy prismicProxy) | |
{ | |
_prismicProxy = prismicProxy; | |
} | |
public ActionResult Dynamic(string id) |
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
using System; | |
using System.Threading; | |
using Xunit; | |
namespace MyNameSpace.Tests | |
{ | |
public class CacheTests | |
{ | |
[Fact] | |
public void CanReuseCachedObject() |
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
public class RequireApiKey : ActionFilterAttribute | |
{ | |
private static readonly ILog Logger = LogManager.GetLogger(typeof(RequireApiKey)); | |
public override void OnActionExecuting(HttpActionContext context) | |
{ | |
var ipAddress = GetIpAddress(context); | |
Logger.InfoFormat("API attempt. Uri {0} - IP {1} - Headers {2} ", context.Request.RequestUri, ipAddress, context.Request.Headers); | |
IEnumerable<string> values; | |
if (context.Request.Headers.TryGetValues("ApiKey", out values) && GetApiKeys().Any (x => x ==values.First()) |