Skip to content

Instantly share code, notes, and snippets.

📈
Focusing

Chris S. yetanotherchris

📈
Focusing
Block or report user

Report or block yetanotherchris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yetanotherchris
yetanotherchris / role.json
Last active Aug 29, 2015
Roles JSON and XML
View role.json
[
{
"Name": "Super Admin",
"Description": "God of Roadkill",
"IOCapabilities": [
"View",
"Upload",
"DeleteFile",
"DeleteFolder"
],
View UKBankHolidayCalculator.cs
public class BankHolidayCalculator
{
public bool IsJanuaryBankHolidayMonday(DateTime currentDateTime)
{
// January bank holiday falls on the first working day after New Year's day,
// which is usually January 1st itself.
DateTime newYearsDay = new DateTime(currentDateTime.Year, 01, 01);
DateTime bankHoliday = newYearsDay;
while (IsWorkingDay(bankHoliday.DayOfWeek) == false)
{
View UKBankHolidayCalculatorTests.cs
using System;
using NUnit.Framework;
[TestFixture]
public class BankHolidayCalculatorTests
{
[Test]
[TestCase("Jan 1 2015")]
[TestCase("Jan 1 2016")]
[TestCase("Jan 2 2017")]
View RunNUnit.cs
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();
View AppveyorChrome.ps1
# Project->Settings->Environment->Install script
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
cinst GoogleChrome
cinst gb.MongoDB
View AppveyorConfigFile.ps1
# 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
View fingerprinter.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>
///
View Assembly version for autoincrementing version
public static string AssemblyVersion
{
get
{
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
@yetanotherchris
yetanotherchris / WCFConfigInCode.cs
Created May 3, 2015
Configuring WCF in code (basic HTTP)
View WCFConfigInCode.cs
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 });
View bigwcfconfig.xml
<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" />
You can’t perform that action at this time.