Skip to content

Instantly share code, notes, and snippets.

View mstum's full-sized avatar

Michael Stum mstum

View GitHub Profile
@mstum
mstum / webapi
Last active December 24, 2015 21:09
Microsoft.AspNet.WebApi.WebHost
Microsoft.AspNet.WebApi.OData
protected void Application_Start(object sender, EventArgs e)
{
WebApiConfig.Register(GlobalConfiguration.Configuration);
}
public static void Register(HttpConfiguration config)
{
/*
A C-program for MT19937, with initialization improved 2002/1/26.
Coded by Takuji Nishimura and Makoto Matsumoto.
Before using, initialize the state by using init_genrand(seed)
or init_by_array(init_key, key_length).
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
All rights reserved.
Copyright (C) 2005, Mutsuo Saito,
@mstum
mstum / Level.cpp
Last active August 29, 2015 14:06
CodeReview #62254 - Static Factory function and Lifetime questions
#include "Level.h"
#include <fstream>
#include <sstream>
std::string Level::GetName(){
// Should this return a Pointer?
return _name;
}
int Level::GetPlayerStartX() {
@mstum
mstum / rnn.cs
Created July 20, 2015 23:38
rnn (Requires.NotNull) ReSharper Template
// ReSharper Template to make "rnn" a shortcut to Requires.NotNull
// For use with the Validation NuGet Package by @AArnott
// https://www.nuget.org/packages/Validation
// https://github.com/AArnott/Validation
// C# Pre-6
Validation.Requires.NotNull($param$,"$param$");
// C# 6
Validation.Requires.NotNull($param$, nameof($param$));
@mstum
mstum / Date.cs
Created September 16, 2016 23:52
using System;
namespace mstum.utils
{
/// <summary>
/// A Date type for .net, essentially a <see cref="DateTime" /> without the time portion.
/// </summary>
/// <remarks>
/// If using Dapper, use this to map directly to a Date column in SQL Server:
/// <code>SqlMapper.AddTypeMap(typeof(Date), DbType.Date);</code>

Keybase proof

I hereby claim:

  • I am mstum on github.
  • I am mstum (https://keybase.io/mstum) on keybase.
  • I have a public key whose fingerprint is 5EB3 3CFF 93DE 63E7 40CF E31A 6A91 BC77 F123 9A88

To claim this, I am signing this object:

@mstum
mstum / Program.cs
Created March 19, 2017 04:03
C# 7 Features
using System;
namespace CSharp7Features
{
class Program
{
static void Main(string[] args)
{
OutVariables();

Keybase proof

I hereby claim:

  • I am mstum on github.
  • I am mstum (https://keybase.io/mstum) on keybase.
  • I have a public key whose fingerprint is 66B1 2E11 BA8E 34C1 605F 1D5C 0DE5 B2FF F611 5471

To claim this, I am signing this object:

@mstum
mstum / MyTestClass.tt
Created June 7, 2017 09:00
T4 Template to implement the Builder Pattern
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".cs" #>
<#
var nsName = "Testing";
var className = "MyTestClass";
var accessor = "public";
@mstum
mstum / gist:2fb41dfe16a9fd195b126d9b1fe75fd2
Last active July 10, 2017 02:08
Remotely manage Hyper-V when not domain Joined
Server:
* Enable-PSRemoting (use sconfig for that)
* Enable-WSManCredSSP -Role Server
Client:
* Run PowerShell as Admin
* Enable-PSRemoting
* Set-Item WSMan:\localhost\Client\TrustedHosts -Value "fqdn-of-hyper-v-host"
* -Concatenate can be used to add
* https://stackoverflow.com/questions/21548566/how-to-add-more-than-one-machine-to-the-trusted-hosts-list-using-winrm