This file contains hidden or 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 static MidFunc Tracing(ITracer tracer) | |
{ | |
if (tracer == null) throw new ArgumentNullException("tracer"); | |
tracer = new SafeTracer(tracer); | |
return next => async env => | |
{ | |
if (!tracer.IsEnabled) | |
{ |
This file contains hidden or 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
Windows Registry Editor Version 5.00 | |
[HKEY_CURRENT_USER\Software\Lenovo\SmartKey\Application\Row\Function\Microsoft Visual Studio 2013] | |
"AppPath"="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\devenv.exe" |
This file contains hidden or 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
# Utilities | |
cinst 7zip | |
cinst ConEmu | |
# Fonts | |
cinst SourceCodePro | |
# Coding | |
cinst git | |
cinst P4Merge |
This file contains hidden or 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 Microsoft.AspNet.Builder; | |
namespace KWebStartup | |
{ | |
public class Startup | |
{ | |
public void Configure(IBuilder app) | |
{ | |
// Doesn't require a dependency on anything. | |
// It's just an extension method on Func<AppFunc, AppFunc>. |
This file contains hidden or 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 interface IEmailSender | |
{ | |
void Send(string recipient, string subject, string htmlBody); | |
} | |
public class EmailSender : IEmailSender | |
{ | |
private readonly IEmailSettings _settings; | |
public EmailSender(IEmailSettings settings) |
This file contains hidden or 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 AnimalFactory | |
{ | |
public IEnumerable<IAnimal> GetAnimals() | |
{ | |
yield return new Dog(); | |
var ducks = GetDucks(); | |
// return ducks; <-- **BOOM** Cannot return a value from an iterator. | |
This file contains hidden or 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 YsodStatusCodeHandler : IStatusCodeHandler | |
{ | |
public bool HandlesStatusCode(HttpStatusCode statusCode, NancyContext context) | |
{ | |
return statusCode == HttpStatusCode.InternalServerError; | |
} | |
public void Handle(HttpStatusCode statusCode, NancyContext context) | |
{ | |
object error; |
This file contains hidden or 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 DemoBoostrapper : DefaultNancyBootstrapper | |
{ | |
protected override NancyInternalConfiguration InternalConfiguration | |
{ | |
get | |
{ | |
return NancyInternalConfiguration.WithOverrides(x => x.StatusCodeHandlers.Clear()); | |
} | |
} | |
} |
This file contains hidden or 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 ExampleUsage | |
{ | |
private readonly IPasswordHasher _hasher; | |
public ExampleUsage(IPasswordHasher hasher) | |
{ | |
_hasher = hasher; | |
} | |
public void Register(string username, string password) |
This file contains hidden or 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 static class RequestExtensions | |
{ | |
public static bool IsLocal(this Request request) | |
{ | |
var remoteAddress = request.UserHostAddress; | |
if (string.IsNullOrEmtpy(remoteAddress)) | |
{ | |
return false; | |
} |