Skip to content

Instantly share code, notes, and snippets.

@mat-mcloughlin
mat-mcloughlin / Postcode.cs
Last active July 30, 2016 21:48
Value Object
public class Postcode
{
private readonly string value;
public Postcode(string value)
{
if (CheckPostcodeIsValid(value))
{
throw new InvalidPostcodeException();
}
Set-ExplorerOptions - showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
cinst steam
cinst googlechrome
cinst git
cinst 7zip
cinst atom
cinst skype
cinst nodejs
{
"fansz": {
"aliases": {},
"mappings": {
"users": {
"properties": {
"backgroundImage": {
"type": "string"
},
"backgroundImageAspectRatio": {
static void Main(string[] args)
{
////////// Setup Elastic
var node = new Uri("http://localhost:9200");
var settings =
new ConnectionSettings(node).SetDefaultIndex("fansz")
.MapDefaultTypeNames(m => m.Add(typeof(UserElastic), "users"));
var client = new ElasticClient(settings);
[TestFixture]
public class WhenCreatingANewUser
{
private ConfigurableContext _configurableContext;
[TestFixtureSetUp]
public void Setup()
{
_configurableContext = new ConfigurableContext<WriteContext>(x =>
{
public class Settings
{
public Settings()
{
SomeString = Helpers.GetSetting("SomeString", "DefaultString");
SomeInt = Helpers.GetSetting("SomeInt", 9, int.TryParse);
SomeTimeSpan = Helpers.GetSetting("SomeTimeSpan", new TimeSpan(60), Helpers.TimeSpanParser);
}
public string SomeString { get; set; }
{
"locked": false,
"version": -9998,
"projectFileDependencyGroups": {
"": [
"riakclient >= 2.1.0"
],
"DNX,Version=v4.5.1": [],
"DNXCore,Version=v5.0": [
"System.Console >= 4.0.0-beta-*"
@mat-mcloughlin
mat-mcloughlin / rename.cs
Created May 30, 2015 16:21
Roslyn Rename
public RosylnController()
{
_workspace = new AdhocWorkspace();
_project = _workspace.AddProject("AdhocProject", LanguageNames.CSharp);
}
[Route("rename")]
public async Task<string> Post(string buffer, int line, int column, string newName)
{
var document = _project.AddDocument("AdhocDocument", SourceText.From(buffer));
@mat-mcloughlin
mat-mcloughlin / Guard.cs
Last active August 29, 2015 14:16
guard.cs
namespace Foo
{
using System;
internal static class Guard
{
internal static void EnsureNotNull(object argument, string argumentName)
{
if (argument == null)
{
@mat-mcloughlin
mat-mcloughlin / abstract
Last active August 29, 2015 14:14
.NET sans Microsoft
It used to be that if you wanted to write .NET code you would be completely reliant on Microsoft for their tools, frameworks and even their operating system. Now things are changing. The .NET open source community has grown in size, and with it, so have your options for frameworks and libraries. Microsoft have even annouced that they are building a cross platform CLR, so you are no longer reliant on Windows. The release of Roslyn and its rich code analysis API's is bringing with it a new wave of lightweight cross platfrom editors that can replace Visual Studio.
In this talk I will discuss some of these technologies, tools and libraries, and demonstrate their viability to show you that there is a new way of developing in the .NET world.