Skip to content

Instantly share code, notes, and snippets.

View wshaddix's full-sized avatar

Wes Shaddix wshaddix

View GitHub Profile
Scenario: Creating a message with a name greater than 75 characters should fail
And I fill in "Name" with "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
And I press "Create Message"
Then I should see "Message was not successfully created."
And I should see "Name can't be more than 75 characters."
@wshaddix
wshaddix / gist:8797934
Created February 4, 2014 03:57
Gets the week number for a given date
main () {
// get today's date
var now = new DateTime.now();
// set it to feb 10th for testing
//now = now.add(new Duration(days:7));
int today = now.weekday;
/*
* Password Hashing With PBKDF2 (http://crackstation.net/hashing-security.htm).
* Copyright (c) 2013, Taylor Hornby
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
// get the password from the user
var clearTextPassword = "Passw0rd";
// create the password hash
var passwordHash = PasswordHash.CreateHash(clearTextPassword);
// store the password hash in a data store
// ...
// (later when the user tries to login)
@wshaddix
wshaddix / UiControllerBase.cs
Last active August 29, 2015 14:01
Asp.Net MVC UI Controller Base Class
public abstract class UiControllerBase : Controller
{
private readonly ILog _log;
protected UiControllerBase(ILog log)
{
_log = log;
}
internal string LoggedInUsername
@wshaddix
wshaddix / CookieTempDataProvider.cs
Created May 22, 2014 00:12
Cookie based TempData provider for Asp.Net MVC applications that don't want to use Session to store TempData content
public class CookieTempDataProvider : ITempDataProvider
{
private const string CookieName = "TempData";
private readonly IFormatter _formatter;
public CookieTempDataProvider()
{
_formatter = new BinaryFormatter();
}
@wshaddix
wshaddix / ILog.cs
Created July 29, 2014 22:48
ILog Interface
using System.Runtime.CompilerServices;
namespace Insiders.Web.Infrastructure.Logging.Interfaces
{
public interface ILog
{
void Debug(string message, [CallerMemberName] string memberName = "");
void Debug(object data, [CallerMemberName] string memberName = "");
@wshaddix
wshaddix / RollbarLogger.cs
Created July 29, 2014 22:57
RollbarLogger
using Insiders.Web.Infrastructure.Logging.Interfaces;
using Insiders.Web.Infrastructure.Stats.Interfaces;
using Newtonsoft.Json;
using RollbarSharp;
using System.Runtime.CompilerServices;
namespace Insiders.Web.Infrastructure.Logging.Implementation
{
public class RollbarLogger : ILog
{
@wshaddix
wshaddix / IoC.cs
Created July 29, 2014 23:21
IoC Class for minimal configuration of Rollbar logging and StatHat stats
using System.Configuration;
using Insiders.Web.Infrastructure.Logging.Implementation;
using Insiders.Web.Infrastructure.Logging.Interfaces;
using Insiders.Web.Infrastructure.Stats.Implementation;
using Insiders.Web.Infrastructure.Stats.Interfaces;
using StructureMap;
using StructureMap.Graph;
namespace Insiders.Web.Infrastructure.IoC
{
@wshaddix
wshaddix / StructureMapDependencyResolver.cs
Created July 29, 2014 23:30
A custom dependency resolver for Asp.Net MVC 5 that utilizes StructureMap for dependency resolution
using Microsoft.Practices.ServiceLocation;
using StructureMap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Insiders.Web.Infrastructure.IoC
{
public class StructureMapDependencyResolver : ServiceLocatorImplBase