Skip to content

Instantly share code, notes, and snippets.

@medmondson
medmondson / NumberSort.cs
Created November 4, 2016 22:21
Basic sort odd/even
int[] numbers = {12, 37, 5, 42, 8, 3};
var evenNumbers = numbers.Where(n => n%2 == 0);
var oddNumbers = numbers.Where(n => n%2 != 0);
@medmondson
medmondson / .cs
Created July 28, 2016 09:31
Using ninject with webapi
//You need to add this line in CreateKernel method of NinjectWebCommon.cs
//GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
//Entire class:
using System.Web.Http;
using gazprom.uk.Services;
using Ninject.Web.WebApi;
SyntaxNode syntax = SyntaxFactory.UsingStatement(SyntaxFactory.Block() /* the code inside the using block */)
.WithDeclaration(SyntaxFactory
.VariableDeclaration(SyntaxFactory.IdentifierName("var"))
.WithVariables(SyntaxFactory.SingletonSeparatedList(SyntaxFactory
.VariableDeclarator(SyntaxFactory.Identifier(variableName))
.WithInitializer(SyntaxFactory.EqualsValueClause(SyntaxFactory
.ObjectCreationExpression(SyntaxFactory.IdentifierName(typeName))
.WithArgumentList(SyntaxFactory.ArgumentList()))))));
$primaryColor: #eeffcc;
body {
$primaryColor: #ccc !global;
background: $primaryColor;
}
p {
color: $primaryColor;
}
@medmondson
medmondson / commands
Last active March 23, 2016 10:03
NPM Basic Commands
//Installing a package that also updates package.json
//gulp-less example, navigate to project folder to where package.json is located
npm install gulp-less --save
DECLARE @Date1 DATE, @Date2 DATE
SET @Date1 = '20101130'
SET @Date2 = '20160301'
DECLARE @DateSpine TABLE (
date DATE
)
INSERT INTO @DateSpine
SELECT DATEADD(DAY,number+1,@Date1) [Date]
@medmondson
medmondson / MockComparisonExamples.cs
Last active February 29, 2016 15:27
Quick n dirty aync/await
using System;
using System.Threading;
using System.Threading.Tasks;
using FakeItEasy.Examples;
using Moq.Examples;
using NSubstitute.Examples;
using RhinoMocks.Examples;
namespace MockComparisonExamples
{
@medmondson
medmondson / shortcuts.xml
Created February 10, 2016 13:56
Notepad++ ShortCuts
<NotepadPlus>
<InternalCommands />
<Macros>
<Macro name="Trim Trailing and save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
<Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
<Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
</Macro>
<Macro name="EndLineCommas" Ctrl="yes" Alt="no" Shift="yes" Key="188">
<Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
<Action type="3" message="1601" wParam="0" lParam="0" sParam="$" />
@medmondson
medmondson / Auto-generate wix components for files
Last active November 10, 2015 15:19
Powershell to create wix components
Get-ChildItem "C:\Users\matt\Desktop\CShell Install" |foreach {"<Component Id=`"" + $_.name + "`" Guid=`"" +[guid]::NewGuid() + "`">`r`n<File Id=`"" + $_.name + "`" Source=`"`$(var.CShell.TargetDir)\" + $_.name + "`">`r`n</File>`r`n</Component>"} | clip
@medmondson
medmondson / ConsoleWritelineLambda.cs
Last active August 29, 2015 14:17
Console.Writeline in Lambda
var i = new List<string>();
i.Add("Hello");
i.Add("Hello2");
i.Add("Hello3");
i.Add("Hello4");
i.Add("Hello5");
i.ForEach(Console.WriteLine); //Action<T> instead of Func<T>
Console.WriteLine(i.Count(x => x == "Hello").ToString()); //Count in here