Skip to content

Instantly share code, notes, and snippets.

View yetanotherchris's full-sized avatar
🔏
;ÿÿÿÿrules

Chris S. yetanotherchris

🔏
;ÿÿÿÿrules
View GitHub Profile
@yetanotherchris
yetanotherchris / role.json
Last active August 29, 2015 14:01
Roles JSON and XML
[
{
"Name": "Super Admin",
"Description": "God of Roadkill",
"IOCapabilities": [
"View",
"Upload",
"DeleteFile",
"DeleteFolder"
],
using System;
using NUnit.Framework;
[TestFixture]
public class BankHolidayCalculatorTests
{
[Test]
[TestCase("Jan 1 2015")]
[TestCase("Jan 1 2016")]
[TestCase("Jan 2 2017")]
static void Main(string[] args)
{
Process process = new Process();
process.StartInfo = new ProcessStartInfo(@"C:\Users\chris\Documents\visual studio 2013\Projects\RunNunitTest\packages\NUnit.Runners.2.6.3\tools\nunit-console.exe",
@"D:\projects\roadkill\src\Roadkill.Tests\bin\Debug\Roadkill.Tests.dll " +
"/noxml " +
"/include:Unit");
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.Start();
# Project->Settings->Environment->Install script
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
cinst GoogleChrome
cinst gb.MongoDB
# Project->Settings->Build->Before build script
(gc lib\Configs\connectionStrings.dev.config).replace('Server=(local);Integrated Security=true;Connect Timeout=5;database=Roadkill','Server=(local)\SQL2012SP1;Database=master;User ID=sa;Password=Password12!') | Out-File lib\Configs\connectionStrings.dev.config
(gc src\Roadkill.Tests\Setup\SqlExpressSetup.cs).replace('Server=(local);Integrated Security=true;Connect Timeout=5;database=Roadkill','Server=(local)\SQL2012SP1;Database=master;User ID=sa;Password=Password12!') | Out-File src\Roadkill.Tests\Setup\SqlExpressSetup.cs
public static class Extensions
{
public static string GetFingerPrint(this UrlHelper helper)
{
byte[] hash = SHA256.Create().ComputeHash(Encoding.Unicode.GetBytes(GetLastWriteTime()));
return HttpServerUtility.UrlTokenEncode(hash);
}
/// <summary>
///
public static string AssemblyVersion
{
get
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
@yetanotherchris
yetanotherchris / WCFConfigInCode.cs
Created May 3, 2015 20:54
Configuring WCF in code (basic HTTP)
public class Configuration
{
public static void ConfigureForHttp<T>(ServiceConfiguration config)
{
var existingBehaviour = config.Description.Behaviors.FirstOrDefault(x => x is AspNetCompatibilityRequirementsAttribute);
if (existingBehaviour != null)
{
config.Description.Behaviors.Remove<AspNetCompatibilityRequirementsAttribute>();
}
config.Description.Behaviors.Add(new AspNetCompatibilityRequirementsAttribute { RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed });
@yetanotherchris
yetanotherchris / bigwcfconfig.xml
Created May 6, 2015 11:19
large wcf config file
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyNameSpace.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
@yetanotherchris
yetanotherchris / simplewcf.xml
Created May 6, 2015 11:23
Slightly simpler WCF configuration web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyNameSpace.ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>